diff --git a/CHANGELOG.md b/CHANGELOG.md index fdf39c0d71051424034a7b4692d842365c5d6b8f..38a116c971551b3dc32944434c9b96ef72f5b481 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,55 @@ +0.42.0-beta5 +============= +* UI improvements: + * Updated the design of Enable Cookies CMS page + * Implemented UI improvements for Widgets + * Fixed the "Help Us to Keep Magento Healthy Report All Bugs (ver. #)" link Magento Admin + * Various UI improvements +* Various improvements: + * Implemented Sales Quote as a standalone Magento module + * Performed custom EAV entities code and DB tables cleanup + * Eliminating remnants of the Core module: + * Moved Application Emulation from the Magento_Core module to the Magento_Store module + * Moved Validator Factory from the Magento_Core module to the Magento Framework + * Added static integrity test for composer.json files + * Added PHPMD and PHPCS annotations to the codebase +* Tests improvements: + * Added MVP tag to the functional tests + * Created acceptance functional test suite + * Replaced end-to-end tests for url rewrite creation, CMS page creation, category creation, review creation, customer frontend creation, and tax rule creation with injectable tests + * Automated test cases for downloadable products with taxes +* Fixed bugs: + * Fixed an issue where the Discounts and Coupons RSS Feed had incorrect title + * Fixed an issue where a wrong special price expiration date was displayed in RSS + * Fixed an issue in the Import functionality where imported files disappeared after the Check Data operation + * Fixed an issue where the Unsubscribe link in the Newsletter was broken + * Fixed an issue where stock status changed incorrectly after import + * Fixed an issue where selected filters and exclude did not work during Export + * Fixed an issue where tax details order was different on order/invoice/refund create and view pages ( + * Fixed a typo in the getCalculationAlgorithm public function + * Fixed an issue where the incorrect value of Subtotal Including Tax was displayed in invoices + * Fixed an issue where tax details were not displayed on a new order + * Improved pricing performance using caching + * Fixed an issue where CsvImportHandler tests still referring to links from Tax module instead of TaxImportExport module + * Fixed an issue where an exception was thrown instead of 404 if altering the url for a product with required configuration on the storefront + * Fixed an issue where the title of successfully placed order page (was empty + * Fixed an issue where certain fields were not disabled by default on the website scope in System configuration as expected + * Fixed an issue where third party interfaces were not supported by single-tenant compiler + * Eliminated the 'protocol' parameter from the ReadInterface and WriteInterface +* GitHub requests: + * [#979](https://github.com/magento/magento2/pull/979) -- Adding OSL license file name + * [#978](https://github.com/magento/magento2/pull/978) -- Added ignore rule for media assets in wysiwyg directory + * [#877](https://github.com/magento/magento2/pull/877) -- Made Topmenu HTML Editable + * [#906](https://github.com/magento/magento2/pull/906) -- Add tests for View\Layout\Reader\Block and slight refactoring + * [#682](https://github.com/magento/magento2/issues/682) -- \Magento\Framework\Pricing\PriceCurrencyInterface depends on Magento application code + * [#581](https://github.com/magento/magento2/issues/581) -- About ByPercent.php under different currencies + * [#964](https://github.com/magento/magento2/pull/964) -- Improving documentation for jMeter performance tests + * [#871](https://github.com/magento/magento2/issues/871) -- Replace Symfony2/Yaml in composer + * [#990](https://github.com/magento/magento2/pull/990) -- add @see annotation before class to make it recognizable by IDE + * [#988](https://github.com/magento/magento2/pull/988) -- Prevent Varnish from creating cache variations of static files +* Framework improvements: + * Improved unit and integration tests coverage + 0.42.0-beta4 ============= * Various improvements: diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index afe0c85867f61b7ccb796a4b5f27de9490617a1f..bc34fafaa9af87aa9403285ca3d90360f0e4f1e3 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json index d2f381ae0325a7815a5fad52d9c1cb112cedaaf2..a3a185e6298dee66b20e5e63685c28bb919f8f94 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|~5.6.0", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index 15dd54529caafe0737a419aae8bc12a5a1616206..ffc4471cf18facae41490778df9ca509a208f5e4 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-cron": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-reports": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-user": "0.42.0-beta4", - "magento/module-backup": "0.42.0-beta4", - "magento/module-email": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-translation": "0.42.0-beta4", - "magento/module-require-js": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-cron": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-reports": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-user": "0.42.0-beta5", + "magento/module-backup": "0.42.0-beta5", + "magento/module-email": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-translation": "0.42.0-beta5", + "magento/module-require-js": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index 61ae463dbbfb871007f0d844216592d42ffd883e..e84901d7a97de5b7f5252ace20a810922fbe1550 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-cron": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-cron": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Bundle/Model/Plugin/QuoteItem.php b/app/code/Magento/Bundle/Model/Plugin/QuoteItem.php index 0ed1f9390ce3db6548fd52874fd16254023d17bd..2b75f6081ea37c968f74866dadf1021ca7058b5e 100644 --- a/app/code/Magento/Bundle/Model/Plugin/QuoteItem.php +++ b/app/code/Magento/Bundle/Model/Plugin/QuoteItem.php @@ -23,7 +23,7 @@ class QuoteItem \Magento\Quote\Model\Quote\Item\ToOrderItem $subject, Closure $proceed, \Magento\Quote\Model\Quote\Item\AbstractItem $item, - $additional + $additional = [] ) { /** @var $orderItem \Magento\Sales\Model\Order\Item */ $orderItem = $proceed($item, $additional); diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index 34e5452ba8ae9588556ab899e9f6f5d5b8ba4e46..3f739c4f4f52fc65a4a08f26e0a68ac451a3cafc 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-catalog-rule": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-gift-message": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-webapi": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-catalog-rule": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-gift-message": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-webapi": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index bf03a08ae1f64a880e0a75fce1a0b19bb9c82d90..40d3551fe5f686b4332a1538be4c027714889d8d 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index c29886f7d6dc66200347729ca3d2c869dce2bb83..78890f7ffbc33eaf9774442feb0f9c247b9140db 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/module-indexer": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-log": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-widget": "0.42.0-beta4", - "magento/module-wishlist": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-msrp": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-catalog-rule": "0.42.0-beta4", - "magento/module-product-alert": "0.42.0-beta4", - "magento/module-url-rewrite": "0.42.0-beta4", - "magento/module-catalog-url-rewrite": "0.42.0-beta4", - "magento/module-page-cache": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/module-indexer": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-log": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-widget": "0.42.0-beta5", + "magento/module-wishlist": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-msrp": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-catalog-rule": "0.42.0-beta5", + "magento/module-product-alert": "0.42.0-beta5", + "magento/module-url-rewrite": "0.42.0-beta5", + "magento/module-catalog-url-rewrite": "0.42.0-beta5", + "magento/module-page-cache": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml index 73c5aeafa13a6726a8135290b9cb73a855961eaf..e876bb781caaf6cb809b0e4863c2f33122e94aba 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml @@ -47,7 +47,8 @@ <script> require([ "jquery", - "mage/mage" + "mage/mage", + "Magento_Catalog/product/view/validation" ], function($){ $('#product_addtocart_form').mage('validation', { radioCheckboxClosest: '.nested' diff --git a/app/code/Magento/Catalog/view/frontend/web/product/view/validation.js b/app/code/Magento/Catalog/view/frontend/web/product/view/validation.js index 703137b01af9a668c896b1bc8c41abf80b035c50..a19ab628f91dbc17c322ddd30aa5bd30bdd7326a 100644 --- a/app/code/Magento/Catalog/view/frontend/web/product/view/validation.js +++ b/app/code/Magento/Catalog/view/frontend/web/product/view/validation.js @@ -17,7 +17,7 @@ $.widget("mage.validation", $.mage.validation, { options: { - radioCheckboxClosest: 'ul', + radioCheckboxClosest: 'ul, ol', errorPlacement: function (error, element) { if (element.attr('data-validate-message-box')) { var messageBox = $(element.attr('data-validate-message-box')); diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index f305a4d190986d9ed07dc82a7a3baffe84268e32..0f1e15621d4c515c5e14db5f9da26681066370d0 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|~5.6.0", - "magento/module-core": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-import-export": "0.42.0-beta4", - "magento/module-indexer": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-core": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-import-export": "0.42.0-beta5", + "magento/module-indexer": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index 04b35d08bafd1e3e81bc23e109d56a0433113285..001776a920d18b64ea9c2f625f3fae4baf378a45 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-indexer": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-indexer": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index c19ff885884e4d4b62a505e46683922d0a286255..24b81d1d9452fd558b4b67850207953b0a3005ea 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-rule": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-indexer": "0.42.0-beta4", - "magento/module-import-export": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-rule": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-indexer": "0.42.0-beta5", + "magento/module-import-export": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index 67e0dae7369e19c2e3d8e65bfe386b943ff38c29..2b41756668e5d0a59eb55b7f85cc8c682b0da1ee 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-search": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-indexer": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-search": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-indexer": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index 44828ca1beea76ef7b05b305895c00c086e2ebf0..3e2d1948b46b96df04880114b3c172b679d425a3 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|~5.6.0", - "magento/module-backend": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-catalog-import-export": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-import-export": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-url-rewrite": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-backend": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-catalog-import-export": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-import-export": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-url-rewrite": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogWidget/composer.json b/app/code/Magento/CatalogWidget/composer.json index 0b537e7372e655b2bed226107e160ca13c185d28..e1963e0dccdf761955ca3caa9af12e30ccc6caef 100644 --- a/app/code/Magento/CatalogWidget/composer.json +++ b/app/code/Magento/CatalogWidget/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-widget": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-rule": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-wishlist": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-widget": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-rule": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-wishlist": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Centinel/composer.json b/app/code/Magento/Centinel/composer.json index 4917eeddd80ed8b379ef057bbf9faa85c983e37c..3146aae7bf54f76b15686cd304b5b8773ee862fe 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php index dc5032ca4cde14b6ec9b0d88cea1c98fccf660e9..6bb7a5e450882e6e51e435e74e9e92a783743019 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php +++ b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php @@ -106,7 +106,6 @@ class SaveOrder extends \Magento\Checkout\Controller\Onepage $result['error'] = true; $result['error_messages'] = __('Something went wrong processing your order. Please try again later.'); } - $this->quoteRepository->save($this->getOnepage()->getQuote()); /** * when there is redirect to third party, we don't want to save order yet. * we will save the order in return action. diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php deleted file mode 100644 index 8b6a70d41742f8d668d3460be9ab046d9de99d0c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address\Billing; - -use Magento\Checkout\Service\V1\Address\Converter as AddressConverter; - -/** Quote billing address read service object. */ -class ReadService implements ReadServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Address converter. - * - * @var AddressConverter - */ - protected $addressConverter; - - /** - * Constructs a quote billing address object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param AddressConverter $addressConverter Address converter. - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - AddressConverter $addressConverter - ) { - $this->quoteRepository = $quoteRepository; - $this->addressConverter = $addressConverter; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Address Quote billing address object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getAddress($cartId) - { - /** - * Address. - * - * @var \Magento\Quote\Model\Quote\Address $address - */ - $address = $this->quoteRepository->getActive($cartId)->getBillingAddress(); - return $this->addressConverter->convertModelToDataObject($address); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadServiceInterface.php deleted file mode 100644 index 0aa26f48fa5d1477ba5b31b40e41c2b9eb5a6d97..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadServiceInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address\Billing; - -/** Quote billing address read service interface. */ -interface ReadServiceInterface -{ - /** - * Returns the billing address for a specified quote. - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Address Quote billing address object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getAddress($cartId); -} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php deleted file mode 100644 index 52ae8d39ebae405cc45395b1891e2ae764e95ff5..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address\Billing; - -use Magento\Checkout\Service\V1\Address\Converter; -use Magento\Checkout\Service\V1\Address\Validator; -use Magento\Quote\Model\Quote\AddressFactory; -use Magento\Quote\Model\QuoteRepository; -use Magento\Framework\Exception\InputException; -use Psr\Log\LoggerInterface as Logger; - -/** Quote billing address write service object. */ -class WriteService implements WriteServiceInterface -{ - /** - * Validator. - * - * @var Validator - */ - protected $addressValidator; - - /** - * Logger. - * - * @var Logger - */ - protected $logger; - - /** - * Address factory. - * - * @var AddressFactory - */ - protected $quoteAddressFactory; - - /** - * Converter. - * - * @var Converter - */ - protected $addressConverter; - - /** - * Quote repository. - * - * @var QuoteRepository - */ - protected $quoteRepository; - - /** - * Constructs a quote billing address service object. - * - * @param QuoteRepository $quoteRepository Quote repository. - * @param Converter $addressConverter Address converter. - * @param Validator $addressValidator Address validator. - * @param AddressFactory $quoteAddressFactory Quote address factory. - * @param Logger $logger Logger. - */ - public function __construct( - QuoteRepository $quoteRepository, - Converter $addressConverter, - Validator $addressValidator, - AddressFactory $quoteAddressFactory, - Logger $logger - ) { - $this->addressValidator = $addressValidator; - $this->logger = $logger; - $this->quoteRepository = $quoteRepository; - $this->quoteAddressFactory = $quoteAddressFactory; - $this->addressConverter = $addressConverter; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @param \Magento\Checkout\Service\V1\Data\Cart\Address $addressData Billing address data. - * @return int Address ID. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\InputException The specified cart ID or address data is not valid. - */ - public function setAddress($cartId, $addressData) - { - /** - * Quote. - * - * @var \Magento\Quote\Model\Quote $quote - */ - $quote = $this->quoteRepository->getActive($cartId); - /** - * Address. - * - * @var \Magento\Quote\Model\Quote\Address $address - */ - $address = $this->quoteAddressFactory->create(); - $this->addressValidator->validate($addressData); - if ($addressData->getId()) { - $address->load($addressData->getId()); - } - $address = $this->addressConverter->convertDataObjectToModel($addressData, $address); - $quote->setBillingAddress($address); - $quote->setDataChanges(true); - try { - $this->quoteRepository->save($quote); - } catch (\Exception $e) { - $this->logger->critical($e); - throw new InputException('Unable to save address. Please, check input data.'); - } - return $quote->getBillingAddress()->getId(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteServiceInterface.php deleted file mode 100644 index b8ebd60a726ec6dde78079b8d9e1fd204b097704..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteServiceInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address\Billing; - -/** - * Quote billing address write service interface. - */ -interface WriteServiceInterface -{ - /** - * Assigns a specified billing address to a specified cart. - * - * @param int $cartId The cart ID. - * @param \Magento\Checkout\Service\V1\Data\Cart\Address $addressData Billing address data. - * @return int Address ID. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\InputException The specified cart ID or address data is not valid. - */ - public function setAddress($cartId, $addressData); -} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Converter.php b/app/code/Magento/Checkout/Service/V1/Address/Converter.php deleted file mode 100644 index 344c2e9bba3eeba263586d3aba4f4ece8faa504b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Converter.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address; - -use Magento\Checkout\Service\V1\Data\Cart\Address; -use Magento\Checkout\Service\V1\Data\Cart\AddressBuilder; -use Magento\Checkout\Service\V1\Data\Cart\Address\Region; -use Magento\Customer\Api\CustomerMetadataInterface; -use Magento\Framework\Api\AttributeValue; -use Magento\Framework\Api\SimpleDataObjectConverter; - -/** Quote shipping address converter service. */ -class Converter -{ - /** - * Address builder. - * - * @var AddressBuilder - */ - protected $addressBuilder; - - /** - * Customer metadata service interface. - * - * @var CustomerMetadataInterface - */ - protected $customerMetadata; - - /** - * Constructs a quote shipping address converter service object. - * - * @param AddressBuilder $addressBuilder Address builder. - * @param CustomerMetadataInterface $customerMetadata Metadata service. - */ - public function __construct(AddressBuilder $addressBuilder, CustomerMetadataInterface $customerMetadata) - { - $this->addressBuilder = $addressBuilder; - $this->customerMetadata = $customerMetadata; - } - - /** - * Converts a quote address model to an address data object. - * - * @param \Magento\Quote\Model\Quote\Address $address The quote address model. - * @return \Magento\Checkout\Service\V1\Data\Cart\Address Address data object. - */ - public function convertModelToDataObject(\Magento\Quote\Model\Quote\Address $address) - { - $data = [ - Address::KEY_COUNTRY_ID => $address->getCountryId(), - Address::KEY_ID => $address->getId(), - Address::KEY_CUSTOMER_ID => $address->getCustomerId(), - Address::KEY_REGION => [ - Region::REGION => $address->getRegion(), - Region::REGION_ID => $address->getRegionId(), - Region::REGION_CODE => $address->getRegionCode() - ], - Address::KEY_STREET => $address->getStreet(), - Address::KEY_COMPANY => $address->getCompany(), - Address::KEY_TELEPHONE => $address->getTelephone(), - Address::KEY_FAX => $address->getFax(), - Address::KEY_POSTCODE => $address->getPostcode(), - Address::KEY_CITY => $address->getCity(), - Address::KEY_FIRSTNAME => $address->getFirstname(), - Address::KEY_LASTNAME => $address->getLastname(), - Address::KEY_MIDDLENAME => $address->getMiddlename(), - Address::KEY_PREFIX => $address->getPrefix(), - Address::KEY_SUFFIX => $address->getSuffix(), - Address::KEY_EMAIL => $address->getEmail(), - Address::KEY_VAT_ID => $address->getVatId() - ]; - - foreach ($this->customerMetadata->getCustomAttributesMetadata() as $attributeMetadata) { - $attributeCode = $attributeMetadata->getAttributeCode(); - $method = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode); - $data[Address::CUSTOM_ATTRIBUTES_KEY][] = - [AttributeValue::ATTRIBUTE_CODE => $attributeCode, AttributeValue::VALUE => $address->$method()]; - } - - return $this->addressBuilder->populateWithArray($data)->create(); - } - - /** - * Converts an address data object to a quote address model. - * - * @param \Magento\Checkout\Service\V1\Data\Cart\Address $dataObject The address data object. - * @param \Magento\Quote\Model\Quote\Address $address The address. - * @return \Magento\Quote\Model\Quote\Address Quote address model. - */ - public function convertDataObjectToModel($dataObject, $address) - { - $address->setData($dataObject->__toArray()); - - //set custom attributes - $customAttributes = $dataObject->getCustomAttributes(); - /** @var \Magento\Framework\Api\AttributeValue $attributeData */ - foreach ($customAttributes as $attributeData) { - $address->setData($attributeData->getAttributeCode(), $attributeData->getValue()); - } - - //set fields with custom logic - $address->setStreet($dataObject->getStreet()); - $address->setRegionId($dataObject->getRegion()->getRegionId()); - $address->setRegion($dataObject->getRegion()->getRegion()); - - return $address; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php deleted file mode 100644 index 600ca9796f1f59d9f4285f8b6d4f04c453df1a2d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address\Shipping; - -use Magento\Checkout\Service\V1\Address\Converter as AddressConverter; -use Magento\Framework\Exception\NoSuchEntityException; - -/** Quote billing address read service object. */ -class ReadService implements ReadServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Address converter. - * - * @var AddressConverter - */ - protected $addressConverter; - - /** - * Constructs a quote billing address read service object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param AddressConverter $addressConverter Address converter. - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - AddressConverter $addressConverter - ) { - $this->quoteRepository = $quoteRepository; - $this->addressConverter = $addressConverter; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Address Shipping address object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getAddress($cartId) - { - /** - * Quote. - * - * @var \Magento\Quote\Model\Quote $quote - */ - $quote = $this->quoteRepository->getActive($cartId); - if ($quote->isVirtual()) { - throw new NoSuchEntityException( - 'Cart contains virtual product(s) only. Shipping address is not applicable' - ); - } - - /** - * Address. - * - * @var \Magento\Quote\Model\Quote\Address $address - */ - $address = $quote->getShippingAddress(); - return $this->addressConverter->convertModelToDataObject($address); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceInterface.php deleted file mode 100644 index 03cbbd02477c55f96d1652a231a75f88ba4af972..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address\Shipping; - -/** Quote billing address read service interface. */ -interface ReadServiceInterface -{ - /** - * Returns the shipping address for a specified quote. - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Address Shipping address object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getAddress($cartId); -} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php deleted file mode 100644 index 5382b78b4724f9aab7ff97effc148b2c2146d5bc..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address\Shipping; - -use Magento\Framework\Exception\InputException; -use Magento\Framework\Exception\NoSuchEntityException; -use Psr\Log\LoggerInterface as Logger; - -/** Quote shipping address write service object. */ -class WriteService implements WriteServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Quote address factory. - * - * @var \Magento\Quote\Model\Quote\AddressFactory - */ - protected $quoteAddressFactory; - - /** - * Address converter. - * - * @var \Magento\Checkout\Service\V1\Address\Converter - */ - protected $addressConverter; - - /** - * Address validator. - * - * @var \Magento\Checkout\Service\V1\Address\Validator - */ - protected $addressValidator; - - /** - * Logger. - * - * @var Logger - */ - protected $logger; - - /** - * Constructs a quote shipping address write service object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param \Magento\Checkout\Service\V1\Address\Converter $addressConverter Address converter. - * @param \Magento\Checkout\Service\V1\Address\Validator $addressValidator Address validator. - * @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory Quote address factory. - * @param Logger $logger Logger. - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - \Magento\Checkout\Service\V1\Address\Converter $addressConverter, - \Magento\Checkout\Service\V1\Address\Validator $addressValidator, - \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory, - Logger $logger - ) { - $this->quoteRepository = $quoteRepository; - $this->quoteAddressFactory = $quoteAddressFactory; - $this->addressConverter = $addressConverter; - $this->addressValidator = $addressValidator; - $this->logger = $logger; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @param \Magento\Checkout\Service\V1\Data\Cart\Address $addressData The shipping address data. - * @return int Address ID. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\InputException The specified cart ID or address data is not valid. - */ - public function setAddress($cartId, $addressData) - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - if ($quote->isVirtual()) { - throw new NoSuchEntityException( - 'Cart contains virtual product(s) only. Shipping address is not applicable' - ); - } - /** @var \Magento\Quote\Model\Quote\Address $address */ - $address = $this->quoteAddressFactory->create(); - $this->addressValidator->validate($addressData); - if ($addressData->getId()) { - $address->load($addressData->getId()); - } - $address = $this->addressConverter->convertDataObjectToModel($addressData, $address); - $address->setSameAsBilling(0); - $address->setCollectShippingRates(true); - - $quote->setShippingAddress($address); - $quote->setDataChanges(true); - try { - $this->quoteRepository->save($quote); - } catch (\Exception $e) { - $this->logger->critical($e); - throw new InputException('Unable to save address. Please, check input data.'); - } - return $quote->getShippingAddress()->getId(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceInterface.php deleted file mode 100644 index 3d0d26860e700a767185f10f7419247ab28dcee7..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Address\Shipping; - -/** Quote shipping address write service interface. */ -interface WriteServiceInterface -{ - /** - * Assigns a specified shipping address to a specified cart. - * - * @param int $cartId The cart ID. - * @param \Magento\Checkout\Service\V1\Data\Cart\Address $addressData The shipping address data. - * @return int Address ID. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\InputException The specified cart ID or address data is not valid. - */ - public function setAddress($cartId, $addressData); -} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php b/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php deleted file mode 100644 index e9f453988d0dbf5ec52c3e506803a8860e6c634c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php +++ /dev/null @@ -1,192 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Cart; - -use Magento\Checkout\Service\V1\Data; -use Magento\Framework\Api\Search\FilterGroup; -use Magento\Framework\Api\SearchCriteria; -use Magento\Framework\Exception\InputException; -use Magento\Quote\Model\Quote; -use Magento\Quote\Model\QuoteRepository; -use Magento\Quote\Model\Resource\Quote\Collection as QuoteCollection; - -/** - * Cart read service object. - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class ReadService implements ReadServiceInterface -{ - /** - * Quote repository. - * - * @var QuoteRepository - */ - private $quoteRepository; - - /** - * Quote collection. - * - * @var QuoteCollection - */ - private $quoteCollection; - - /** - * Search results builder. - * - * @var Data\CartSearchResultsBuilder - */ - private $searchResultsBuilder; - - /** - * Cart mapper. - * - * @var Data\CartMapper - */ - private $cartMapper; - - /** - * Array of valid search fields. - * - * @var array - */ - private $validSearchFields = [ - 'id', 'store_id', 'created_at', 'updated_at', 'converted_at', 'is_active', 'is_virtual', - 'items_count', 'items_qty', 'checkout_method', 'reserved_order_id', 'orig_order_id', 'base_grand_total', - 'grand_total', 'base_subtotal', 'subtotal', 'base_subtotal_with_discount', 'subtotal_with_discount', - 'customer_is_guest', 'customer_id', 'customer_group_id', 'customer_id', 'customer_tax_class_id', - 'customer_email', 'global_currency_code', 'base_currency_code', 'store_currency_code', 'quote_currency_code', - 'store_to_base_rate', 'store_to_quote_rate', 'base_to_global_rate', 'base_to_quote_rate', - ]; - - /** - * Cart data object - quote field map. - * - * @var array - */ - private $searchFieldMap = [ - 'id' => 'entity_id', - ]; - - /** - * Constructs a cart read service object. - * - * @param QuoteRepository $quoteRepository Quote repository. - * @param QuoteCollection $quoteCollection Quote collection. - * @param Data\CartSearchResultsBuilder $searchResultsBuilder Search results builder. - * @param Data\CartMapper $cartMapper Cart mapper. - */ - public function __construct( - QuoteRepository $quoteRepository, - QuoteCollection $quoteCollection, - Data\CartSearchResultsBuilder $searchResultsBuilder, - Data\CartMapper $cartMapper - ) { - $this->quoteRepository = $quoteRepository; - $this->quoteCollection = $quoteCollection; - $this->searchResultsBuilder = $searchResultsBuilder; - $this->cartMapper = $cartMapper; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart Cart object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getCart($cartId) - { - $quote = $this->quoteRepository->getActive($cartId); - return $this->cartMapper->map($quote); - } - - /** - * {@inheritDoc} - * - * @param int $customerId The customer ID. - * @return \Magento\Checkout\Service\V1\Data\Cart Cart object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified customer does not exist. - */ - public function getCartForCustomer($customerId) - { - $quote = $this->quoteRepository->getActiveForCustomer($customerId); - return $this->cartMapper->map($quote); - } - - /** - * {@inheritDoc} - * - * @param \Magento\Framework\Api\SearchCriteria $searchCriteria The search criteria. - * @return \Magento\Checkout\Service\V1\Data\CartSearchResults Cart search results object. - */ - public function getCartList(SearchCriteria $searchCriteria) - { - $this->searchResultsBuilder->setSearchCriteria($searchCriteria); - - foreach ($searchCriteria->getFilterGroups() as $group) { - $this->addFilterGroupToCollection($group, $this->quoteCollection); - } - - $this->searchResultsBuilder->setTotalCount($this->quoteCollection->getSize()); - $sortOrders = $searchCriteria->getSortOrders(); - if ($sortOrders) { - foreach ($sortOrders as $sortOrder) { - $this->quoteCollection->addOrder( - $this->getQuoteSearchField($sortOrder->getField()), - $sortOrder->getDirection() == SearchCriteria::SORT_ASC ? 'ASC' : 'DESC' - ); - } - } - $this->quoteCollection->setCurPage($searchCriteria->getCurrentPage()); - $this->quoteCollection->setPageSize($searchCriteria->getPageSize()); - - $cartList = []; - /** @var Quote $quote */ - foreach ($this->quoteCollection as $quote) { - $cartList[] = $this->cartMapper->map($quote); - } - $this->searchResultsBuilder->setItems($cartList); - - return $this->searchResultsBuilder->create(); - } - - /** - * Adds a specified filter group to the specified quote collection. - * - * @param FilterGroup $filterGroup The filter group. - * @param QuoteCollection $collection The quote collection. - * @return void - * @throws InputException The specified filter group or quote collection does not exist. - */ - protected function addFilterGroupToCollection(FilterGroup $filterGroup, QuoteCollection $collection) - { - $fields = []; - $conditions = []; - foreach ($filterGroup->getFilters() as $filter) { - $fields[] = $this->getQuoteSearchField($filter->getField()); - $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq'; - $conditions[] = [$condition => $filter->getValue()]; - } - if ($fields) { - $collection->addFieldToFilter($fields, $conditions); - } - } - - /** - * Returns a mapped search field. - * - * @param string $field The field. - * @return string Mapped search field. - * @throws InputException The specified field cannot be used for search. - */ - protected function getQuoteSearchField($field) - { - if (!in_array($field, $this->validSearchFields)) { - throw new InputException("Field '{$field}' cannot be used for search."); - } - return isset($this->searchFieldMap[$field]) ? $this->searchFieldMap[$field] : $field; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php deleted file mode 100644 index cb6dfda5f03bfc062af26ec0b7f2803398cb4b91..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Cart; - -use Magento\Framework\Api\SearchCriteria; - -/** - * Cart read service interface. - */ -interface ReadServiceInterface -{ - /** - * Enables an administrative user to return information for a specified cart. - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart Cart object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getCart($cartId); - - /** - * Returns information for the cart for a specified customer. - * - * @param int $customerId The customer ID. - * @return \Magento\Checkout\Service\V1\Data\Cart Cart object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified customer does not exist. - */ - public function getCartForCustomer($customerId); - - /** - * Enables administrative users to list carts that match specified search criteria. - * - * @param \Magento\Framework\Api\SearchCriteria $searchCriteria The search criteria. - * @return \Magento\Checkout\Service\V1\Data\CartSearchResults Cart search results object. - */ - public function getCartList(SearchCriteria $searchCriteria); -} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/TotalsService.php b/app/code/Magento/Checkout/Service/V1/Cart/TotalsService.php deleted file mode 100644 index 3baa1a8ebc6e802326116787c69e87ef846fbabb..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Cart/TotalsService.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Cart; - -use Magento\Checkout\Service\V1\Data\Cart\Totals; -use Magento\Checkout\Service\V1\Data\Cart; -use Magento\Quote\Model\Quote; -use Magento\Quote\Model\QuoteRepository; - -/** - * Cart totals service object. - */ -class TotalsService implements TotalsServiceInterface -{ - /** - * Cart totals builder. - * - * @var Cart\TotalsBuilder - */ - private $totalsBuilder; - - /** - * Cart totals mapper. - * - * @var Cart\TotalsMapper - */ - private $totalsMapper; - - /** - * Quote repository. - * - * @var QuoteRepository - */ - private $quoteRepository; - - /** - * Item totals mapper. - * - * @var Totals\ItemMapper; - */ - private $itemTotalsMapper; - - /** - * Constructs a cart totals service object. - * - * @param Cart\TotalsBuilder $totalsBuilder Cart totals builder. - * @param Cart\TotalsMapper $totalsMapper Cart totals mapper. - * @param QuoteRepository $quoteRepository Quote repository. - * @param Totals\ItemMapper $itemTotalsMapper Item totals mapper. - */ - public function __construct( - Cart\TotalsBuilder $totalsBuilder, - Cart\TotalsMapper $totalsMapper, - QuoteRepository $quoteRepository, - Totals\ItemMapper $itemTotalsMapper - ) { - $this->totalsBuilder = $totalsBuilder; - $this->totalsMapper = $totalsMapper; - $this->quoteRepository = $quoteRepository; - $this->itemTotalsMapper = $itemTotalsMapper; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return Totals Quote totals data. - */ - public function getTotals($cartId) - { - /** - * Quote. - * - * @var \Magento\Quote\Model\Quote $quote - */ - $quote = $this->quoteRepository->getActive($cartId); - - $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote)); - $items = []; - foreach ($quote->getAllItems() as $item) { - $items[] = $this->itemTotalsMapper->extractDto($item); - } - $this->totalsBuilder->setItems($items); - - return $this->totalsBuilder->create(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php deleted file mode 100644 index 61066236f16fb81a1b7c0254bf3df495e05df53a..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php +++ /dev/null @@ -1,190 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Cart; - -use Magento\Authorization\Model\UserContextInterface; -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Exception\StateException; - -/** - * Cart write service object. - */ -class WriteService implements WriteServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Store manager interface. - * - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $storeManager; - - /** - * Customer registry. - * - * @var \Magento\Customer\Api\CustomerRepositoryInterface - */ - protected $customerRepository; - - /** - * User context interface. - * - * @var UserContextInterface - */ - protected $userContext; - - /** - * Quote factory. - * - * @var \Magento\Quote\Model\QuoteManagement - */ - protected $quoteServiceFactory; - - /** - * @var \Magento\Customer\Model\CustomerFactory - */ - protected $customerModelFactory; - - /** - * Constructs a cart write service object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param \Magento\Store\Model\StoreManagerInterface $storeManager Store manager. - * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository Customer registry. - * @param UserContextInterface $userContext User context. - * @param \Magento\Quote\Model\QuoteManagement $quoteServiceFactory Quote service factory. - * @param \Magento\Customer\Model\CustomerFactory $customerModelFactory - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, - UserContextInterface $userContext, - \Magento\Quote\Model\QuoteManagement $quoteServiceFactory, - \Magento\Customer\Model\CustomerFactory $customerModelFactory - ) { - $this->quoteRepository = $quoteRepository; - $this->storeManager = $storeManager; - $this->customerRepository = $customerRepository; - $this->userContext = $userContext; - $this->quoteServiceFactory = $quoteServiceFactory; - $this->customerModelFactory = $customerModelFactory; - } - - /** - * {@inheritDoc} - * - * @throws \Magento\Framework\Exception\CouldNotSaveException The empty cart and quote could not be created. - * @return int Cart ID. - */ - public function create() - { - $quote = $this->userContext->getUserType() == UserContextInterface::USER_TYPE_CUSTOMER - ? $this->createCustomerCart() - : $this->createAnonymousCart(); - - try { - $this->quoteRepository->save($quote); - } catch (\Exception $e) { - throw new CouldNotSaveException('Cannot create quote'); - } - return $quote->getId(); - } - - /** - * Creates an anonymous cart. - * - * @return \Magento\Quote\Model\Quote Cart object. - */ - protected function createAnonymousCart() - { - $storeId = $this->storeManager->getStore()->getId(); - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->create(); - $quote->setStoreId($storeId); - return $quote; - } - - /** - * Creates a cart for the currently logged-in customer. - * - * @return \Magento\Quote\Model\Quote Cart object. - * @throws CouldNotSaveException The cart could not be created. - */ - protected function createCustomerCart() - { - $storeId = $this->storeManager->getStore()->getId(); - $customer = $this->customerRepository->getById($this->userContext->getUserId()); - - try { - $this->quoteRepository->getActiveForCustomer($this->userContext->getUserId()); - throw new CouldNotSaveException('Cannot create quote'); - } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - } - - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->create(); - $quote->setStoreId($storeId); - $quote->setCustomer($customer); - $quote->setCustomerIsGuest(0); - return $quote; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @param int $customerId The customer ID. - * @return boolean - * @throws \Magento\Framework\Exception\StateException The customer cannot be assigned to the specified cart: The cart belongs to a different store or is not anonymous, or the customer already has an active cart. - */ - public function assignCustomer($cartId, $customerId) - { - $storeId = $this->storeManager->getStore()->getId(); - $quote = $this->quoteRepository->getActive($cartId); - $customer = $this->customerRepository->getById($customerId); - $customerModel = $this->customerModelFactory->create(); - - if (!in_array($storeId, $customerModel->load($customerId)->getSharedStoreIds())) { - throw new StateException('Cannot assign customer to the given cart. The cart belongs to different store.'); - } - if ($quote->getCustomerId()) { - throw new StateException('Cannot assign customer to the given cart. The cart is not anonymous.'); - } - try { - $this->quoteRepository->getForCustomer($customerId); - throw new StateException('Cannot assign customer to the given cart. Customer already has active cart.'); - } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - } - - $quote->setCustomer($customer); - $quote->setCustomerIsGuest(0); - $this->quoteRepository->save($quote); - return true; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return int Order ID. - */ - public function order($cartId) - { - $quote = $this->quoteRepository->getActive($cartId); - $order = $this->quoteServiceFactory->submit($quote); - return $order->getId(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php b/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php deleted file mode 100644 index ecb614bbf56b1116e68812d13efbd8d158281903..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Coupon; - -use Magento\Checkout\Service\V1\Data\Cart\Coupon as Coupon; -use Magento\Checkout\Service\V1\Data\Cart\CouponBuilder as CouponBuilder; - -/** - * Coupon read service object. - */ -class ReadService implements ReadServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Coupon builder. - * - * @var CouponBuilder - */ - protected $couponBuilder; - - /** - * Constructs a coupon read service object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param CouponBuilder $couponBuilder Coupon builder. - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - CouponBuilder $couponBuilder - ) { - $this->quoteRepository = $quoteRepository; - $this->couponBuilder = $couponBuilder; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Coupon Coupon object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function get($cartId) - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - $data = [Coupon::COUPON_CODE => $quote->getCouponCode()]; - $output = $this->couponBuilder->populateWithArray($data)->create(); - return $output; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Coupon/ReadServiceInterface.php deleted file mode 100644 index d53b27d44d28e8955d75e2af48022c7a67a60285..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Coupon/ReadServiceInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Coupon; - -/** - * Coupon read service interface. - */ -interface ReadServiceInterface -{ - /** - * Returns information for a coupon in a specified cart. - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Coupon Coupon object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function get($cartId); -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart.php b/app/code/Magento/Checkout/Service/V1/Data/Cart.php deleted file mode 100644 index d5cc15d0f206e121bdbe2ca789264c21f4f6107b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart.php +++ /dev/null @@ -1,299 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Data; - -/** - * Cart data object. - * - * @codeCoverageIgnore - */ -class Cart extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /** - * Cart ID. - */ - const ID = 'id'; - - /** - * ID of the store where the cart was created. - */ - const STORE_ID = 'store_id'; - - /** - * Cart creation date and time. - */ - const CREATED_AT = 'created_at'; - - /** - * Cart last update date and time. - */ - const UPDATED_AT = 'updated_at'; - - /** - * Cart conversion date and time. - */ - const CONVERTED_AT = 'converted_at'; - - /** - * Flag that shows whether the cart is still active. - */ - const IS_ACTIVE = 'is_active'; - - /** - * Flag that shows whether the cart is virtual. A virtual cart contains virtual items. - */ - const IS_VIRTUAL = 'is_virtual'; - - /** - * List of cart items. - */ - const ITEMS = 'items'; - - /** - * Number of different items or products in the cart. - */ - const ITEMS_COUNT = 'items_count'; - - /** - * Total quantity of all cart items. - */ - const ITEMS_QUANTITY = 'items_qty'; - - /** - * Information about the customer who is assigned to the cart. - */ - const CUSTOMER = 'customer'; - - /** - * Payment method that is used to process the cart. - */ - const CHECKOUT_METHOD = 'checkout_method'; - - /** - * Cart shipping address. - */ - const SHIPPING_ADDRESS = 'shipping_address'; - - /** - * Cart billing address. - */ - const BILLING_ADDRESS = 'shipping_address'; - - /** - * Information about cart totals. - */ - const TOTALS = 'totals'; - - /** - * The order ID that is reserved for the cart. - */ - const RESERVED_ORDER_ID = 'reserved_order_id'; - - /** - * Original order ID. - */ - const ORIG_ORDER_ID = 'orig_order_id'; - - /** - * Information about the quote currency, such as code, exchange rates, and so on. - */ - const CURRENCY = 'currency'; - - /** - * Returns the cart/quote ID. - * - * @return int Cart/quote ID. - */ - public function getId() - { - return $this->_get(self::ID); - } - - /** - * Returns the store ID for the store where the cart was created. - * - * @return int|null Store ID. Otherwise, null. - */ - public function getStoreId() - { - return $this->_get(self::STORE_ID); - } - - /** - * Returns the cart creation date and time. - * - * @return string|null Cart creation date and time. Otherwise, null. - */ - public function getCreatedAt() - { - return $this->_get(self::CREATED_AT); - } - - /** - * Returns the cart last update date and time. - * - * @return string|null Cart last update date and time. Otherwise, null. - */ - public function getUpdatedAt() - { - return $this->_get(self::UPDATED_AT); - } - - /** - * Returns the cart conversion date and time. - * - * @return string|null Cart conversion date and time. Otherwise, null. - */ - public function getConvertedAt() - { - return $this->_get(self::CONVERTED_AT); - } - - /** - * Determines whether the cart is still active. - * - * @return bool|null Active status flag value. Otherwise, null. - */ - public function getIsActive() - { - $value = $this->_get(self::IS_ACTIVE); - if (!is_null($value)) { - $value = (bool)$value; - } - - return $value; - } - - /** - * Determines whether the cart is a virtual cart. - * - * A virtual cart contains virtual items. - * - * @return bool|null Virtual flag value. Otherwise, null. - */ - public function getIsVirtual() - { - $value = $this->_get(self::IS_VIRTUAL); - if (!is_null($value)) { - $value = (bool)$value; - } - - return $value; - } - - /** - * Lists items in the cart. - * - * @return \Magento\Checkout\Service\V1\Data\Cart\Item[]|null Array of items. Otherwise, null. - */ - public function getItems() - { - return $this->_get(self::ITEMS); - } - - /** - * Returns the number of different items or products in the cart. - * - * @return int|null Number of different items or products in the cart. Otherwise, null. - */ - public function getItemsCount() - { - return $this->_get(self::ITEMS_COUNT); - } - - /** - * Returns the total quantity of all cart items. - * - * @return float|null Total quantity of all cart items. Otherwise, null. - */ - public function getItemsQty() - { - return $this->_get(self::ITEMS_QUANTITY); - } - - /** - * Returns information about the customer who is assigned to the cart. - * - * @return \Magento\Checkout\Service\V1\Data\Cart\Customer Information about the customer who is assigned to the cart. - */ - public function getCustomer() - { - return $this->_get(self::CUSTOMER); - } - - /** - * Returns the payment method that is used to process the cart. - * - * @return string|null Payment method. Otherwise, null. - */ - public function getCheckoutMethod() - { - return $this->_get(self::CHECKOUT_METHOD); - } - - /** - * Returns the cart shipping address. - * - * @return \Magento\Checkout\Service\V1\Data\Cart\Address|null Cart shipping address. Otherwise, null. - */ - public function getShippingAddress() - { - return $this->_get(self::SHIPPING_ADDRESS); - } - - /** - * Returns the cart billing address. - * - * @return \Magento\Checkout\Service\V1\Data\Cart\Address|null Cart billing address. Otherwise, null. - */ - public function getBillingAddress() - { - return $this->_get(self::BILLING_ADDRESS); - } - - /** - * Returns information about cart totals. - * - * @return \Magento\Checkout\Service\V1\Data\Cart\Totals|null Information about cart totals. Otherwise, null. - */ - public function getTotals() - { - return $this->_get(self::TOTALS); - } - - /** - * Returns the reserved order ID for the cart. - * - * @return string|null Reserved order ID. Otherwise, null. - */ - public function getReservedOrderId() - { - return $this->_get(self::RESERVED_ORDER_ID); - } - - /** - * Returns the original order ID for the cart. - * - * @return string|null Original order ID. Otherwise, null. - */ - public function getOrigOrderId() - { - return $this->_get(self::ORIG_ORDER_ID); - } - - /** - * Returns information about quote currency, such as code, exchange rate, and so on. - * - * @return \Magento\Checkout\Service\V1\Data\Cart\Currency|null Quote currency information. Otherwise, null. - */ - public function getCurrency() - { - return $this->_get(self::CURRENCY); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.php deleted file mode 100644 index e461b12aa9ad36fd96b27fb159944b7aeed4f128..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart\Address; - -/** - * @codeCoverageIgnore - */ -class Region extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /**#@+ - * Array keys - */ - /** - * Region code. - */ - const REGION_CODE = 'region_code'; - - /** - * Region name. - */ - const REGION = 'region'; - - /** - * Region ID. - */ - const REGION_ID = 'region_id'; - - /**#@-*/ - - /** - * Returns the region code. - * - * @return string Region code. - */ - public function getRegionCode() - { - return $this->_get(self::REGION_CODE); - } - - /** - * Returns the region name. - * - * @return string Region. - */ - public function getRegion() - { - return $this->_get(self::REGION); - } - - /** - * Returns the region ID. - * - * @return int Region ID. - */ - public function getRegionId() - { - return $this->_get(self::REGION_ID); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php deleted file mode 100644 index 02a37e8f28ed49c2283793b4f414697d8b874969..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php +++ /dev/null @@ -1,261 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -use Magento\Checkout\Service\V1\Data\Cart\Address\Region; -use Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder; -use Magento\Customer\Api\CustomerMetadataInterface; -use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeDataBuilder; - -/** - * Quote address data object builder - * - * @codeCoverageIgnore - */ -class AddressBuilder extends ExtensibleObjectBuilder -{ - /** - * Region builder - * - * @var \Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder - */ - protected $_regionBuilder; - - /** - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeDataBuilder $valueBuilder - * @param CustomerMetadataInterface $metadataService - * @param RegionBuilder $regionBuilder - */ - public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeDataBuilder $valueBuilder, - CustomerMetadataInterface $metadataService, - RegionBuilder $regionBuilder - ) { - parent::__construct($objectFactory, $valueBuilder, $metadataService); - $this->_regionBuilder = $regionBuilder; - $this->data[Address::KEY_REGION] = $regionBuilder->create(); - } - - /** - * Convenience method to return region builder - * - * @return RegionBuilder - */ - public function getRegionBuilder() - { - return $this->_regionBuilder; - } - - /** - * Set id - * - * @param int $id - * @return $this - */ - public function setId($id) - { - return $this->_set(Address::KEY_ID, $id); - } - - /** - * {@inheritdoc} - */ - protected function _setDataValues(array $data) - { - if (array_key_exists(Address::KEY_REGION, $data)) { - if (!is_array($data[Address::KEY_REGION])) { - // Region data has been submitted as individual keys of Address object. Let's extract it. - $regionData = []; - foreach ([Region::REGION, Region::REGION_CODE, Region::REGION_ID] as $attrCode) { - if (isset($data[$attrCode])) { - $regionData[$attrCode] = $data[$attrCode]; - } - } - } else { - $regionData = $data[Address::KEY_REGION]; - } - $data[Address::KEY_REGION] = $this->_regionBuilder->populateWithArray($regionData)->create(); - } - return parent::_setDataValues($data); - } - - /** - * Set region - * - * @param \Magento\Checkout\Service\V1\Data\Cart\Address\Region $region - * @return $this - */ - public function setRegion(\Magento\Checkout\Service\V1\Data\Cart\Address\Region $region) - { - return $this->_set(Address::KEY_REGION, $region); - } - - /** - * Set country id - * - * @param int $countryId - * @return $this - */ - public function setCountryId($countryId) - { - return $this->_set(Address::KEY_COUNTRY_ID, $countryId); - } - - /** - * Set street - * - * @param string[] $street - * @return $this - */ - public function setStreet($street) - { - return $this->_set(Address::KEY_STREET, $street); - } - - /** - * Set company - * - * @param string $company - * @return $this - */ - public function setCompany($company) - { - return $this->_set(Address::KEY_COMPANY, $company); - } - - /** - * Set telephone number - * - * @param string $telephone - * @return $this - */ - public function setTelephone($telephone) - { - return $this->_set(Address::KEY_TELEPHONE, $telephone); - } - - /** - * Set fax number - * - * @param string $fax - * @return $this - */ - public function setFax($fax) - { - return $this->_set(Address::KEY_FAX, $fax); - } - - /** - * Set postcode - * - * @param string $postcode - * @return $this - */ - public function setPostcode($postcode) - { - return $this->_set(Address::KEY_POSTCODE, $postcode); - } - - /** - * Set city name - * - * @param string $city - * @return $this - */ - public function setCity($city) - { - return $this->_set(Address::KEY_CITY, $city); - } - - /** - * Set first name - * - * @param string $firstname - * @return $this - */ - public function setFirstname($firstname) - { - return $this->_set(Address::KEY_FIRSTNAME, $firstname); - } - - /** - * Set last name - * - * @param string $lastname - * @return $this - */ - public function setLastname($lastname) - { - return $this->_set(Address::KEY_LASTNAME, $lastname); - } - - /** - * Set middle name - * - * @param string $middlename - * @return $this - */ - public function setMiddlename($middlename) - { - return $this->_set(Address::KEY_MIDDLENAME, $middlename); - } - - /** - * Set prefix - * - * @param string $prefix - * @return $this - */ - public function setPrefix($prefix) - { - return $this->_set(Address::KEY_PREFIX, $prefix); - } - - /** - * Set suffix - * - * @param string $suffix - * @return $this - */ - public function setSuffix($suffix) - { - return $this->_set(Address::KEY_SUFFIX, $suffix); - } - - /** - * Set Vat id - * - * @param string $vatId - * @return $this - */ - public function setVatId($vatId) - { - return $this->_set(Address::KEY_VAT_ID, $vatId); - } - - /** - * Set customer id - * - * @param string $customerId - * @return $this - */ - public function setCustomerId($customerId) - { - return $this->_set(Address::KEY_CUSTOMER_ID, $customerId); - } - - /** - * @param $value string - * @return $this - */ - public function setEmail($value) - { - return $this->_set(Address::KEY_EMAIL, $value); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Coupon.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Coupon.php deleted file mode 100644 index 539c388bcaf50388d848abf355b967890023e9c3..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Coupon.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * Coupon data for quote. - * - * @codeCoverageIgnore - */ -class Coupon extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /** - * Coupon code. - */ - const COUPON_CODE = 'coupon_code'; - - /** - * Returns the coupon code. - * - * @return string Coupon code. - */ - public function getCouponCode() - { - return $this->_get(self::COUPON_CODE); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/CouponBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/CouponBuilder.php deleted file mode 100644 index 455d6f1f601d7757fa89c35a04ce10bb0651e09c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/CouponBuilder.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * @codeCoverageIgnore - */ -class CouponBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param string $value - * @return $this - */ - public function setCouponCode($value) - { - $this->_set(Coupon::COUPON_CODE, $value); - return $this; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Currency.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Currency.php deleted file mode 100644 index 4216bcfb595f184a71e0fdd30157da1fe2621b6d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Currency.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * Currency data for quote - * - * @codeCoverageIgnore - */ -class Currency extends \Magento\Framework\Api\AbstractExtensibleObject -{ - const GLOBAL_CURRENCY_CODE = 'global_currency_code'; - - const BASE_CURRENCY_CODE = 'base_currency_code'; - - const STORE_CURRENCY_CODE = 'store_currency_code'; - - const QUOTE_CURRENCY_CODE = 'quote_currency_code'; - - const STORE_TO_BASE_RATE = 'store_to_base_rate'; - - const STORE_TO_QUOTE_RATE = 'store_to_quote_rate'; - - const BASE_TO_GLOBAL_RATE = 'base_to_global_rate'; - - const BASE_TO_QUOTE_RATE = 'base_to_quote_rate'; - - /** - * Get global currency code - * - * @return string|null - */ - public function getGlobalCurrencyCode() - { - return $this->_get(self::GLOBAL_CURRENCY_CODE); - } - - /** - * Get base currency code - * - * @return string|null - */ - public function getBaseCurrencyCode() - { - return $this->_get(self::BASE_CURRENCY_CODE); - } - - /** - * Get store currency code - * - * @return string|null - */ - public function getStoreCurrencyCode() - { - return $this->_get(self::STORE_CURRENCY_CODE); - } - - /** - * Get quote currency code - * - * @return string|null - */ - public function getQuoteCurrencyCode() - { - return $this->_get(self::QUOTE_CURRENCY_CODE); - } - - /** - * Get store currency to base currency rate - * - * @return float|null - */ - public function getStoreToBaseRate() - { - return $this->_get(self::STORE_TO_BASE_RATE); - } - - /** - * Get store currency to quote currency rate - * - * @return float|null - */ - public function getStoreToQuoteRate() - { - return $this->_get(self::STORE_TO_QUOTE_RATE); - } - - /** - * Get base currency to global currency rate - * - * @return float|null - */ - public function getBaseToGlobalRate() - { - return $this->_get(self::BASE_TO_GLOBAL_RATE); - } - - /** - * Get base currency to quote currency rate - * - * @return float|null - */ - public function getBaseToQuoteRate() - { - return $this->_get(self::BASE_TO_QUOTE_RATE); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Customer.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Customer.php deleted file mode 100644 index 0cb9d61bf18b97b914b01f6ec247752a87143ab7..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Customer.php +++ /dev/null @@ -1,201 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * Customer data for quote. - * - * @codeCoverageIgnore - */ -class Customer extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /** - * Customer ID. - */ - const ID = 'id'; - - /** - * Customer tax class ID. - */ - const TAX_CLASS_ID = 'tax_class_id'; - - const GROUP_ID = 'group_id'; - - const EMAIL = 'email'; - - const PREFIX = 'prefix'; - - const FIRST_NAME = 'first_name'; - - const MIDDLE_NAME = 'middle_name'; - - const LAST_NAME = 'last_name'; - - const SUFFIX = 'suffix'; - - const DOB = 'dob'; - - const NOTE = 'note'; - - const NOTE_NOTIFY = 'note_notify'; - - const IS_GUEST = 'is_guest'; - - const TAXVAT = 'taxvat'; - - const GENDER = 'gender'; - - /** - * Get customer id - * - * @return int|null - */ - public function getId() - { - return $this->_get(self::ID); - } - - /** - * Get customer tax class id - * - * @return int|null - */ - public function getTaxClassId() - { - return $this->_get(self::TAX_CLASS_ID); - } - - /** - * Get customer group id - * - * @return int|null - */ - public function getGroupId() - { - return $this->_get(self::GROUP_ID); - } - - /** - * Get customer email - * - * @return string|null - */ - public function getEmail() - { - return $this->_get(self::EMAIL); - } - - /** - * Get customer name prefix - * - * @return string|null - */ - public function getPrefix() - { - return $this->_get(self::PREFIX); - } - - /** - * Get customer first name - * - * @return string|null - */ - public function getFirstName() - { - return $this->_get(self::FIRST_NAME); - } - - /** - * Get customer middle name - * - * @return string|null - */ - public function getMiddleName() - { - return $this->_get(self::MIDDLE_NAME); - } - - /** - * Get customer last name - * - * @return string|null - */ - public function getLastName() - { - return $this->_get(self::LAST_NAME); - } - - /** - * Get customer name suffix - * - * @return string|null - */ - public function getSuffix() - { - return $this->_get(self::SUFFIX); - } - - /** - * Get customer date of birth - * - * @return string|null - */ - public function getDob() - { - return $this->_get(self::DOB); - } - - /** - * Get note - * - * @return string|null - */ - public function getNote() - { - return $this->_get(self::NOTE); - } - - /** - * Get notification status - * - * @return string|null - */ - public function getNoteNotify() - { - return $this->_get(self::NOTE_NOTIFY); - } - - /** - * Is customer a guest? - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getIsGuest() - { - return (bool)$this->_get(self::IS_GUEST); - } - - /** - * Get taxvat value - * - * @return string|null - */ - public function getTaxVat() - { - return $this->_get(self::TAXVAT); - } - - /** - * Get gender - * - * @return string|null - */ - public function getGender() - { - return $this->_get(self::GENDER); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerBuilder.php deleted file mode 100644 index 4d4d2fbc2636451ad165f2c2ca435ae13a935e33..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerBuilder.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * Customer data builder for quote - * - * @codeCoverageIgnore - */ -class CustomerBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * Set customer id - * - * @param int|null $value - * @return $this - */ - public function setId($value) - { - return $this->_set(Customer::ID, $value); - } - - /** - * Set customer tax class id - * - * @param int|null $value - * @return $this - */ - public function setTaxClassId($value) - { - return $this->_set(Customer::TAX_CLASS_ID, $value); - } - - /** - * Set customer group id - * - * @param int|null $value - * @return $this - */ - public function setGroupId($value) - { - return $this->_set(Customer::GROUP_ID, $value); - } - - /** - * Set customer email - * - * @param string|null $value - * @return $this - */ - public function setEmail($value) - { - return $this->_set(Customer::EMAIL, $value); - } - - /** - * Set customer name prefix - * - * @param string|null $value - * @return $this - */ - public function setPrefix($value) - { - return $this->_set(Customer::PREFIX, $value); - } - - /** - * Set customer first name - * - * @param string|null $value - * @return $this - */ - public function setFirstName($value) - { - return $this->_set(Customer::FIRST_NAME, $value); - } - - /** - * Set customer middle name - * - * @param string|null $value - * @return $this - */ - public function setMiddleName($value) - { - return $this->_set(Customer::MIDDLE_NAME, $value); - } - - /** - * Set customer last name - * - * @param string|null $value - * @return $this - */ - public function setLastName($value) - { - return $this->_set(Customer::LAST_NAME, $value); - } - - /** - * Set customer name suffix - * - * @param string|null $value - * @return $this - */ - public function setSuffix($value) - { - return $this->_set(Customer::SUFFIX, $value); - } - - /** - * Set customer date of birth - * - * @param string|null $value - * @return $this - */ - public function setDob($value) - { - return $this->_set(Customer::DOB, $value); - } - - /** - * Set note - * - * @param string|null $value - * @return $this - */ - public function setNote($value) - { - return $this->_set(Customer::NOTE, $value); - } - - /** - * Set notification status - * - * @param string|null $value - * @return $this - */ - public function setNoteNotify($value) - { - return $this->_set(Customer::NOTE_NOTIFY, $value); - } - - /** - * Is customer a guest? - * - * @param bool $value - * @return $this - */ - public function setIsGuest($value) - { - return (bool)$this->_set(Customer::IS_GUEST, $value); - } - - /** - * Get taxvat value - * - * @param string $value - * @return $this - */ - public function setTaxVat($value) - { - return $this->_set(Customer::TAXVAT, $value); - } - - /** - * Get gender - * - * @param string $value - * @return $this - */ - public function setGender($value) - { - return $this->_set(Customer::GENDER, $value); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerMapper.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerMapper.php deleted file mode 100644 index 9a40d51b2d52cd9be23164a6780cb1f10abbbae2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerMapper.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -use Magento\Quote\Model\Quote; - -/** - * Cart mapper - */ -class CustomerMapper -{ - /** - * Fetch quote customer data - * - * @param Quote $quote - * @return array - */ - public function map(Quote $quote) - { - return [ - Customer::ID => $quote->getCustomerId(), - Customer::EMAIL => $quote->getCustomerEmail(), - Customer::GROUP_ID => $quote->getCustomerGroupId(), - Customer::TAX_CLASS_ID => $quote->getCustomerTaxClassId(), - Customer::PREFIX => $quote->getCustomerPrefix(), - Customer::FIRST_NAME => $quote->getCustomerFirstname(), - Customer::MIDDLE_NAME => $quote->getCustomerMiddlename(), - Customer::LAST_NAME => $quote->getCustomerLastname(), - Customer::SUFFIX => $quote->getCustomerSuffix(), - Customer::DOB => $quote->getCustomerDob(), - Customer::NOTE => $quote->getCustomerNote(), - Customer::NOTE_NOTIFY => $quote->getCustomerNoteNotify(), - Customer::IS_GUEST => $quote->getCustomerIsGuest(), - Customer::GENDER => $quote->getCustomerGender(), - Customer::TAXVAT => $quote->getCustomerTaxvat() - ]; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Item.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Item.php deleted file mode 100644 index 4307cfb5fb6d73145b2e1d4c27e63f0987f41741..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Item.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * Shopping cart item data object. - * - * @codeCoverageIgnore - */ -class Item extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /** - * Item ID. - */ - const ITEM_ID = 'item_id'; - - /** - * Product SKU. - */ - const SKU = 'sku'; - - /** - * Product quantity. - */ - const QTY = 'qty'; - - /** - * Product name. - */ - const NAME = 'name'; - - /** - * Product price. - */ - const PRICE = 'price'; - - /** - * Product type. - */ - const PRODUCT_TYPE = 'product_type'; - - /** - * Returns the item ID. - * - * @return int|null Item ID. Otherwise, null. - */ - public function getItemId() - { - return $this->_get(self::ITEM_ID); - } - - /** - * Returns the product SKU. - * - * @return string|null Product SKU. Otherwise, null. - */ - public function getSku() - { - return $this->_get(self::SKU); - } - - /** - * Returns the product quantity. - * - * @return int Product quantity. - */ - public function getQty() - { - return $this->_get(self::QTY); - } - - /** - * Returns the product name. - * - * @return string|null Product name. Otherwise, null. - */ - public function getName() - { - return $this->_get(self::NAME); - } - - /** - * Returns the product price. - * - * @return float|null Product price. Otherwise, null. - */ - public function getPrice() - { - return $this->_get(self::PRICE); - } - - /** - * Returns the product type. - * - * @return string|null Product type. Otherwise, null. - */ - public function getProductType() - { - return $this->_get(self::PRODUCT_TYPE); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod.php deleted file mode 100644 index cc5fa54eafb3d73127ff96ae15c12f480d95b8c6..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * @codeCoverageIgnore - */ -class PaymentMethod extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /** - * Payment method - */ - const METHOD = 'method'; - - /** - * Purchase order number - */ - const PO_NUMBER = 'po_number'; - - /** - * Credit card owner - */ - const CC_OWNER = 'cc_owner'; - - /** - * Credit card number - */ - const CC_NUMBER = 'cc_number'; - - /** - * Credit card type - */ - const CC_TYPE = 'cc_type'; - - /** - * Credit card expiration year - */ - const CC_EXP_YEAR = 'cc_exp_year'; - - /** - * Credit card expiration month - */ - const CC_EXP_MONTH = 'cc_exp_month'; - - /** - * Additional payment details - */ - const PAYMENT_DETAILS = 'payment_details'; - - /** - * Get purchase order number - * - * @return string|null - */ - public function getPoNumber() - { - return $this->_get(self::PO_NUMBER); - } - - /** - * Get payment method code - * - * @return string - */ - public function getMethod() - { - return $this->_get(self::METHOD); - } - - /** - * Get credit card owner - * - * @return string|null - */ - public function getCcOwner() - { - return $this->_get(self::CC_OWNER); - } - - /** - * Get credit card number - * - * @return string|null - */ - public function getCcNumber() - { - return $this->_get(self::CC_NUMBER); - } - - /** - * Get credit card type - * - * @return string|null - */ - public function getCcType() - { - return $this->_get(self::CC_TYPE); - } - - /** - * Get credit card expiration year - * - * @return string|null - */ - public function getCcExpYear() - { - return $this->_get(self::CC_EXP_YEAR); - } - - /** - * Get credit card expiration month - * - * @return string|null - */ - public function getCcExpMonth() - { - return $this->_get(self::CC_EXP_MONTH); - } - - /** - * Get payment additional details - * - * @return string|null - */ - public function getPaymentDetails() - { - return $this->_get(self::PAYMENT_DETAILS); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Builder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Builder.php deleted file mode 100644 index 4c412e7a10d4a60a78af0af7e8eb49ffdc972ddc..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Builder.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Data\Cart\PaymentMethod; - -use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod as QuotePaymentMethod; -use Magento\Framework\Exception\LocalizedException; -use Magento\Quote\Model\Quote; - -class Builder -{ - /** - * @param QuotePaymentMethod $object - * @param Quote $quote - * @return \Magento\Quote\Model\Quote\Payment - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function build(QuotePaymentMethod $object, Quote $quote) - { - $payment = $quote->getPayment(); - try { - $data = $object->__toArray(); - $additionalDataValue = $object->getPaymentDetails(); - unset($data[QuotePaymentMethod::PAYMENT_DETAILS]); - if (!empty($additionalDataValue)) { - $additionalData = @unserialize($additionalDataValue); - if (is_array($additionalData) && !empty($additionalData)) { - $data = array_merge($data, $additionalData); - } - } - $data['checks'] = [ - \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, - \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, - \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, - \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, - ]; - $payment->importData($data); - } catch (\Exception $e) { - throw new LocalizedException('The requested Payment Method is not available.'); - } - return $payment; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Converter.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Converter.php deleted file mode 100644 index 083f54d39909bfb12405312761972d643671260e..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Converter.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Data\Cart\PaymentMethod; - -use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod as QuotePaymentMethod; - -class Converter -{ - /** - * @var \Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder - */ - protected $builder; - - /** - * @param \Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder $builder - */ - public function __construct(\Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder $builder) - { - $this->builder = $builder; - } - - /** - * Convert quote payment object to payment data object - * - * @param \Magento\Quote\Model\Quote\Payment $object - * @return QuotePaymentMethod - */ - public function toDataObject(\Magento\Quote\Model\Quote\Payment $object) - { - $data = [ - QuotePaymentMethod::METHOD => $object->getMethod(), - QuotePaymentMethod::PO_NUMBER => $object->getPoNumber(), - QuotePaymentMethod::CC_OWNER => $object->getCcOwner(), - QuotePaymentMethod::CC_NUMBER => $object->getCcNumber(), - QuotePaymentMethod::CC_TYPE => $object->getCcType(), - QuotePaymentMethod::CC_EXP_YEAR => $object->getCcExpYear(), - QuotePaymentMethod::CC_EXP_MONTH => $object->getCcExpMonth(), - QuotePaymentMethod::PAYMENT_DETAILS => $object->getAdditionalData(), - ]; - - return $this->builder->populateWithArray($data)->create(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsMapper.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsMapper.php deleted file mode 100644 index d731d54609b06ea105605e557baebdee345c8ea9..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsMapper.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -use Magento\Quote\Model\Quote; - -/** - * Totals data mapper - */ -class TotalsMapper -{ - /** - * Fetch quote totals data - * - * @param Quote $quote - * @return array - */ - public function map(Quote $quote) - { - $totals = [ - Totals::BASE_GRAND_TOTAL => $quote->getBaseGrandTotal(), - Totals::GRAND_TOTAL => $quote->getGrandTotal(), - Totals::BASE_SUBTOTAL => $quote->getBaseSubtotal(), - Totals::SUBTOTAL => $quote->getSubtotal(), - Totals::BASE_SUBTOTAL_WITH_DISCOUNT => $quote->getBaseSubtotalWithDiscount(), - Totals::SUBTOTAL_WITH_DISCOUNT => $quote->getSubtotalWithDiscount(), - - Totals::BASE_CURRENCY_CODE => $quote->getBaseCurrencyCode(), - Totals::QUOTE_CURRENCY_CODE => $quote->getQuoteCurrencyCode(), - ]; - - $shippingAddress = $quote->getShippingAddress(); - - $totals[Totals::DISCOUNT_AMOUNT] = $shippingAddress->getDiscountAmount(); - $totals[Totals::BASE_DISCOUNT_AMOUNT] = $shippingAddress->getBaseDiscountAmount(); - $totals[Totals::SHIPPING_AMOUNT] = $shippingAddress->getShippingAmount(); - $totals[Totals::BASE_SHIPPING_AMOUNT] = $shippingAddress->getBaseShippingAmount(); - $totals[Totals::SHIPPING_DISCOUNT_AMOUNT] = $shippingAddress->getShippingDiscountAmount(); - $totals[Totals::BASE_SHIPPING_DISCOUNT_AMOUNT] = $shippingAddress->getBaseShippingDiscountAmount(); - $totals[Totals::TAX_AMOUNT] = $shippingAddress->getTaxAmount(); - $totals[Totals::BASE_TAX_AMOUNT] = $shippingAddress->getBaseTaxAmount(); - $totals[Totals::SHIPPING_TAX_AMOUNT] = $shippingAddress->getShippingTaxAmount(); - $totals[Totals::BASE_SHIPPING_TAX_AMOUNT] = $shippingAddress->getBaseShippingTaxAmount(); - $totals[Totals::SUBTOTAL_INCL_TAX] = $shippingAddress->getSubtotalInclTax(); - $totals[Totals::BASE_SUBTOTAL_INCL_TAX] = $shippingAddress->getBaseSubtotalTotalInclTax(); - $totals[Totals::SHIPPING_INCL_TAX] = $shippingAddress->getShippingInclTax(); - $totals[Totals::BASE_SHIPPING_INCL_TAX] = $shippingAddress->getBaseShippingInclTax(); - return $totals; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/CartBuilder.php deleted file mode 100644 index 625649909ac64f24a2dd79da4caeaff44747d0ae..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/CartBuilder.php +++ /dev/null @@ -1,210 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data; - -use Magento\Checkout\Service\V1\Data\Cart\Currency; - -/** - * Cart data object builder - * - * @codeCoverageIgnore - */ -class CartBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * Cart/quote id - * - * @param int $value - * @return $this - */ - public function setId($value) - { - return $this->_set(Cart::ID, $value); - } - - /** - * Store id - * - * @param int $value - * @return $this - */ - public function setStoreId($value) - { - return $this->_set(Cart::STORE_ID, $value); - } - - /** - * set creation date and time - * - * @param string $value - * @return $this - */ - public function setCreatedAt($value) - { - return $this->_set(Cart::CREATED_AT, $value); - } - - /** - * Set last update date and time - * - * @param string $value - * @return $this - */ - public function setUpdatedAt($value) - { - return $this->_set(Cart::UPDATED_AT, $value); - } - - /** - * Set convertion date and time - * - * @param string $value - * @return $this - */ - public function setConvertedAt($value) - { - return $this->_set(Cart::CONVERTED_AT, $value); - } - - /** - * Set active status - * - * @param bool|null $value - * @return $this - */ - public function setIsActive($value) - { - return $this->_set(Cart::IS_ACTIVE, $value); - } - - /** - * Set virtual flag(if cart contains virtual products) - * - * @param bool|null $value - * @return $this - */ - public function setIsVirtual($value) - { - return $this->_set(Cart::IS_VIRTUAL, $value); - } - - /** - * Set cart items - * - * @param \Magento\Checkout\Service\V1\Data\Cart\Item[] $value - * @return $this - */ - public function setItems($value) - { - return $this->_set(Cart::ITEMS, $value); - } - - /** - * Set items count(amount of different products) - * - * @param int $value - * @return $this - */ - public function setItemsCount($value) - { - return $this->_set(Cart::ITEMS_COUNT, $value); - } - - /** - * Set items quantity(total amount of all products) - * - * @param float $value - * @return $this - */ - public function setItemsQty($value) - { - return $this->_set(Cart::ITEMS_QUANTITY, $value); - } - - /** - * Set customer data object - * - * @param \Magento\Checkout\Service\V1\Data\Cart\Customer $value - * @return $this - */ - public function setCustomer($value) - { - return $this->_set(Cart::CUSTOMER, $value); - } - - /** - * Set checkout method - * - * @param string $value - * @return $this - */ - public function setCheckoutMethod($value) - { - return $this->_set(Cart::CHECKOUT_METHOD, $value); - } - - /** - * Set shipping address data object - * - * @param \Magento\Checkout\Service\V1\Data\Cart\Address $value - * @return $this - */ - public function setShippingAddress($value) - { - return $this->_set(Cart::SHIPPING_ADDRESS, $value); - } - - /** - * Set billing address data object - * - * @param \Magento\Checkout\Service\V1\Data\Cart\Address $value - * @return $this - */ - public function setBillingAddress($value) - { - return $this->_set(Cart::BILLING_ADDRESS, $value); - } - - /** - * @param \Magento\Checkout\Service\V1\Data\Cart\Totals $value - * @return $this - */ - public function setTotals($value) - { - return $this->_set(Cart::TOTALS, $value); - } - - /** - * Set reserved order id - * - * @param string $value - * @return $this - */ - public function setReservedOrderId($value) - { - return $this->_set(Cart::RESERVED_ORDER_ID, $value); - } - - /** - * Set original order id - * - * @param string $value - * @return $this - */ - public function setOrigOrderId($value) - { - return $this->_set(Cart::ORIG_ORDER_ID, $value); - } - - /** - * @param \Magento\Checkout\Service\V1\Data\Cart\Currency|null $value - * @return $this - */ - public function setCurrency($value) - { - return $this->_set(Cart::CURRENCY, $value); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartMapper.php b/app/code/Magento/Checkout/Service/V1/Data/CartMapper.php deleted file mode 100644 index 96327ac3aa9e5a927c40d13c791e22ffba9aeab3..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/CartMapper.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data; - -use Magento\Checkout\Service\V1\Data\Cart; -use Magento\Quote\Model\Quote; - -/** - * Cart mapper - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class CartMapper -{ - /** - * @var Cart\TotalsBuilder - */ - private $totalsBuilder; - - /** - * @var CartBuilder - */ - private $cartBuilder; - - /** - * @var Cart\CustomerBuilder - */ - private $customerBuilder; - - /** - * @var Cart\CustomerMapper - */ - private $customerMapper; - - /** - * @var Cart\TotalsMapper - */ - private $totalsMapper; - - /** - * @var Cart\CurrencyMapper; - */ - private $currencyMapper; - - /** - * @var Cart\Totals\ItemMapper - */ - private $itemTotalsMapper; - - /** - * @param Cart\TotalsBuilder $totalsBuilder - * @param CartBuilder $cartBuilder - * @param Cart\CustomerBuilder $customerBuilder - * @param Cart\CustomerMapper $customerMapper - * @param Cart\TotalsMapper $totalsMapper - * @param Cart\CurrencyMapper $currencyMapper - * @param Cart\Totals\ItemMapper $itemTotalsMapper - */ - public function __construct( - Cart\TotalsBuilder $totalsBuilder, - CartBuilder $cartBuilder, - Cart\CustomerBuilder $customerBuilder, - Cart\CustomerMapper $customerMapper, - Cart\TotalsMapper $totalsMapper, - Cart\CurrencyMapper $currencyMapper, - Cart\Totals\ItemMapper $itemTotalsMapper - ) { - $this->totalsBuilder = $totalsBuilder; - $this->cartBuilder = $cartBuilder; - $this->customerBuilder = $customerBuilder; - $this->customerMapper = $customerMapper; - $this->totalsMapper = $totalsMapper; - $this->currencyMapper = $currencyMapper; - $this->itemTotalsMapper = $itemTotalsMapper; - } - - /** - * Fetch base quote data and map it to DTO fields - * - * @param Quote $quote - * @return array - */ - public function map(Quote $quote) - { - $this->cartBuilder->populateWithArray([ - Cart::ID => $quote->getId(), - Cart::STORE_ID => $quote->getStoreId(), - Cart::CREATED_AT => $quote->getCreatedAt(), - Cart::UPDATED_AT => $quote->getUpdatedAt(), - Cart::CONVERTED_AT => $quote->getConvertedAt(), - Cart::IS_ACTIVE => $quote->getIsActive(), - Cart::IS_VIRTUAL => $quote->getIsVirtual(), - Cart::ITEMS_COUNT => $quote->getItemsCount(), - Cart::ITEMS_QUANTITY => $quote->getItemsQty(), - Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), - Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), - Cart::ORIG_ORDER_ID => $quote->getOrigOrderId(), - ]); - - $this->customerBuilder->populateWithArray($this->customerMapper->map($quote)); - $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote)); - $items = []; - foreach ($quote->getAllItems() as $item) { - $items[] = $this->itemTotalsMapper->extractDto($item); - } - $this->totalsBuilder->setItems($items); - - $this->cartBuilder->setCustomer($this->customerBuilder->create()); - $this->cartBuilder->setTotals($this->totalsBuilder->create()); - $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote)); - return $this->cartBuilder->create(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php deleted file mode 100644 index 1ffb276415c3a525a9b8886f0d96de3c100c7e5b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data; - -/** - * @codeCoverageIgnore - */ -class CartSearchResults extends \Magento\Framework\Api\SearchResults -{ - /** - * Get items - * - * @return \Magento\Checkout\Service\V1\Data\Cart[] - */ - public function getItems() - { - return parent::getItems(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php deleted file mode 100644 index f3f46270d2adb087859bc9b45572cd2fbe1a66dd..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data; - -use Magento\Framework\Api\AbstractSearchResultsBuilder; -use Magento\Framework\Api\AttributeDataBuilder; -use Magento\Framework\Api\MetadataServiceInterface; -use Magento\Framework\Api\ObjectFactory; -use Magento\Framework\Api\SearchCriteriaBuilder; - -/** - * @codeCoverageIgnore - */ -class CartSearchResultsBuilder extends AbstractSearchResultsBuilder -{ - /** - * Constructor - * - * @param ObjectFactory $objectFactory - * @param AttributeDataBuilder $valueBuilder - * @param MetadataServiceInterface $metadataService - * @param SearchCriteriaBuilder $searchCriteriaBuilder - * @param CartBuilder $itemObjectBuilder - */ - public function __construct( - ObjectFactory $objectFactory, - AttributeDataBuilder $valueBuilder, - MetadataServiceInterface $metadataService, - SearchCriteriaBuilder $searchCriteriaBuilder, - CartBuilder $itemObjectBuilder - ) { - parent::__construct( - $objectFactory, - $valueBuilder, - $metadataService, - $searchCriteriaBuilder, - $itemObjectBuilder - ); - } - - /** - * Set cart list - * - * @param \Magento\Checkout\Service\V1\Data\Cart[] $items - * @return $this - */ - public function setItems($items) - { - return parent::setItems($items); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod.php b/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod.php deleted file mode 100644 index db5c1fb6667d3a1e574c798821b93f91794e27ef..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Data; - -/** - * @codeCoverageIgnore - */ -class PaymentMethod extends \Magento\Framework\Api\AbstractExtensibleObject -{ - const CODE = 'code'; - - const TITLE = 'title'; - - /** - * Get payment method code - * - * @return string - */ - public function getCode() - { - return $this->_get(self::CODE); - } - - /** - * Get payment method title - * - * @return string - */ - public function getTitle() - { - return $this->_get(self::TITLE); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod/Converter.php b/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod/Converter.php deleted file mode 100644 index 970763c2878aeef35f09c4c66410e56677559e44..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod/Converter.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\PaymentMethod; - -use Magento\Checkout\Service\V1\Data\PaymentMethod as QuotePaymentMethod; - -/** - * Payment method converter. - */ -class Converter -{ - /** - * Payment method builder. - * - * @var \Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder - */ - protected $builder; - - /** - * Constructs a payment method converter object. - * - * @param \Magento\Checkout\Service\V1\Data\PaymentMethodBuilder $builder Payment method builder. - */ - public function __construct(\Magento\Checkout\Service\V1\Data\PaymentMethodBuilder $builder) - { - $this->builder = $builder; - } - - /** - * Converts quote payment object to payment data object. - * - * @param \Magento\Payment\Model\MethodInterface $object The quote payment object. - * @return \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod Payment data object. - */ - public function toDataObject(\Magento\Payment\Model\MethodInterface $object) - { - $data = [ - QuotePaymentMethod::CODE => $object->getCode(), - QuotePaymentMethod::TITLE => $object->getTitle(), - ]; - return $this->builder->populateWithArray($data)->create(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Item/ReadService.php b/app/code/Magento/Checkout/Service/V1/Item/ReadService.php deleted file mode 100644 index 68ca13033f5491bc587c0b8de526b13fe9a669d6..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Item/ReadService.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Item; - -/** - * Read service object. - */ -class ReadService implements ReadServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Item mapper. - * - * @var \Magento\Checkout\Service\V1\Data\Cart\ItemMapper - */ - protected $itemMapper; - - /** - * Constructs a read service object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param \Magento\Checkout\Service\V1\Data\Cart\ItemMapper $itemMapper Item mapper. - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - \Magento\Checkout\Service\V1\Data\Cart\ItemMapper $itemMapper - ) { - $this->quoteRepository = $quoteRepository; - $this->itemMapper = $itemMapper; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Item[] Array of items. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getList($cartId) - { - $output = []; - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - - /** @var \Magento\Quote\Model\Quote\Item $item */ - foreach ($quote->getAllItems() as $item) { - $output[] = $this->itemMapper->extractDto($item); - } - return $output; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php deleted file mode 100644 index 6bbaaa7e5d72e883dac9e14a7ab2a41521163aab..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Item; - -/** - * Read service interface. - */ -interface ReadServiceInterface -{ - /** - * Lists items that are assigned to a specified cart. - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Item[] Array of items. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getList($cartId); -} diff --git a/app/code/Magento/Checkout/Service/V1/Item/WriteService.php b/app/code/Magento/Checkout/Service/V1/Item/WriteService.php deleted file mode 100644 index b8fc3a97ceb2c590bbbb00e6b76e574fc3825696..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Item/WriteService.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Item; - -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Exception\InputException; -use Magento\Framework\Exception\NoSuchEntityException; - -/** - * Write service object. - */ -class WriteService implements WriteServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Product repository. - * - * @var \Magento\Catalog\Api\ProductRepositoryInterface - */ - protected $productRepository; - - /** - * Constructs a write service object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - \Magento\Catalog\Api\ProductRepositoryInterface $productRepository - ) { - $this->quoteRepository = $quoteRepository; - $this->productRepository = $productRepository; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @param \Magento\Checkout\Service\V1\Data\Cart\Item $data The item. - * @return int Item ID. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\CouldNotSaveException The specified item could not be saved to the cart. - * @throws \Magento\Framework\Exception\InputException The specified item or cart is not valid. - */ - public function addItem($cartId, \Magento\Checkout\Service\V1\Data\Cart\Item $data) - { - $qty = $data->getQty(); - if (!is_numeric($qty) || $qty <= 0) { - throw InputException::invalidFieldValue('qty', $qty); - } - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - - $product = $this->productRepository->get($data->getSku()); - - try { - $quote->addProduct($product, $qty); - $this->quoteRepository->save($quote->collectTotals()); - } catch (\Exception $e) { - throw new CouldNotSaveException('Could not add item to quote'); - } - return $quote->getItemByProduct($product)->getId(); - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @param int $itemId The item ID of the item to be updated. - * @param \Magento\Checkout\Service\V1\Data\Cart\Item $data The item. - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified item or cart does not exist. - * @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be updated. - * @throws \Magento\Framework\Exception\InputException The specified item or cart is not valid. - */ - public function updateItem($cartId, $itemId, \Magento\Checkout\Service\V1\Data\Cart\Item $data) - { - $qty = $data->getQty(); - if (!is_numeric($qty) || $qty <= 0) { - throw InputException::invalidFieldValue('qty', $qty); - } - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - $quoteItem = $quote->getItemById($itemId); - if (!$quoteItem) { - throw new NoSuchEntityException("Cart $cartId doesn't contain item $itemId"); - } - $quoteItem->setData('qty', $qty); - - try { - $this->quoteRepository->save($quote->collectTotals()); - } catch (\Exception $e) { - throw new CouldNotSaveException('Could not update quote item'); - } - return true; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @param int $itemId The item ID of the item to be removed. - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified item or cart does not exist. - * @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be removed. - */ - public function removeItem($cartId, $itemId) - { - /** - * Quote. - * - * @var \Magento\Quote\Model\Quote $quote - */ - $quote = $this->quoteRepository->getActive($cartId); - $quoteItem = $quote->getItemById($itemId); - if (!$quoteItem) { - throw new NoSuchEntityException("Cart $cartId doesn't contain item $itemId"); - } - try { - $quote->removeItem($itemId); - $this->quoteRepository->save($quote->collectTotals()); - } catch (\Exception $e) { - throw new CouldNotSaveException('Could not remove item from quote'); - } - return true; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php deleted file mode 100644 index 20ea6ec225a09fcd026aabbf974fa6d030e3966a..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\PaymentMethod; - -use \Magento\Quote\Model\QuoteRepository; -use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter as QuoteMethodConverter; -use Magento\Checkout\Service\V1\Data\PaymentMethod\Converter as PaymentMethodConverter; -use Magento\Payment\Model\MethodList; - -/** - * Payment method read service object. - */ -class ReadService implements ReadServiceInterface -{ - /** - * Quote repository. - * - * @var QuoteRepository - */ - protected $quoteRepository; - - /** - * Quote method converter. - * - * @var QuoteMethodConverter - */ - protected $quoteMethodConverter; - - /** - * Payment method converter. - * - * @var PaymentMethodConverter - */ - protected $paymentMethodConverter; - - /** - * Method list. - * - * @var MethodList - */ - protected $methodList; - - /** - * Constructs a payment method read service object. - * - * @param QuoteRepository $quoteRepository Quote repository. - * @param QuoteMethodConverter $quoteMethodConverter Quote method converter. - * @param PaymentMethodConverter $paymentMethodConverter Payment method converter. - * @param MethodList $methodList Method list. - */ - public function __construct( - QuoteRepository $quoteRepository, - QuoteMethodConverter $quoteMethodConverter, - PaymentMethodConverter $paymentMethodConverter, - MethodList $methodList - ) { - $this->quoteRepository = $quoteRepository; - $this->quoteMethodConverter = $quoteMethodConverter; - $this->paymentMethodConverter = $paymentMethodConverter; - $this->methodList = $methodList; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod Payment method object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getPayment($cartId) - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - $payment = $quote->getPayment(); - if (!$payment->getId()) { - return null; - } - return $this->quoteMethodConverter->toDataObject($payment); - } - - /** - * {@inheritDoc} - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\PaymentMethod[] Array of payment methods. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getList($cartId) - { - $output = []; - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - foreach ($this->methodList->getAvailableMethods($quote) as $method) { - $output[] = $this->paymentMethodConverter->toDataObject($method); - } - return $output; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceInterface.php deleted file mode 100644 index 228bafd2e5a3bb4f4525d40dc71299c89178f3db..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\PaymentMethod; - -/** - * Payment method read service interface. - */ -interface ReadServiceInterface -{ - /** - * Returns the payment method for a specified shopping cart. - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod Payment method object. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getPayment($cartId); - - /** - * Lists available payment methods for a specified shopping cart. - * - * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\PaymentMethod[] Array of payment methods. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function getList($cartId); -} diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php deleted file mode 100644 index e2a35850f226de32cb953e8a20cdbfde330b4ce4..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\PaymentMethod; - -use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder; -use Magento\Framework\Exception\State\InvalidTransitionException; -use Magento\Payment\Model\Checks\ZeroTotal; -use Magento\Quote\Model\QuoteRepository; - -/** - * Payment method write service object. - */ -class WriteService implements WriteServiceInterface -{ - /** - * Quote repository. - * - * @var QuoteRepository - */ - protected $quoteRepository; - - /** - * Payment method builder. - * - * @var Builder - */ - protected $paymentMethodBuilder; - - /** - * Zero total validator. - * - * @var ZeroTotal - */ - protected $zeroTotalValidator; - - /** - * Constructs a payment method write service object. - * - * @param QuoteRepository $quoteRepository Quote repository. - * @param Builder $paymentMethodBuilder Payment method builder. - * @param ZeroTotal $zeroTotalValidator Zero total validator. - */ - public function __construct( - QuoteRepository $quoteRepository, - Builder $paymentMethodBuilder, - ZeroTotal $zeroTotalValidator - ) { - $this->quoteRepository = $quoteRepository; - $this->paymentMethodBuilder = $paymentMethodBuilder; - $this->zeroTotalValidator = $zeroTotalValidator; - } - - /** - * {@inheritDoc} - * - * @param \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod $method The payment method. - * @param int $cartId The cart ID. - * @return int Payment method ID. - * @throws \Magento\Framework\Exception\State\InvalidTransitionException The billing or shipping address is not set, or the specified payment method is not available. - */ - public function set(\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod $method, $cartId) - { - $quote = $this->quoteRepository->getActive($cartId); - - $payment = $this->paymentMethodBuilder->build($method, $quote); - if ($quote->isVirtual()) { - // check if billing address is set - if (is_null($quote->getBillingAddress()->getCountryId())) { - throw new InvalidTransitionException('Billing address is not set'); - } - $quote->getBillingAddress()->setPaymentMethod($payment->getMethod()); - } else { - // check if shipping address is set - if (is_null($quote->getShippingAddress()->getCountryId())) { - throw new InvalidTransitionException('Shipping address is not set'); - } - $quote->getShippingAddress()->setPaymentMethod($payment->getMethod()); - } - if (!$quote->isVirtual() && $quote->getShippingAddress()) { - $quote->getShippingAddress()->setCollectShippingRates(true); - } - - if (!$this->zeroTotalValidator->isApplicable($payment->getMethodInstance(), $quote)) { - throw new InvalidTransitionException('The requested Payment Method is not available.'); - } - - $quote->setTotalsCollectedFlag(false) - ->collectTotals() - ->save(); - - return $quote->getPayment()->getId(); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceInterface.php deleted file mode 100644 index ff294bd3293007d8fe27698d352cd8205e119253..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\PaymentMethod; - -/** - * Payment method write service interface. - */ -interface WriteServiceInterface -{ - /** - * Adds a specified payment method to a specified shopping cart. - * - * @param \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod $method The payment method. - * @param int $cartId The cart ID. - * @return int Payment method ID. - * @throws \Magento\Framework\Exception\State\InvalidTransitionException The billing or shipping address is not set, or the specified payment method is not available. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - */ - public function set(\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod $method, $cartId); -} diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceInterface.php deleted file mode 100644 index 42848f2637b58445bbb8f2b737dcc6185dd61d6c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceInterface.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\ShippingMethod; - -/** - * Quote shipping method read service interface. - */ -interface ReadServiceInterface -{ - /** - * Returns selected shipping method for a specified quote. - * - * @param int $cartId The shopping cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\ShippingMethod Shipping method. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified shopping cart does not exist. - * @throws \Magento\Framework\Exception\StateException The shipping address is not set. - */ - public function getMethod($cartId); - - /** - * Lists applicable shipping methods for a specified quote. - * - * @param int $cartId The shopping cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\ShippingMethod[] An array of shipping methods. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified quote does not exist. - * @throws \Magento\Framework\Exception\StateException The shipping address is not set. - */ - public function getList($cartId); -} diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php deleted file mode 100644 index 4dd75a5550f414afcadb25038c48481e46ad38e7..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\ShippingMethod; - -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Exception\InputException; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Exception\StateException; -use Magento\Quote\Model\QuoteRepository; - -/** - * Shipping method write service object. - */ -class WriteService implements WriteServiceInterface -{ - /** - * Address factory. - * - * @var \Magento\Quote\Model\Quote\AddressFactory - */ - protected $addressFactory; - - /** - * Quote repository. - * - * @var QuoteRepository - */ - protected $quoteRepository; - - /** - * Constructs a shipping method write service object. - * - * @param \Magento\Quote\Model\Quote\AddressFactory $addressFactory Address factory. - * @param QuoteRepository $quoteRepository Quote repository. - */ - public function __construct( - \Magento\Quote\Model\Quote\AddressFactory $addressFactory, - QuoteRepository $quoteRepository - ) { - $this->addressFactory = $addressFactory; - $this->quoteRepository = $quoteRepository; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The shopping cart ID. - * @param string $carrierCode The carrier code. - * @param string $methodCode The shipping method code. - * @return bool - * @throws \Magento\Framework\Exception\InputException The shipping method is not valid for an empty cart. - * @throws \Magento\Framework\Exception\CouldNotSaveException The shipping method could not be saved. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart contains only virtual products and the shipping method is not applicable. - * @throws \Magento\Framework\Exception\StateException The billing or shipping address is not set. - */ - public function setMethod($cartId, $carrierCode, $methodCode) - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - if (0 == $quote->getItemsCount()) { - throw new InputException('Shipping method is not applicable for empty cart'); - } - - if ($quote->isVirtual()) { - throw new NoSuchEntityException( - 'Cart contains virtual product(s) only. Shipping method is not applicable.' - ); - } - $shippingAddress = $quote->getShippingAddress(); - if (!$shippingAddress->getCountryId()) { - throw new StateException('Shipping address is not set'); - } - $billingAddress = $quote->getBillingAddress(); - if (!$billingAddress->getCountryId()) { - throw new StateException('Billing address is not set'); - } - - $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode); - if (!$shippingAddress->requestShippingRates()) { - throw new NoSuchEntityException('Carrier with such method not found: ' . $carrierCode . ', ' . $methodCode); - } - try { - $this->quoteRepository->save($quote->collectTotals()); - } catch (\Exception $e) { - throw new CouldNotSaveException('Cannot set shipping method. ' . $e->getMessage()); - } - return true; - } -} diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceInterface.php deleted file mode 100644 index 15c7ae02f6ca71bbb615398d552a076f69b9fe0f..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceInterface.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\ShippingMethod; - -/** - * Interface to choose the shipping method for a cart address. - */ -interface WriteServiceInterface -{ - /** - * Sets the carrier and shipping methods codes for a specified cart. - * - * @param int $cartId The shopping cart ID. - * @param string $carrierCode The carrier code. - * @param string $methodCode The shipping method code. - * @return bool - * @throws \Magento\Framework\Exception\InputException The shipping method is not valid for an empty cart. - * @throws \Magento\Framework\Exception\CouldNotSaveException The shipping method could not be saved. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart contains only virtual products so the shipping method does not apply. - * @throws \Magento\Framework\Exception\StateException The billing or shipping address is not set. - */ - public function setMethod($cartId, $carrierCode, $methodCode); -} diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 38bd83c692b9ae685fe3d4b227e5e1ed991c90eb..5a270ffc2c1f8e27e775af65643d00061010e14c 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -3,29 +3,28 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-authorization": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-payment": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-gift-message": "0.42.0-beta4", - "magento/module-wishlist": "0.42.0-beta4", - "magento/module-page-cache": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-msrp": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-ui": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-payment": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-gift-message": "0.42.0-beta5", + "magento/module-wishlist": "0.42.0-beta5", + "magento/module-page-cache": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-msrp": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-ui": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Checkout/etc/di.xml b/app/code/Magento/Checkout/etc/di.xml index 33ae407c99345abf6624ce1ee1a04eb03f219f1d..f7d28cc7c961cfc47dbe1cd7cdd1dc391e05ac8c 100644 --- a/app/code/Magento/Checkout/etc/di.xml +++ b/app/code/Magento/Checkout/etc/di.xml @@ -23,19 +23,4 @@ <argument name="storage" xsi:type="object">Magento\Checkout\Model\Session\Storage</argument> </arguments> </type> - <preference for="Magento\Checkout\Service\V1\Item\ReadServiceInterface" type="Magento\Checkout\Service\V1\Item\ReadService" /> - <preference for="\Magento\Checkout\Service\V1\Item\WriteServiceInterface" type="Magento\Checkout\Service\V1\Item\WriteService" /> - <preference for="\Magento\Checkout\Service\V1\Address\Shipping\ReadServiceInterface" type="Magento\Checkout\Service\V1\Address\Shipping\ReadService" /> - <preference for="\Magento\Checkout\Service\V1\Address\Shipping\WriteServiceInterface" type="Magento\Checkout\Service\V1\Address\Shipping\WriteService" /> - <preference for="\Magento\Checkout\Service\V1\Address\Billing\ReadServiceInterface" type="Magento\Checkout\Service\V1\Address\Billing\ReadService" /> - <preference for="\Magento\Checkout\Service\V1\Address\Billing\WriteServiceInterface" type="Magento\Checkout\Service\V1\Address\Billing\WriteService" /> - <preference for="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" type="Magento\Checkout\Service\V1\Cart\ReadService" /> - <preference for="Magento\Checkout\Service\V1\Cart\TotalsServiceInterface" type="Magento\Checkout\Service\V1\Cart\TotalsService" /> - <preference for="\Magento\Checkout\Service\V1\Cart\WriteServiceInterface" type="Magento\Checkout\Service\V1\Cart\WriteService" /> - <preference for="Magento\Checkout\Service\V1\ShippingMethod\WriteServiceInterface" type="Magento\Checkout\Service\V1\ShippingMethod\WriteService" /> - <preference for="Magento\Checkout\Service\V1\Coupon\ReadServiceInterface" type="Magento\Checkout\Service\V1\Coupon\ReadService" /> - <preference for="Magento\Checkout\Service\V1\Coupon\WriteServiceInterface" type="Magento\Checkout\Service\V1\Coupon\WriteService" /> - <preference for="Magento\Checkout\Service\V1\ShippingMethod\ReadServiceInterface" type="Magento\Checkout\Service\V1\ShippingMethod\ReadService" /> - <preference for="Magento\Checkout\Service\V1\PaymentMethod\ReadServiceInterface" type="\Magento\Checkout\Service\V1\PaymentMethod\ReadService" /> - <preference for="Magento\Checkout\Service\V1\PaymentMethod\WriteServiceInterface" type="\Magento\Checkout\Service\V1\PaymentMethod\WriteService" /> </config> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js index c3c6b12819d96358cc13b4e61ceb3a1bb0dbab53..cda76773ef3c4ebe4f6b654886833425f5630486 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js @@ -37,8 +37,7 @@ define([ var isAgreementValid = true; agreementFormsGroup.find('form').each( function(){ - $(this).validation(); - isAgreementValid = isAgreementValid && $(this).validation && $(this).validation('isValid'); + isAgreementValid = $(this).validation() && $(this).validation('isValid') && isAgreementValid; } ); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/overview.js b/app/code/Magento/Checkout/view/frontend/web/js/overview.js index 4ce29e190e4e2b5211de126dd5c0bf36e5111a77..94f918b73e64335f4d1d624959083620151f9afe 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/overview.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/overview.js @@ -11,13 +11,12 @@ define([ "mage/translate" ], function($){ "use strict"; - + $.widget('mage.orderOverview', { options: { opacity: 0.5, // CSS opacity for the 'Place Order' button when it's clicked and then disabled. pleaseWaitLoader: 'span.please-wait', // 'Submitting order information...' Ajax loader. - placeOrderSubmit: 'button[type="submit"]', // The 'Place Order' button. - agreements: '#checkout-agreements' // Container for all of the checkout agreements and terms/conditions + placeOrderSubmit: 'button[type="submit"]' // The 'Place Order' button. }, /** @@ -29,14 +28,12 @@ define([ }, /** - * Verify that all agreements and terms/conditions are checked. Show the Ajax loader. Disable - * the submit button (i.e. Place Order). + * Show the Ajax loader. Disable the submit button (i.e. Place Order). * @return {Boolean} * @private */ _showLoader: function() { - if ($(this.options.agreements).find('input[type="checkbox"]:not(:checked)').length > 0) { - alert($.mage.__('Please agree to all Terms and Conditions before placing the orders.')); + if (!this.element.validation('isValid')) { return false; } this.element.find(this.options.pleaseWaitLoader).show().end() @@ -44,6 +41,6 @@ define([ return true; } }); - + return $.mage.orderOverview; }); \ No newline at end of file diff --git a/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php b/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..3d528c2a3969d4d9df645a92eff98c77f67cdec0 --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CheckoutAgreements\Api; + +interface CheckoutAgreementsRepositoryInterface +{ + /** + * Lists active checkout agreements. + * + * @return \Magento\CheckoutAgreements\Api\Data\AgreementInterface[] + */ + public function getList(); +} diff --git a/app/code/Magento/CheckoutAgreements/Api/Data/AgreementInterface.php b/app/code/Magento/CheckoutAgreements/Api/Data/AgreementInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..86daddcff06e5a6c50a66f6498b58347e9a1797f --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/Api/Data/AgreementInterface.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CheckoutAgreements\Api\Data; + +interface AgreementInterface +{ + /** + * Returns the agreement ID. + * + * @return int Agreement ID. + */ + public function getAgreementId(); + + /** + * Returns the agreement name. + * + * @return string Agreement name. + */ + public function getName(); + + /** + * Returns the agreement content. + * + * @return string Agreement content. + */ + public function getContent(); + + /** + * Returns the agreement content height, which is an optional CSS property. + * + * @return string|null Agreement content height. Otherwise, null. + */ + public function getContentHeight(); + + /** + * Returns the agreement checkbox text. + * + * @return string Agreement checkbox text. + */ + public function getCheckboxText(); + + /** + * Returns the agreement status. + * + * @return bool Agreement status. + * @SuppressWarnings(PHPMD.BooleanGetMethodName) + */ + public function getIsActive(); + + /** + * Returns the agreement content type. + * + * @return bool * true - HTML. + * * false - plain text. + * @SuppressWarnings(PHPMD.BooleanGetMethodName) + */ + public function getIsHtml(); +} diff --git a/app/code/Magento/CheckoutAgreements/Model/Agreement.php b/app/code/Magento/CheckoutAgreements/Model/Agreement.php index 8a565ffb74e0448d6b25c5ee2c3114f56abd1da1..df49829e376a4e80745fbbaf38d8480b08c3834e 100644 --- a/app/code/Magento/CheckoutAgreements/Model/Agreement.php +++ b/app/code/Magento/CheckoutAgreements/Model/Agreement.php @@ -5,24 +5,10 @@ */ namespace Magento\CheckoutAgreements\Model; -/** - * @method \Magento\CheckoutAgreements\Model\Resource\Agreement _getResource() - * @method \Magento\CheckoutAgreements\Model\Resource\Agreement getResource() - * @method string getName() - * @method \Magento\CheckoutAgreements\Model\Agreement setName(string $value) - * @method string getContent() - * @method \Magento\CheckoutAgreements\Model\Agreement setContent(string $value) - * @method string getContentHeight() - * @method \Magento\CheckoutAgreements\Model\Agreement setContentHeight(string $value) - * @method string getCheckboxText() - * @method \Magento\CheckoutAgreements\Model\Agreement setCheckboxText(string $value) - * @method int getIsActive() - * @method \Magento\CheckoutAgreements\Model\Agreement setIsActive(int $value) - * @method int getIsHtml() - * @method \Magento\CheckoutAgreements\Model\Agreement setIsHtml(int $value) - * - */ -class Agreement extends \Magento\Framework\Model\AbstractModel +use Magento\CheckoutAgreements\Api\Data\AgreementInterface; +use Magento\Framework\Model\AbstractExtensibleModel; + +class Agreement extends AbstractExtensibleModel implements AgreementInterface { /** * Allowed CSS units for height field @@ -77,4 +63,62 @@ class Agreement extends \Magento\Framework\Model\AbstractModel return parent::beforeSave(); } + + //@codeCoverageIgnoreStart + /** + * @inheritdoc + */ + public function getAgreementId() + { + return $this->getData('agreement_id'); + } + + /** + * @inheritdoc + */ + public function getName() + { + return $this->getData('name'); + } + + /** + * @inheritdoc + */ + public function getContent() + { + return $this->getData('content'); + } + + /** + * @inheritdoc + */ + public function getContentHeight() + { + return $this->getData('content_height'); + } + + /** + * @inheritdoc + */ + public function getCheckboxText() + { + return $this->getData('checkbox_text'); + } + + /** + * @inheritdoc + */ + public function getIsActive() + { + return $this->getData('is_active'); + } + + /** + * @inheritdoc + */ + public function getIsHtml() + { + return $this->getData('is_html'); + } + //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php b/app/code/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepository.php similarity index 54% rename from app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php rename to app/code/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepository.php index 68c68ee8cdfec54083e6b8c97cc56cd218c7fa56..892e1599241f3e1858379aed0788bd134f023914 100644 --- a/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php +++ b/app/code/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepository.php @@ -6,21 +6,19 @@ // @codingStandardsIgnoreFile -namespace Magento\CheckoutAgreements\Service\V1\Agreement; +namespace Magento\CheckoutAgreements\Model; use Magento\CheckoutAgreements\Model\Resource\Agreement\CollectionFactory as AgreementCollectionFactory; use Magento\CheckoutAgreements\Model\Resource\Agreement\Collection as AgreementCollection; -use Magento\CheckoutAgreements\Model\Agreement; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Model\ScopeInterface; -use Magento\CheckoutAgreements\Service\V1\Data\AgreementBuilder; -use Magento\CheckoutAgreements\Service\V1\Data\Agreement as AgreementDataObject; +use Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface; /** - * Checkout agreement service. + * Checkout agreement repository. */ -class ReadService implements ReadServiceInterface +class CheckoutAgreementsRepository implements CheckoutAgreementsRepositoryInterface { /** * Collection factory. @@ -29,13 +27,6 @@ class ReadService implements ReadServiceInterface */ private $collectionFactory; - /** - * Agreement builder. - * - * @var AgreementBuilder - */ - private $agreementBuilder; - /** * Store manager. * @@ -51,21 +42,18 @@ class ReadService implements ReadServiceInterface private $scopeConfig; /** - * Constructs a checkout agreement service object. + * Constructs a checkout agreement data object. * * @param AgreementCollectionFactory $collectionFactory Collection factory. - * @param AgreementBuilder $agreementBuilder Agreement builder. * @param \Magento\Store\Model\StoreManagerInterface $storeManager Store manager. * @param ScopeConfigInterface $scopeConfig Scope config. */ public function __construct( AgreementCollectionFactory $collectionFactory, - AgreementBuilder $agreementBuilder, StoreManagerInterface $storeManager, ScopeConfigInterface $scopeConfig ) { $this->collectionFactory = $collectionFactory; - $this->agreementBuilder = $agreementBuilder; $this->storeManager = $storeManager; $this->scopeConfig = $scopeConfig; } @@ -73,7 +61,7 @@ class ReadService implements ReadServiceInterface /** * {@inheritdoc} * - * @return array|\Magento\CheckoutAgreements\Service\V1\Data\Agreement[] Array of checkout agreement service objects. + * @return \Magento\CheckoutAgreements\Api\Data\AgreementInterface[] Array of checkout agreement data objects. */ public function getList() { @@ -88,29 +76,9 @@ class ReadService implements ReadServiceInterface $agreementDataObjects = []; foreach ($agreementCollection as $agreement) { - $agreementDataObjects[] = $this->createAgreementDataObject($agreement); + $agreementDataObjects[] = $agreement; } return $agreementDataObjects; } - - /** - * Creates an agreement data object based on a specified agreement model. - * - * @param Agreement $agreement The agreement model. - * @return AgreementDataObject Agreement data object. - */ - protected function createAgreementDataObject(Agreement $agreement) - { - $this->agreementBuilder->populateWithArray([ - AgreementDataObject::ID => $agreement->getId(), - AgreementDataObject::NAME => $agreement->getName(), - AgreementDataObject::CONTENT => $agreement->getContent(), - AgreementDataObject::CONTENT_HEIGHT => $agreement->getContentHeight(), - AgreementDataObject::CHECKBOX_TEXT => $agreement->getCheckboxText(), - AgreementDataObject::ACTIVE => (bool)$agreement->getIsActive(), - AgreementDataObject::HTML => (bool)$agreement->getIsHtml(), - ]); - return $this->agreementBuilder->create(); - } } diff --git a/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceInterface.php b/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceInterface.php deleted file mode 100644 index baf99c5990d95ca15a85fd999c42eedceab92f38..0000000000000000000000000000000000000000 --- a/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\CheckoutAgreements\Service\V1\Agreement; - -/** - * Checkout agreement service interface. - */ -interface ReadServiceInterface -{ - /** - * Lists active checkout agreements. - * - * @return \Magento\CheckoutAgreements\Service\V1\Data\Agreement[] Array of active checkout agreements. - */ - public function getList(); -} diff --git a/app/code/Magento/CheckoutAgreements/Service/V1/Data/Agreement.php b/app/code/Magento/CheckoutAgreements/Service/V1/Data/Agreement.php deleted file mode 100644 index 52275580119de2a7613421416d80b9c6f262998e..0000000000000000000000000000000000000000 --- a/app/code/Magento/CheckoutAgreements/Service/V1/Data/Agreement.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\CheckoutAgreements\Service\V1\Data; - -use Magento\Framework\Api\AbstractExtensibleObject; - -/** - * Checkout agreement data object. - * - * @codeCoverageIgnore - */ -class Agreement extends AbstractExtensibleObject -{ - /** - * Agreement ID. - */ - const ID = 'id'; - - /** - * Agreement name. - */ - const NAME = 'name'; - - /** - * Agreement content. - */ - const CONTENT = 'content'; - - /** - * Agreement content height. Optional CSS property. - */ - const CONTENT_HEIGHT = 'content_height'; - - /** - * Agreement checkbox text. Caption of UI component. - */ - const CHECKBOX_TEXT = 'checkbox_text'; - - /** - * Agreement status. - */ - const ACTIVE = 'active'; - - /** - * Agreement content type. True is HTML. False is plain text. - */ - const HTML = 'html'; - - /** - * Returns the agreement ID. - * - * @return int Agreement ID. - */ - public function getId() - { - return $this->_get(self::ID); - } - - /** - * Returns the agreement name. - * - * @return string Agreement name. - */ - public function getName() - { - return $this->_get(self::NAME); - } - - /** - * Returns the agreement content. - * - * @return string Agreement content. - */ - public function getContent() - { - return $this->_get(self::CONTENT); - } - - /** - * Returns the agreement content height, which is an optional CSS property. - * - * @return string|null Agreement content height. Otherwise, null. - */ - public function getContentHeight() - { - return $this->_get(self::CONTENT_HEIGHT); - } - - /** - * Returns the agreement checkbox text. - * - * @return string Agreement checkbox text. - */ - public function getCheckboxText() - { - return $this->_get(self::CHECKBOX_TEXT); - } - - /** - * Returns the agreement status. - * - * @return bool Agreement status. - */ - public function isActive() - { - return $this->_get(self::ACTIVE); - } - - /** - * Returns the agreement content type. - * - * @return bool * true - HTML. - * * false - plain text. - */ - public function isHtml() - { - return $this->_get(self::HTML); - } -} diff --git a/app/code/Magento/CheckoutAgreements/Service/V1/Data/AgreementBuilder.php b/app/code/Magento/CheckoutAgreements/Service/V1/Data/AgreementBuilder.php deleted file mode 100644 index 82f11f5f6b4053e5e0e60b271d8beee747c87bfc..0000000000000000000000000000000000000000 --- a/app/code/Magento/CheckoutAgreements/Service/V1/Data/AgreementBuilder.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\CheckoutAgreements\Service\V1\Data; - -use Magento\Framework\Api\ExtensibleObjectBuilder; - -/** - * Checkout agreement data object builder. - * - * @codeCoverageIgnore - */ -class AgreementBuilder extends ExtensibleObjectBuilder -{ - /** - * Sets the agreement ID. - * - * @param int $value The agreement ID. - * @return $this - */ - public function setId($value) - { - return $this->_set(Agreement::ID, $value); - } - - /** - * Sets the agreement name. - * - * @param string $value The agreement name. - * @return $this - */ - public function setName($value) - { - return $this->_set(Agreement::NAME, $value); - } - - /** - * Sets the agreement content. - * - * @param string $value The agreement content. - * @return $this - */ - public function setContent($value) - { - return $this->_set(Agreement::CONTENT, $value); - } - - /** - * Sets the agreement content height, which is an optional CSS property. - * - * @param string $value The agreement content height. - * @return $this - */ - public function setContentHeight($value) - { - return $this->_set(Agreement::CONTENT_HEIGHT, $value); - } - - /** - * Sets the agreement checkbox text. - * - * @param string $value The agreement checkbox text. - * @return $this - */ - public function setCheckboxText($value) - { - return $this->_set(Agreement::CHECKBOX_TEXT, $value); - } - - /** - * Sets the agreement status. - * - * @param bool $value The agreement status value. Set to true for active. - * @return $this - */ - public function setActive($value) - { - return $this->_set(Agreement::ACTIVE, $value); - } - - /** - * Sets the agreement content type. - * - * @param bool $value The agreement content type. Set to true for HTML. Set to false for plain text. - * @return $this - */ - public function setHtml($value) - { - return $this->_set(Agreement::HTML, $value); - } -} diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index d5a47c50bc4b0d954bde20450cd85d216d6997ed..27002a1d39f06dcb45f9d59c94dd364115014d29 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|~5.6.0", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CheckoutAgreements/etc/di.xml b/app/code/Magento/CheckoutAgreements/etc/di.xml index 057668faba72736c474f2b4d83528b526a18f58b..b72ba8165bc5e5dd08df20d658e6ebfd7f4ed8f2 100644 --- a/app/code/Magento/CheckoutAgreements/etc/di.xml +++ b/app/code/Magento/CheckoutAgreements/etc/di.xml @@ -6,7 +6,8 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\CheckoutAgreements\Service\V1\Agreement\ReadServiceInterface" type="Magento\CheckoutAgreements\Service\V1\Agreement\ReadService" /> + <preference for="Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface" type="Magento\CheckoutAgreements\Model\CheckoutAgreementsRepository" /> + <preference for="Magento\CheckoutAgreements\Api\Data\AgreementInterface" type="Magento\CheckoutAgreements\Model\Agreement" /> <type name="Magento\Framework\Module\Updater\SetupFactory"> <arguments> <argument name="resourceTypes" xsi:type="array"> diff --git a/app/code/Magento/CheckoutAgreements/etc/webapi.xml b/app/code/Magento/CheckoutAgreements/etc/webapi.xml index 1c6fa3cd5572ba4eae62901abb1173b9c0444194..5b66e1ff52d5c71af405581abd683fbdf9547249 100644 --- a/app/code/Magento/CheckoutAgreements/etc/webapi.xml +++ b/app/code/Magento/CheckoutAgreements/etc/webapi.xml @@ -8,7 +8,7 @@ <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> <route url="/V1/carts/licence" method="GET"> - <service class="Magento\CheckoutAgreements\Service\V1\Agreement\ReadServiceInterface" method="getList"/> + <service class="Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface" method="getList"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index 88465c8ad4529ed5c115487f9258b384a26e823d..336de310eb79f3387317a48833bd69dacbde009e 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-widget": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-email": "0.42.0-beta4", - "magento/module-ui": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-widget": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-email": "0.42.0-beta5", + "magento/module-ui": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index 8e5c888669acf958fc7e2d275136ac9cd3b97450..5ee6ad540c37f036f05636275d7351b1283e072d 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-cms": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-url-rewrite": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-cms": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-url-rewrite": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json index 5b7e1e3cd382eef13f9c05cce9cdcad36a7fa954..470f26f2fcb7bcbbceea8555a8cbf18959e5148f 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|~5.6.0", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-catalog-import-export": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-import-export": "0.42.0-beta4", - "magento/module-configurable-product": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-catalog-import-export": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-import-export": "0.42.0-beta5", + "magento/module-configurable-product": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index 925cd49e100048db949051bec4dc5edc72cc52ba..69c4345c1be673c4058160ef88a92bb71083074e 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -3,24 +3,24 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-catalog-rule": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-webapi": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-catalog-rule": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-webapi": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index 9ef0d938edd9504ae43cd121b6da7637475611c3..f3f7a447b5839e08e3ef368b0dc79040e050661a 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json index ef8c29a7eba0183dc927bcffe05a4bee94e01e99..3d9fb4646c9e887f1d9a0944548811d50ede154e 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-cron": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-page-cache": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-cron": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-page-cache": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index 583d3a76a125a22be1573cb968eca50844afd293..5acbed553baa119e294ae31313b8483a642c98ad 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index 508d4a1888d971217e917b927222ea056774e20d..aac5c11665a2022d5f841c380a4c17892537e3dc 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-page-cache": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-page-cache": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index 077bac8e41c2b04d3a66f8b12d6896b8069cdc59..72cd0320ac3cbd62e7312204beeedf1dac069d9f 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -3,29 +3,29 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-newsletter": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-wishlist": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-review": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-page-cache": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-authorization": "0.42.0-beta4", - "magento/module-integration": "0.42.0-beta4", - "magento/module-ui": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-newsletter": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-wishlist": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-review": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-page-cache": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-authorization": "0.42.0-beta5", + "magento/module-integration": "0.42.0-beta5", + "magento/module-ui": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index d5a5064f9e57d45a76ef9a2627307a0a9d3caaac..356a378a6ec363f85558a7d19f4903f2665e9110 100644 --- a/app/code/Magento/CustomerImportExport/composer.json +++ b/app/code/Magento/CustomerImportExport/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-backend": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-import-export": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-backend": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-import-export": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index 79e8100a7f7b9a27fc8df52151a580d6e325f78c..3d4d28a75761fb8c846cdaff7c05d1b0925470c2 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index 4019644d6dd1efb24e13dc43e12615049d3ae586..093c2658ed73aba8c84772303404bc6042a85a15 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -3,22 +3,22 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-shipping": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-shipping": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php index fc34e67f0c1656778c5d9b9727fec2d9ccb52b78..3b5ec26325abc5716c3c2137e5c4e75549eaf4d0 100644 --- a/app/code/Magento/Directory/Model/Currency.php +++ b/app/code/Magento/Directory/Model/Currency.php @@ -90,7 +90,13 @@ class Currency extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $resource, + $resourceCollection, + $data + ); $this->_localeFormat = $localeFormat; $this->_storeManager = $storeManager; $this->_directoryHelper = $directoryHelper; @@ -152,6 +158,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel * @param string $id * @param string $field * @return $this + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function load($id, $field = null) { diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index d2f73d089a3f0c40cbe9f025a74ef814e9d92db7..10067e542da7870fb4c32fe22145508db130ec9e 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index 4dfe131efbf3337990ad2ff4c18f6686164e8d2c..0cda376e9001aab778e4f0e75e475ee3fe7b9af2 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-wishlist": "0.42.0-beta4", - "magento/module-gift-message": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-msrp": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-wishlist": "0.42.0-beta5", + "magento/module-gift-message": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-msrp": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index d02b7871d607bcd51504fe3f254dfc85dc0bd99b..c4f86f04350f5b29b3d94b08fafb67326901f8f2 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index d228422e79fa1999657fc2c8da42f89d901f8967..16d885ff3f1197817fd88fa8beb81481a4c76718 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 7290419698c2bdecb97b92cfa44c8ea5bc8e5c52..d51b956ecc129256523b99b212846f54c2c2a095 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-shipping": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-shipping": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GiftMessage/Api/CartRepositoryInterface.php b/app/code/Magento/GiftMessage/Api/CartRepositoryInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..62a7916c14ca9479e2a9feefa458aa2c8aacf5ed --- /dev/null +++ b/app/code/Magento/GiftMessage/Api/CartRepositoryInterface.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\GiftMessage\Api; + +interface CartRepositoryInterface +{ + /** + * Returns the gift message for a specified order. + * + * @param int $cartId The shopping cart ID. + * @return \Magento\GiftMessage\Api\Data\MessageInterface Gift message. + */ + public function get($cartId); + + /** + * Sets the gift message for an entire order. + * + * @param int $cartId The cart ID. + * @param \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage The gift message. + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + * @throws \Magento\Framework\Exception\InputException You cannot add gift messages to empty carts. + * @throws \Magento\Framework\Exception\State\InvalidTransitionException You cannot add gift messages to + * virtual products. + * @throws \Magento\Framework\Exception\CouldNotSaveException The specified gift message could not be saved. + */ + public function save($cartId, \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage); +} diff --git a/app/code/Magento/GiftMessage/Api/Data/MessageInterface.php b/app/code/Magento/GiftMessage/Api/Data/MessageInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..876e4c7514ad874921d06e7597653e02cc525c6c --- /dev/null +++ b/app/code/Magento/GiftMessage/Api/Data/MessageInterface.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\GiftMessage\Api\Data; + +interface MessageInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Returns the gift message ID. + * + * @return int|null Gift message ID. Otherwise, null. + */ + public function getGiftMessageId(); + + /** + * Returns the customer ID. + * + * @return int|null Customer ID. Otherwise, null. + */ + public function getCustomerId(); + + /** + * Returns the sender name. + * + * @return string Sender name. + */ + public function getSender(); + + /** + * Returns the recipient name. + * + * @return string Recipient name. + */ + public function getRecipient(); + + /** + * Returns the message text. + * + * @return string Message text. + */ + public function getMessage(); +} diff --git a/app/code/Magento/GiftMessage/Api/ItemRepositoryInterface.php b/app/code/Magento/GiftMessage/Api/ItemRepositoryInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..f0141740b3ed9b34f40822415c3d301e16e27876 --- /dev/null +++ b/app/code/Magento/GiftMessage/Api/ItemRepositoryInterface.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\GiftMessage\Api; + +interface ItemRepositoryInterface +{ + /** + * Returns the gift message for a specified item in a specified shopping cart. + * + * @param int $cartId The shopping cart ID. + * @param int $itemId The item ID. + * @return \Magento\GiftMessage\Api\Data\MessageInterface Gift message. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified item does not exist in the cart. + */ + public function get($cartId, $itemId); + + /** + * Sets the gift message for a specified item in a specified shopping cart. + * + * @param int $cartId The cart ID. + * @param \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage The gift message. + * @param int $itemId The item ID. + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + * @throws \Magento\Framework\Exception\InputException You cannot add gift messages to empty carts. + * @throws \Magento\Framework\Exception\State\InvalidTransitionException You cannot add gift messages to + * virtual products. + * @throws \Magento\Framework\Exception\CouldNotSaveException The specified gift message could not be saved. + */ + public function save($cartId, \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage, $itemId); +} diff --git a/app/code/Magento/GiftMessage/Model/CartRepository.php b/app/code/Magento/GiftMessage/Model/CartRepository.php new file mode 100644 index 0000000000000000000000000000000000000000..528ccf78320b624bdbdcf75bbf5aac889108dbc9 --- /dev/null +++ b/app/code/Magento/GiftMessage/Model/CartRepository.php @@ -0,0 +1,116 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\GiftMessage\Model; + +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\State\InvalidTransitionException; + +/** + * Shopping cart gift message repository object. + */ +class CartRepository implements \Magento\GiftMessage\Api\CartRepositoryInterface +{ + /** + * Quote repository. + * + * @var \Magento\Quote\Model\QuoteRepository + */ + protected $quoteRepository; + + /** + * Store manager interface. + * + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * Gift message manager. + * + * @var \Magento\GiftMessage\Model\GiftMessageManager + */ + protected $giftMessageManager; + + /** + * Message helper. + * + * @var \Magento\GiftMessage\Helper\Message + */ + protected $helper; + + /** + * Message factory. + * + * @var \Magento\GiftMessage\Model\MessageFactory + */ + protected $messageFactory; + + /** + * @param \Magento\Quote\Model\QuoteRepository $quoteRepository + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param GiftMessageManager $giftMessageManager + * @param \Magento\GiftMessage\Helper\Message $helper + * @param MessageFactory $messageFactory + */ + public function __construct( + \Magento\Quote\Model\QuoteRepository $quoteRepository, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager, + \Magento\GiftMessage\Helper\Message $helper, + \Magento\GiftMessage\Model\MessageFactory $messageFactory + ) { + $this->quoteRepository = $quoteRepository; + $this->giftMessageManager = $giftMessageManager; + $this->storeManager = $storeManager; + $this->helper = $helper; + $this->messageFactory = $messageFactory; + } + + /** + * {@inheritDoc} + */ + public function get($cartId) + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + + $messageId = $quote->getGiftMessageId(); + if (!$messageId) { + return null; + } + + return $this->messageFactory->create()->load($messageId); + } + + /** + * {@inheritDoc} + */ + public function save($cartId, \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage) + { + /** + * Quote. + * + * @var \Magento\Quote\Model\Quote $quote + */ + $quote = $this->quoteRepository->getActive($cartId); + + if (0 == $quote->getItemsCount()) { + throw new InputException('Gift Messages is not applicable for empty cart'); + } + + if ($quote->isVirtual()) { + throw new InvalidTransitionException('Gift Messages is not applicable for virtual products'); + } + if (!$this->helper->getIsMessagesAvailable('quote', $quote, $this->storeManager->getStore())) { + throw new CouldNotSaveException('Gift Message is not available'); + } + $this->giftMessageManager->setMessage($quote, 'quote', $giftMessage); + return true; + } +} diff --git a/app/code/Magento/GiftMessage/Model/GiftMessageManager.php b/app/code/Magento/GiftMessage/Model/GiftMessageManager.php index 5fcbe852b191e91cd95cfc888860db033339ba4f..7fc655d323ab3f2816c55ff433071d19d05ae3f9 100644 --- a/app/code/Magento/GiftMessage/Model/GiftMessageManager.php +++ b/app/code/Magento/GiftMessage/Model/GiftMessageManager.php @@ -5,6 +5,9 @@ */ namespace Magento\GiftMessage\Model; +use Magento\Framework\Exception\State\InvalidTransitionException; +use Magento\Framework\Exception\CouldNotSaveException; + class GiftMessageManager { /** @@ -85,4 +88,38 @@ class GiftMessageManager } return $this; } + + /** + * Sets the gift message to item or quote. + * + * @param \Magento\Quote\Model\Quote $quote The quote. + * @param string $type The type. + * @param \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage The gift message. + * @param null|int $entityId The entity ID. + * @return void + * @throws \Magento\Framework\Exception\CouldNotSaveException The specified gift message is not available. + * @throws \Magento\Framework\Exception\State\InvalidTransitionException The billing or shipping address is not set. + */ + public function setMessage(\Magento\Quote\Model\Quote $quote, $type, $giftMessage, $entityId = null) + { + if (is_null($quote->getBillingAddress()->getCountryId())) { + throw new InvalidTransitionException('Billing address is not set'); + } + + // check if shipping address is set + if (is_null($quote->getShippingAddress()->getCountryId())) { + throw new InvalidTransitionException('Shipping address is not set'); + } + $message[$type][$entityId] = [ + 'from' => $giftMessage->getSender(), + 'to' => $giftMessage->getRecipient(), + 'message' => $giftMessage->getMessage(), + ]; + + try { + $this->add($message, $quote); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not add gift message to shopping cart'); + } + } } diff --git a/app/code/Magento/GiftMessage/Model/ItemRepository.php b/app/code/Magento/GiftMessage/Model/ItemRepository.php new file mode 100644 index 0000000000000000000000000000000000000000..90db371ca8fbdf8ffad383f375a9350e81fdbd01 --- /dev/null +++ b/app/code/Magento/GiftMessage/Model/ItemRepository.php @@ -0,0 +1,128 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\GiftMessage\Model; + +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\State\InvalidTransitionException; +use Magento\Framework\Exception\NoSuchEntityException; + +/** + * Shopping cart gift message item repository object. + */ +class ItemRepository implements \Magento\GiftMessage\Api\ItemRepositoryInterface +{ + /** + * Quote repository. + * + * @var \Magento\Quote\Model\QuoteRepository + */ + protected $quoteRepository; + + /** + * Store manager interface. + * + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * Gift message manager. + * + * @var \Magento\GiftMessage\Model\GiftMessageManager + */ + protected $giftMessageManager; + + /** + * Message helper. + * + * @var \Magento\GiftMessage\Helper\Message + */ + protected $helper; + + /** + * Message factory. + * + * @var \Magento\GiftMessage\Model\MessageFactory + */ + protected $messageFactory; + + /** + * @param \Magento\Quote\Model\QuoteRepository $quoteRepository + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param GiftMessageManager $giftMessageManager + * @param \Magento\GiftMessage\Helper\Message $helper + * @param MessageFactory $messageFactory + */ + public function __construct( + \Magento\Quote\Model\QuoteRepository $quoteRepository, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager, + \Magento\GiftMessage\Helper\Message $helper, + \Magento\GiftMessage\Model\MessageFactory $messageFactory + ) { + $this->quoteRepository = $quoteRepository; + $this->giftMessageManager = $giftMessageManager; + $this->storeManager = $storeManager; + $this->helper = $helper; + $this->messageFactory = $messageFactory; + } + + /** + * {@inheritDoc} + */ + public function get($cartId, $itemId) + { + /** + * Quote. + * + * @var \Magento\Quote\Model\Quote $quote + */ + $quote = $this->quoteRepository->getActive($cartId); + if (!$item = $quote->getItemById($itemId)) { + throw new NoSuchEntityException('There is no item with provided id in the cart'); + }; + $messageId = $item->getGiftMessageId(); + if (!$messageId) { + return null; + } + + /** + * Model. + * + * @var \Magento\GiftMessage\Model\Message $model + */ + return $this->messageFactory->create()->load($messageId); + } + + /** + * {@inheritDoc} + */ + public function save($cartId, \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage, $itemId) + { + /** + * Quote. + * + * @var \Magento\Quote\Model\Quote $quote + */ + $quote = $this->quoteRepository->getActive($cartId); + + if (!$item = $quote->getItemById($itemId)) { + throw new NoSuchEntityException("There is no product with provided itemId: $itemId in the cart"); + }; + + if ($item->getIsVirtual()) { + throw new InvalidTransitionException('Gift Messages is not applicable for virtual products'); + } + if (!$this->helper->getIsMessagesAvailable('items', $quote, $this->storeManager->getStore())) { + throw new CouldNotSaveException('Gift Message is not available'); + } + $this->giftMessageManager->setMessage($quote, 'quote_item', $giftMessage, $itemId); + return true; + } +} diff --git a/app/code/Magento/GiftMessage/Model/Message.php b/app/code/Magento/GiftMessage/Model/Message.php index 0ecfeae37c180d71b171e499edfff72982caf8db..808025555d590796a6202d5d58079c5d6a253047 100644 --- a/app/code/Magento/GiftMessage/Model/Message.php +++ b/app/code/Magento/GiftMessage/Model/Message.php @@ -5,23 +5,22 @@ */ namespace Magento\GiftMessage\Model; +use Magento\Framework\Api\AttributeDataBuilder; + /** * Gift Message model * * @method \Magento\GiftMessage\Model\Resource\Message _getResource() * @method \Magento\GiftMessage\Model\Resource\Message getResource() - * @method int getCustomerId() * @method \Magento\GiftMessage\Model\Message setCustomerId(int $value) - * @method string getSender() * @method \Magento\GiftMessage\Model\Message setSender(string $value) - * @method string getRecipient() * @method \Magento\GiftMessage\Model\Message setRecipient(string $value) - * @method string getMessage() * @method \Magento\GiftMessage\Model\Message setMessage(string $value) * * @author Magento Core Team <core@magentocommerce.com> */ -class Message extends \Magento\Framework\Model\AbstractModel +class Message extends \Magento\Framework\Model\AbstractExtensibleModel implements + \Magento\GiftMessage\Api\Data\MessageInterface { /** * @var \Magento\GiftMessage\Model\TypeFactory @@ -31,21 +30,33 @@ class Message extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\GiftMessage\Model\Resource\Message $resource + * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param AttributeDataBuilder $customAttributeBuilder + * @param Resource\Message $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection - * @param \Magento\GiftMessage\Model\TypeFactory $typeFactory + * @param TypeFactory $typeFactory * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, + \Magento\Framework\Api\MetadataServiceInterface $metadataService, + AttributeDataBuilder $customAttributeBuilder, \Magento\GiftMessage\Model\Resource\Message $resource, \Magento\Framework\Data\Collection\Db $resourceCollection, \Magento\GiftMessage\Model\TypeFactory $typeFactory, array $data = [] ) { $this->_typeFactory = $typeFactory; - parent::__construct($context, $registry, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $metadataService, + $customAttributeBuilder, + $resource, + $resourceCollection, + $data + ); } /** @@ -76,4 +87,46 @@ class Message extends \Magento\Framework\Model\AbstractModel { return trim($this->getMessage()) == ''; } + + /** + * @codeCoverageIgnoreStart + * {@inheritdoc} + */ + public function getGiftMessageId() + { + return $this->getData('gift_message_id'); + } + + /** + * {@inheritdoc} + */ + public function getCustomerId() + { + return $this->getData('customer_id'); + } + + /** + * {@inheritdoc} + */ + public function getSender() + { + return $this->getData('sender'); + } + + /** + * {@inheritdoc} + */ + public function getRecipient() + { + return $this->getData('recipient'); + } + + /** + * {@inheritdoc} + */ + public function getMessage() + { + return $this->getData('message'); + } + ////@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/GiftMessage/Service/V1/Data/Message.php b/app/code/Magento/GiftMessage/Service/V1/Data/Message.php deleted file mode 100644 index 768b74a47e020fc7d6e6d2aed61e4d02b2bd3efa..0000000000000000000000000000000000000000 --- a/app/code/Magento/GiftMessage/Service/V1/Data/Message.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\GiftMessage\Service\V1\Data; - -/** - * Gift message data object. - * - * @codeCoverageIgnore - */ -class Message extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /** - * Gift message ID. - */ - const GIFT_MESSAGE_ID = 'gift_message_id'; - - /** - * Sender name. - */ - const SENDER = 'sender'; - - /** - * Recipient name. - */ - const RECIPIENT = 'recipient'; - - /** - * Message text. - */ - const MESSAGE = 'message'; - - /** - * Customer ID. - */ - const CUSTOMER_ID = 'customer_id'; - - /** - * Returns the gift message ID. - * - * @return int|null Gift message ID. Otherwise, null. - */ - public function getGiftMessageId() - { - return $this->_get(self::GIFT_MESSAGE_ID); - } - - /** - * Returns the customer ID. - * - * @return int|null Customer ID. Otherwise, null. - */ - public function getCustomerId() - { - return $this->_get(self::CUSTOMER_ID); - } - - /** - * Returns the sender name. - * - * @return string Sender name. - */ - public function getSender() - { - return $this->_get(self::SENDER); - } - - /** - * Returns the recipient name. - * - * @return string Recipient name. - */ - public function getRecipient() - { - return $this->_get(self::RECIPIENT); - } - - /** - * Returns the message text. - * - * @return string Message text. - */ - public function getMessage() - { - return $this->_get(self::MESSAGE); - } -} diff --git a/app/code/Magento/GiftMessage/Service/V1/ReadService.php b/app/code/Magento/GiftMessage/Service/V1/ReadService.php deleted file mode 100644 index e1e0dda0ace03d2329a4ecd324c4584d5056aaa3..0000000000000000000000000000000000000000 --- a/app/code/Magento/GiftMessage/Service/V1/ReadService.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\GiftMessage\Service\V1; - -use Magento\Framework\Exception\NoSuchEntityException; - -/** - * Shopping cart gift message service object. - */ -class ReadService implements ReadServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Message factory. - * - * @var \Magento\GiftMessage\Model\MessageFactory - */ - protected $messageFactory; - - /** - * Message mapper. - * - * @var \Magento\GiftMessage\Service\V1\Data\MessageMapper - */ - protected $messageMapper; - - /** - * Constructs a shopping cart gift message service object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param \Magento\GiftMessage\Model\MessageFactory $messageFactory Message factory. - * @param \Magento\GiftMessage\Service\V1\Data\MessageMapper $messageMapper Message mapper. - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - \Magento\GiftMessage\Model\MessageFactory $messageFactory, - \Magento\GiftMessage\Service\V1\Data\MessageMapper $messageMapper - ) { - $this->quoteRepository = $quoteRepository; - $this->messageFactory = $messageFactory; - $this->messageMapper = $messageMapper; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The shopping cart ID. - * @return \Magento\GiftMessage\Service\V1\Data\Message Gift message. - */ - public function get($cartId) - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - - $messageId = $quote->getGiftMessageId(); - if (!$messageId) { - return null; - } - - /** @var \Magento\GiftMessage\Model\Message $model */ - $model = $this->messageFactory->create()->load($messageId); - - return $this->messageMapper->extractDto($model); - } - - /** - * {@inheritDoc} - * - * @param int $cartId The shopping cart ID. - * @param int $itemId The item ID. - * @return \Magento\GiftMessage\Service\V1\Data\Message Gift message. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified item does not exist in the cart. - */ - public function getItemMessage($cartId, $itemId) - { - /** - * Quote. - * - * @var \Magento\Quote\Model\Quote $quote - */ - $quote = $this->quoteRepository->getActive($cartId); - if (!$item = $quote->getItemById($itemId)) { - throw new NoSuchEntityException('There is no item with provided id in the cart'); - }; - $messageId = $item->getGiftMessageId(); - if (!$messageId) { - return null; - } - - /** - * Model. - * - * @var \Magento\GiftMessage\Model\Message $model - */ - $model = $this->messageFactory->create()->load($messageId); - - return $this->messageMapper->extractDto($model); - } -} diff --git a/app/code/Magento/GiftMessage/Service/V1/ReadServiceInterface.php b/app/code/Magento/GiftMessage/Service/V1/ReadServiceInterface.php deleted file mode 100644 index 6da2510a67e52e29a0d78781b2864495750545bb..0000000000000000000000000000000000000000 --- a/app/code/Magento/GiftMessage/Service/V1/ReadServiceInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\GiftMessage\Service\V1; - -/** - * Quote shipping method read service interface. - */ -interface ReadServiceInterface -{ - /** - * Returns the gift message for a specified order. - * - * @param int $cartId The shopping cart ID. - * @return \Magento\GiftMessage\Service\V1\Data\Message Gift message. - */ - public function get($cartId); - - /** - * Returns the gift message for a specified item in a specified shopping cart. - * - * @param int $cartId The shopping cart ID. - * @param int $itemId The item ID. - * @return \Magento\GiftMessage\Service\V1\Data\Message Gift message. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified item does not exist in the cart. - */ - public function getItemMessage($cartId, $itemId); -} diff --git a/app/code/Magento/GiftMessage/Service/V1/WriteService.php b/app/code/Magento/GiftMessage/Service/V1/WriteService.php deleted file mode 100644 index 0163c329a40ce534ae237c060f91de5f6b568507..0000000000000000000000000000000000000000 --- a/app/code/Magento/GiftMessage/Service/V1/WriteService.php +++ /dev/null @@ -1,163 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\GiftMessage\Service\V1; - -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Exception\InputException; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Exception\State\InvalidTransitionException; - -/** - * Gift message write service data object. - */ -class WriteService implements WriteServiceInterface -{ - /** - * Quote repository. - * - * @var \Magento\Quote\Model\QuoteRepository - */ - protected $quoteRepository; - - /** - * Store manager interface. - * - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $storeManager; - - /** - * Gift message manager. - * - * @var \Magento\GiftMessage\Model\GiftMessageManager - */ - protected $giftMessageManager; - - /** - * Message helper. - * - * @var \Magento\GiftMessage\Helper\Message - */ - protected $helper; - - /** - * Constructs a gift message write service data object. - * - * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param \Magento\Store\Model\StoreManagerInterface $storeManager Store manager. - * @param \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager Gift message manager. - * @param \Magento\GiftMessage\Helper\Message $helper Message helper. - */ - public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager, - \Magento\GiftMessage\Helper\Message $helper - ) { - $this->quoteRepository = $quoteRepository; - $this->giftMessageManager = $giftMessageManager; - $this->storeManager = $storeManager; - $this->helper = $helper; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The shopping cart ID. - * @param Data\Message $giftMessage The gift message. - * @return bool - * @throws \Magento\Framework\Exception\InputException You cannot add gift messages to empty carts. - * @throws \Magento\Framework\Exception\State\InvalidTransitionException You cannot add gift messages to virtual - * products. - */ - public function setForQuote($cartId, \Magento\GiftMessage\Service\V1\Data\Message $giftMessage) - { - /** - * Quote. - * - * @var \Magento\Quote\Model\Quote $quote - */ - $quote = $this->quoteRepository->getActive($cartId); - - if (0 == $quote->getItemsCount()) { - throw new InputException('Gift Messages is not applicable for empty cart'); - } - - if ($quote->isVirtual()) { - throw new InvalidTransitionException('Gift Messages is not applicable for virtual products'); - } - - $this->setMessage($quote, 'quote', $giftMessage); - return true; - } - - /** - * {@inheritDoc} - * - * @param int $cartId The shopping cart ID. - * @param Data\Message $giftMessage The gift message. - * @param int $itemId The item ID. - * @return bool - * @throws \Magento\Framework\Exception\State\InvalidTransitionException You cannot add gift messages to - * virtual products. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified item does not exist in the cart. - */ - public function setForItem($cartId, \Magento\GiftMessage\Service\V1\Data\Message $giftMessage, $itemId) - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->getActive($cartId); - - if (!$item = $quote->getItemById($itemId)) { - throw new NoSuchEntityException("There is no product with provided itemId: $itemId in the cart"); - }; - - if ($item->getIsVirtual()) { - throw new InvalidTransitionException('Gift Messages is not applicable for virtual products'); - } - - $this->setMessage($quote, 'quote_item', $giftMessage, $itemId); - return true; - } - - /** - * Sets the gift message to item or quote. - * - * @param \Magento\Quote\Model\Quote $quote The quote. - * @param string $type The type. - * @param \Magento\GiftMessage\Service\V1\Data\Message $giftMessage The gift message. - * @param null|int $entityId The entity ID. - * @return void - * @throws \Magento\Framework\Exception\CouldNotSaveException The specified gift message is not available. - * @throws \Magento\Framework\Exception\State\InvalidTransitionException The billing or shipping address is not set. - */ - protected function setMessage(\Magento\Quote\Model\Quote $quote, $type, $giftMessage, $entityId = null) - { - if (is_null($quote->getBillingAddress()->getCountryId())) { - throw new InvalidTransitionException('Billing address is not set'); - } - - // check if shipping address is set - if (is_null($quote->getShippingAddress()->getCountryId())) { - throw new InvalidTransitionException('Shipping address is not set'); - } - - $configType = $type == 'quote' ? '' : 'items'; - if (!$this->helper->getIsMessagesAvailable($configType, $quote, $this->storeManager->getStore())) { - throw new CouldNotSaveException('Gift Message is not available'); - } - $message[$type][$entityId] = [ - 'from' => $giftMessage->getSender(), - 'to' => $giftMessage->getRecipient(), - 'message' => $giftMessage->getMessage(), - ]; - - try { - $this->giftMessageManager->add($message, $quote); - } catch (\Exception $e) { - throw new CouldNotSaveException('Could not add gift message to shopping cart'); - } - } -} diff --git a/app/code/Magento/GiftMessage/Service/V1/WriteServiceInterface.php b/app/code/Magento/GiftMessage/Service/V1/WriteServiceInterface.php deleted file mode 100644 index 295485887416ec9ec665a823338b36bb783cf993..0000000000000000000000000000000000000000 --- a/app/code/Magento/GiftMessage/Service/V1/WriteServiceInterface.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\GiftMessage\Service\V1; - -/** - * Quote shipping method read service. - */ -interface WriteServiceInterface -{ - /** - * Sets the gift message for an entire order. - * - * @param int $cartId The cart ID. - * @param \Magento\GiftMessage\Service\V1\Data\Message $giftMessage The gift message. - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\InputException You cannot add gift messages to empty carts. - * @throws \Magento\Framework\Exception\State\InvalidTransitionException You cannot add gift messages to - * virtual products. - * @throws \Magento\Framework\Exception\CouldNotSaveException The specified gift message could not be saved. - */ - public function setForQuote($cartId, \Magento\GiftMessage\Service\V1\Data\Message $giftMessage); - - /** - * Sets the gift message for a specified item. - * - * @param int $cartId The cart ID. - * @param \Magento\GiftMessage\Service\V1\Data\Message $giftMessage The gift message. - * @param int $itemId The item ID. - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\InputException You cannot add gift messages to empty carts. - * @throws \Magento\Framework\Exception\State\InvalidTransitionException You cannot add gift messages to - * virtual products. - * @throws \Magento\Framework\Exception\CouldNotSaveException The specified gift message could not be saved. - */ - public function setForItem($cartId, \Magento\GiftMessage\Service\V1\Data\Message $giftMessage, $itemId); -} diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index 3a01616c8d4e4762c68bfc3c7dc76e5fa38a1879..1142c6bb8c34f03c6c6966fec032912c9ba575b1 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-multishipping": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-multishipping": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GiftMessage/etc/di.xml b/app/code/Magento/GiftMessage/etc/di.xml index a01e8d4bed694f3190fc2132796ee6c9c56d5fc6..f49fdfcd4b5c4c51487985c7a004c0bd2edd0fba 100644 --- a/app/code/Magento/GiftMessage/etc/di.xml +++ b/app/code/Magento/GiftMessage/etc/di.xml @@ -20,6 +20,7 @@ </argument> </arguments> </type> - <preference for="Magento\GiftMessage\Service\V1\ReadServiceInterface" type="Magento\GiftMessage\Service\V1\ReadService"/> - <preference for="Magento\GiftMessage\Service\V1\WriteServiceInterface" type="Magento\GiftMessage\Service\V1\WriteService"/> + <preference for="Magento\GiftMessage\Api\CartRepositoryInterface" type="Magento\GiftMessage\Model\CartRepository"/> + <preference for="Magento\GiftMessage\Api\ItemRepositoryInterface" type="Magento\GiftMessage\Model\ItemRepository"/> + <preference for="Magento\GiftMessage\Api\Data\MessageInterface" type="Magento\GiftMessage\Model\Message"/> </config> diff --git a/app/code/Magento/GiftMessage/etc/webapi.xml b/app/code/Magento/GiftMessage/etc/webapi.xml index e5875d5d09d5a9c24a0bfaaff409ae315c3e65d8..c5dd571a7ac105813159525195c8074be14be8c6 100644 --- a/app/code/Magento/GiftMessage/etc/webapi.xml +++ b/app/code/Magento/GiftMessage/etc/webapi.xml @@ -8,25 +8,25 @@ <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> <route url="/V1/carts/:cartId/gift-message" method="GET"> - <service class="Magento\GiftMessage\Service\V1\ReadServiceInterface" method="get"/> + <service class="Magento\GiftMessage\Api\CartRepositoryInterface" method="get"/> <resources> <resource ref="Magento_Sales::create" /> </resources> </route> <route url="/V1/carts/:cartId/gift-message/:itemId" method="GET"> - <service class="Magento\GiftMessage\Service\V1\ReadServiceInterface" method="getItemMessage"/> + <service class="Magento\GiftMessage\Api\ItemRepositoryInterface" method="get"/> <resources> <resource ref="Magento_Sales::create" /> </resources> </route> - <route url="/V1/carts/:cartId/gift-message" method="PUT"> - <service class="Magento\GiftMessage\Service\V1\WriteServiceInterface" method="setForQuote"/> + <route url="/V1/carts/:cartId/gift-message" method="POST"> + <service class="Magento\GiftMessage\Api\CartRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::create" /> </resources> </route> - <route url="/V1/carts/:cartId/gift-message/:itemId" method="PUT"> - <service class="Magento\GiftMessage\Service\V1\WriteServiceInterface" method="setForItem"/> + <route url="/V1/carts/:cartId/gift-message/:itemId" method="POST"> + <service class="Magento\GiftMessage\Api\ItemRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::create" /> </resources> diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index 39e31ce86c536b67eabaad0ee94847ddbfc453fd..c452340ddba31069974e2709c4a7c22044e11ed8 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 36c520368a0fcaff30376d928cb52fa8b07cf051..057bf57573c3bf0409b369fadab38e8a7b1b6ad9 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index 35eb2dec491b69593e2e624f7c3ee87c5be66c05..6ccc86c4b7237d32aebf9b5d6e5c9a2869621f04 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-google-analytics": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-google-analytics": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 06930c045265755931ac1ee41acca725dcd28f1e..a8267bf53b11950d6b2bd0867a968d9c7fa16f70 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json index 98e7b3d0940d987ad6e8249ac47803be02d21318..31a7e9d18593b3532bafd8c232c5aa4f8fefeee7 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|~5.6.0", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-import-export": "0.42.0-beta4", - "magento/module-catalog-import-export": "0.42.0-beta4", - "magento/module-grouped-product": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-import-export": "0.42.0-beta5", + "magento/module-catalog-import-export": "0.42.0-beta5", + "magento/module-grouped-product": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index a39cb2bef2398cf164bf84c794237fcf1d4e9a50..66765e0905decf74925b42f8b8aefcb7b1f7e16a 100644 --- a/app/code/Magento/GroupedProduct/composer.json +++ b/app/code/Magento/GroupedProduct/composer.json @@ -3,22 +3,22 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-msrp": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-msrp": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index cf1edd4bf677045853afd1798e2fe0ad5740ab43..6bd32167a3f7e201922980ba5e67220f2d623e70 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-indexer": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-indexer": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index 3639c8c5acc7463bcb5a49c1cac4b231fe867646..94d226c6548ccb838473a104f94a2b7194abed36 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|~5.6.0", - "magento/module-backend": "0.42.0-beta4", - "magento/module-page-cache": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-backend": "0.42.0-beta5", + "magento/module-page-cache": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index 5173a1289899445da8a7731b62e3cbd400cb9157..301e687b7c36eef264934625777060be4d964ee4 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-user": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-authorization": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-user": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-authorization": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index 076de1684536d16b841880998fd83f75951f2e54..0e9de4b96a770e370f461541ae5bb98c63e3ae9f 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|~5.6.0", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index 5217997ddac9441daa4a223c3afd6e70be0488aa..5e633eb2806dd2e14e9b4bf40263c09ec7e3e440 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Msrp/composer.json b/app/code/Magento/Msrp/composer.json index f0ae88d6a9313dc841786629b11a14643f65e542..d31f4fdb9032ae11be61a6bc10054f0b87e0da7f 100644 --- a/app/code/Magento/Msrp/composer.json +++ b/app/code/Magento/Msrp/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-bundle": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-downloadable": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-grouped-product": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-bundle": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-downloadable": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-grouped-product": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index 16088de7f6e184c6a29e6394e12a5faac5fd4fc3..809ec11f824c0bb52cb5b27e830e79a6b347bd08 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -616,10 +616,10 @@ class Multishipping extends \Magento\Framework\Object if ($address->getAddressType() == 'billing') { $order->setIsVirtual(1); } else { - $order->setShippingAddress($this->quoteAddressToOrderAddress->addressToOrderAddress($address)); + $order->setShippingAddress($this->quoteAddressToOrderAddress->convert($address)); } - $order->setPayment($this->quotePaymentToOrderPayment->paymentToOrderPayment($quote->getPayment())); + $order->setPayment($this->quotePaymentToOrderPayment->convert($quote->getPayment())); if ($this->priceCurrency->round($address->getGrandTotal()) == 0) { $order->getPayment()->setMethod('free'); } @@ -634,7 +634,7 @@ class Multishipping extends \Magento\Framework\Object )->setProductOptions( $_quoteItem->getProduct()->getTypeInstance()->getOrderOptions($_quoteItem->getProduct()) ); - $orderItem = $this->quoteItemToOrderItem->itemToOrderItem($item); + $orderItem = $this->quoteItemToOrderItem->convert($_quoteItem); if ($item->getParentItem()) { $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId())); } diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index b6ad3579769b9c440a855bcead48b50edaadb5e2..94cbf4ea1f4a1d4e5ffdf2b880e88767a293d0d1 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-payment": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-payment": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Multishipping/view/frontend/templates/checkout/overview.phtml b/app/code/Magento/Multishipping/view/frontend/templates/checkout/overview.phtml index 51302fd4e104d3220833aa9ecc88b1fda7a3432b..64358eb5197713f61be652ad1a99e8f9e0efb8c3 100644 --- a/app/code/Magento/Multishipping/view/frontend/templates/checkout/overview.phtml +++ b/app/code/Magento/Multishipping/view/frontend/templates/checkout/overview.phtml @@ -7,7 +7,7 @@ // @codingStandardsIgnoreFile ?> -<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="review-order-form" data-mage-init='{"orderOverview": {}}' class="form multicheckout order-review"> +<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="review-order-form" data-mage-init='{"orderOverview": {}, "validation":{}}' class="form multicheckout order-review"> <?php echo $this->getBlockHtml('formkey'); ?> <div class="block block-billing"> <div class="block-title"><strong><?php echo __('Billing Information') ?></strong></div> diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 8fd1f35d11f8a1601f3bbd1c5f0cc3f066071ae9..6a42aa3339296263f34ebd10ab3fa75a484afbc2 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-widget": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/module-email": "0.42.0-beta4", - "magento/module-cron": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-widget": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/module-email": "0.42.0-beta5", + "magento/module-cron": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index c04204b657bd8091ccc5ee7e16490a5b75f90bae..8cbb8f7f2e4544987786f39fb4eb9c709b5921ba 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|~5.6.0", - "magento/module-payment": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-payment": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index f3929a902fdafb878a0a2ba086be0c198e90c143..c721f1f83eddd65e6a374f51d46308e66d63d186 100644 --- a/app/code/Magento/OfflineShipping/composer.json +++ b/app/code/Magento/OfflineShipping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-shipping": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-sales-rule": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-shipping": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-sales-rule": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index 055bc6ae45fa3b9ea2a7d9dbfa09ee14629bdc88..3840361a003b47e20c3669d606c71b704cd89a04 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/PageCache/etc/varnish.vcl b/app/code/Magento/PageCache/etc/varnish.vcl index 4b2a337ba321fe2498965857456c7acc44f0c38c..2b90ee0e3ef14cb62ec4c038855bc8ae27b90d44 100644 --- a/app/code/Magento/PageCache/etc/varnish.vcl +++ b/app/code/Magento/PageCache/etc/varnish.vcl @@ -46,6 +46,18 @@ sub vcl_recv { if (req.request != "GET" && req.request != "HEAD") { return (pass); } + + # normalize url in case of leading HTTP scheme and domain + set req.url = regsub(req.url, "^http[s]?://[^/]+", ""); + + # collect all cookies + std.collect(req.http.Cookie); + + # static files are always cacheable. remove SSL flag and cookie + if (req.url ~ "^/(pub/)?(media|static)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico|woff|svg)$") { + unset req.http.Https; + unset req.http.Cookie; + } set req.grace = 1m; diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index d34a730f44babe204a2412b7e2f70ff9cdd2f83d..ca6dd62a7c5856d84d6706e77910e093cbdc7046 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -12,14 +12,19 @@ use Magento\Payment\Model\Checks\PaymentMethodChecksInterface; use Magento\Payment\Model\MethodInterface; use Magento\Sales\Model\Order\Invoice; use Magento\Sales\Model\Order\Payment; +use Magento\Quote\Api\Data\PaymentMethodInterface; /** * Payment method abstract model * @method AbstractMethod setStore() * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -abstract class AbstractMethod extends \Magento\Framework\Object implements MethodInterface, PaymentMethodChecksInterface +abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibleModel implements + MethodInterface, + PaymentMethodChecksInterface, + PaymentMethodInterface { const ACTION_ORDER = 'order'; @@ -215,24 +220,40 @@ abstract class AbstractMethod extends \Magento\Framework\Object implements Metho protected $logger; /** - * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\Model\Resource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data */ public function __construct( - \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Psr\Log\LoggerInterface $logger, + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { - parent::__construct($data); - $this->logger = $logger; - $this->_eventManager = $eventManager; + parent::__construct( + $context, + $registry, + $metadataService, + $customAttributeBuilder, + $resource, + $resourceCollection, + $data + ); $this->_paymentData = $paymentData; $this->_scopeConfig = $scopeConfig; + $this->_eventManager = $context->getEventDispatcher(); + $this->logger = $context->getLogger(); } /** diff --git a/app/code/Magento/Payment/Model/Method/Cc.php b/app/code/Magento/Payment/Model/Method/Cc.php index 031f6155cbf5b2ecdda8fe1fadc8887c6b28f992..ab4058f3789c723d03664657ade6e5cf126956af 100644 --- a/app/code/Magento/Payment/Model/Method/Cc.php +++ b/app/code/Magento/Payment/Model/Method/Cc.php @@ -5,6 +5,9 @@ */ namespace Magento\Payment\Model\Method; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Cc extends \Magento\Payment\Model\Method\AbstractMethod { /** @@ -40,26 +43,45 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod protected $_centinelService; /** - * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService + * @param \Magento\Framework\Model\Resource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Psr\Log\LoggerInterface $logger, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { - parent::__construct($eventManager, $paymentData, $scopeConfig, $logger, $data); + parent::__construct( + $context, + $registry, + $metadataService, + $customAttributeBuilder, + $paymentData, + $scopeConfig, + $resource, + $resourceCollection, + $data + ); $this->_moduleList = $moduleList; $this->_localeDate = $localeDate; $this->_centinelService = $centinelService; diff --git a/app/code/Magento/Payment/Model/Method/Free.php b/app/code/Magento/Payment/Model/Method/Free.php index c229101b5a514a689bbd31604d1d9c2ff5d0abbd..b7a7e00f601dbe9cf3e4124757070b6eb11de0fd 100644 --- a/app/code/Magento/Payment/Model/Method/Free.php +++ b/app/code/Magento/Payment/Model/Method/Free.php @@ -41,22 +41,41 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod protected $priceCurrency; /** - * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Psr\Log\LoggerInterface $logger * @param PriceCurrencyInterface $priceCurrency + * @param \Magento\Framework\Model\Resource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Psr\Log\LoggerInterface $logger, PriceCurrencyInterface $priceCurrency, + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { - parent::__construct($eventManager, $paymentData, $scopeConfig, $logger, $data); + parent::__construct( + $context, + $registry, + $metadataService, + $customAttributeBuilder, + $paymentData, + $scopeConfig, + $resource, + $resourceCollection, + $data + ); $this->priceCurrency = $priceCurrency; } diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 3eb01931bb2d4403e608b4128601355aea4a0154..60faba8ae0ac888196a213444144d6bcfe17a4b4 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-centinel": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-centinel": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index 3680fca52129bf67c3e2ff1cc1f3516179c50030..10370a7abe702275cc01831fb9e92a731784bc2e 100644 --- a/app/code/Magento/Persistent/composer.json +++ b/app/code/Magento/Persistent/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-cron": "0.42.0-beta4", - "magento/module-page-cache": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-cron": "0.42.0-beta5", + "magento/module-page-cache": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 11578bec3f343960bc9ceae8c6a5fd44ceb6d038..92693fb6a37f2b664db52842f1028e90ce97ce84 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Quote/Api/BillingAddressManagementInterface.php b/app/code/Magento/Quote/Api/BillingAddressManagementInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..ebadf462e06060dc3d649acf4670ff9db18bf667 --- /dev/null +++ b/app/code/Magento/Quote/Api/BillingAddressManagementInterface.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api; + +interface BillingAddressManagementInterface +{ + /** + * Assigns a specified billing address to a specified cart. + * + * @param int $cartId The cart ID. + * @param \Magento\Quote\Api\Data\AddressInterface $address Billing address data. + * @return int Address ID. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + * @throws \Magento\Framework\Exception\InputException The specified cart ID or address data is not valid. + */ + public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address); + + /** + * Returns the billing address for a specified quote. + * + * @param int $cartId The cart ID. + * @return \Magento\Quote\Api\Data\AddressInterface Quote billing address object. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + */ + public function get($cartId); +} diff --git a/app/code/Magento/Checkout/Service/V1/Item/WriteServiceInterface.php b/app/code/Magento/Quote/Api/CartItemRepositoryInterface.php similarity index 55% rename from app/code/Magento/Checkout/Service/V1/Item/WriteServiceInterface.php rename to app/code/Magento/Quote/Api/CartItemRepositoryInterface.php index 30a0db6dfb4a1eedb2e914f3ed95df59ac736ccc..708f29fef341501425887b6495ae9aaa564c94a3 100644 --- a/app/code/Magento/Checkout/Service/V1/Item/WriteServiceInterface.php +++ b/app/code/Magento/Quote/Api/CartItemRepositoryInterface.php @@ -3,37 +3,39 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Item; +namespace Magento\Quote\Api; -/** - * Write service interface. - */ -interface WriteServiceInterface +interface CartItemRepositoryInterface { /** - * Adds the specified item to the specified cart. + * Lists items that are assigned to a specified cart. * * @param int $cartId The cart ID. - * @param \Magento\Checkout\Service\V1\Data\Cart\Item $data The item. - * @return int Item ID. + * @return \Magento\Quote\Api\Data\CartItemInterface[] Array of items. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + */ + public function getList($cartId); + + /** + * Adds the specified item to the specified cart. + * + * @param \Magento\Quote\Api\Data\CartItemInterface $cartItem The item. + * @return \Magento\Quote\Api\Data\CartItemInterface Item. * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. * @throws \Magento\Framework\Exception\CouldNotSaveException The specified item could not be saved to the cart. * @throws \Magento\Framework\Exception\InputException The specified item or cart is not valid. */ - public function addItem($cartId, \Magento\Checkout\Service\V1\Data\Cart\Item $data); + public function save(\Magento\Quote\Api\Data\CartItemInterface $cartItem); /** - * Updates the specified item in the specified cart. + * Remove bundle option * - * @param int $cartId The cart ID. - * @param int $itemId The item ID of the item to be updated. - * @param \Magento\Checkout\Service\V1\Data\Cart\Item $data The item. - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified item or cart does not exist. - * @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be updated. - * @throws \Magento\Framework\Exception\InputException The specified item or cart is not valid. + * @param \Magento\Quote\Api\Data\CartItemInterface $cartItem + * @return void + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Webapi\Exception */ - public function updateItem($cartId, $itemId, \Magento\Checkout\Service\V1\Data\Cart\Item $data); + public function delete(\Magento\Quote\Api\Data\CartItemInterface $cartItem); /** * Removes the specified item from the specified cart. @@ -44,5 +46,5 @@ interface WriteServiceInterface * @throws \Magento\Framework\Exception\NoSuchEntityException The specified item or cart does not exist. * @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be removed. */ - public function removeItem($cartId, $itemId); + public function deleteById($cartId, $itemId); } diff --git a/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php b/app/code/Magento/Quote/Api/CartManagementInterface.php similarity index 53% rename from app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php rename to app/code/Magento/Quote/Api/CartManagementInterface.php index d38945578132893e3e85e1bd28afa1dc81892db5..4bf49813ac4313319350c774ee038d1f312453da 100644 --- a/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php +++ b/app/code/Magento/Quote/Api/CartManagementInterface.php @@ -3,29 +3,37 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Cart; +namespace Magento\Quote\Api; -/** - * Cart write service interface. - */ -interface WriteServiceInterface +interface CartManagementInterface { /** * Enables an administrative or guest user to create an empty cart and quote for an anonymous customer. * + * @param int $storeId * @throws \Magento\Framework\Exception\CouldNotSaveException The empty cart and quote could not be created. * @return int Cart ID. */ - public function create(); + public function createEmptyCart($storeId); + + /** + * Returns information for the cart for a specified customer. + * + * @param int $customerId The customer ID. + * @return \Magento\Quote\Api\Data\CartInterface Cart object. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified customer does not exist. + */ + public function getCartForCustomer($customerId); /** * Assigns a specified customer to a specified shopping cart. * * @param int $cartId The cart ID. * @param int $customerId The customer ID. + * @param int $storeId * @return boolean */ - public function assignCustomer($cartId, $customerId); + public function assignCustomer($cartId, $customerId, $storeId); /** * Places an order for a specified cart. @@ -33,5 +41,5 @@ interface WriteServiceInterface * @param int $cartId The cart ID. * @return int Order ID. */ - public function order($cartId); + public function placeOrder($cartId); } diff --git a/app/code/Magento/Quote/Api/CartRepositoryInterface.php b/app/code/Magento/Quote/Api/CartRepositoryInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..63db4ccd4c0951cfa226556e854e4677929564c5 --- /dev/null +++ b/app/code/Magento/Quote/Api/CartRepositoryInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api; + +interface CartRepositoryInterface +{ + /** + * Enables an administrative user to return information for a specified cart. + * + * @param int $cartId + * @return \Magento\Quote\Api\Data\CartInterface + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($cartId); + + /** + * Enables administrative users to list carts that match specified search criteria. + * + * @param \Magento\Framework\Api\SearchCriteria $searchCriteria + * @return \Magento\Quote\Api\Data\CartSearchResultsInterface + */ + public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria); +} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/TotalsServiceInterface.php b/app/code/Magento/Quote/Api/CartTotalRepositoryInterface.php similarity index 58% rename from app/code/Magento/Checkout/Service/V1/Cart/TotalsServiceInterface.php rename to app/code/Magento/Quote/Api/CartTotalRepositoryInterface.php index d88f5421ed4e360286f700e749ff29e43e08130e..305c06e8ffedb31a0fdcf3894f7b245b967555ed 100644 --- a/app/code/Magento/Checkout/Service/V1/Cart/TotalsServiceInterface.php +++ b/app/code/Magento/Quote/Api/CartTotalRepositoryInterface.php @@ -3,19 +3,16 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Cart; +namespace Magento\Quote\Api; -/** - * Totals service interface. - */ -interface TotalsServiceInterface +interface CartTotalRepositoryInterface { /** * Returns quote totals data for a specified cart. * * @param int $cartId The cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\Totals Quote totals data. + * @return \Magento\Quote\Api\Data\TotalsInterface Quote totals data. * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. */ - public function getTotals($cartId); + public function get($cartId); } diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/WriteServiceInterface.php b/app/code/Magento/Quote/Api/CouponManagementInterface.php similarity index 59% rename from app/code/Magento/Checkout/Service/V1/Coupon/WriteServiceInterface.php rename to app/code/Magento/Quote/Api/CouponManagementInterface.php index 586071765cc15d9825148eaadee1afb560dd6f00..280d248d49d2f48b9ea1248dbcb20198f2536adf 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/WriteServiceInterface.php +++ b/app/code/Magento/Quote/Api/CouponManagementInterface.php @@ -1,25 +1,36 @@ <?php /** + * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Coupon; + +namespace Magento\Quote\Api; /** - * Coupon write service interface. + * Coupon management service interface. */ -interface WriteServiceInterface +interface CouponManagementInterface { + /** + * Returns information for a coupon in a specified cart. + * + * @param int $cartId The cart ID. + * @return string The coupon code data. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + */ + public function get($cartId); + /** * Adds a coupon by code to a specified cart. * * @param int $cartId The cart ID. - * @param \Magento\Checkout\Service\V1\Data\Cart\Coupon $couponCodeData The coupon code data. + * @param string $couponCode The coupon code data. * @return bool * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. * @throws \Magento\Framework\Exception\CouldNotSaveException The specified coupon could not be added. */ - public function set($cartId, \Magento\Checkout\Service\V1\Data\Cart\Coupon $couponCodeData); + public function set($cartId, $couponCode); /** * Deletes a coupon from a specified cart. @@ -29,5 +40,5 @@ interface WriteServiceInterface * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. * @throws \Magento\Framework\Exception\CouldNotDeleteException The specified coupon could not be deleted. */ - public function delete($cartId); + public function remove($cartId); } diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address.php b/app/code/Magento/Quote/Api/Data/AddressInterface.php similarity index 50% rename from app/code/Magento/Checkout/Service/V1/Data/Cart/Address.php rename to app/code/Magento/Quote/Api/Data/AddressInterface.php index a65d1cbc5d5215629c25a2e678030202d75889c3..d5f23c64c59147ed93d4e9d6f9ba90bcf7a1c2dd 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address.php +++ b/app/code/Magento/Quote/Api/Data/AddressInterface.php @@ -3,14 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Data\Cart; +namespace Magento\Quote\Api\Data; -/** - * Quote billing/shipping address data - * - * @codeCoverageIgnore - */ -class Address extends \Magento\Framework\Api\AbstractExtensibleObject +interface AddressInterface extends \Magento\Framework\Api\ExtensibleDataInterface { /**#@+ * Constants defined for keys of array, makes typos less likely @@ -21,9 +16,13 @@ class Address extends \Magento\Framework\Api\AbstractExtensibleObject const KEY_ID = 'id'; - const KEY_CUSTOMER_ID = 'customer_id'; + const REGION_ID = 'region_id'; - const KEY_REGION = 'region'; + const REGION_CODE = 'region_code'; + + const REGION = 'region'; + + const KEY_CUSTOMER_ID = 'customer_id'; const KEY_STREET = 'street'; @@ -56,168 +55,131 @@ class Address extends \Magento\Framework\Api\AbstractExtensibleObject * * @return int|null */ - public function getId() - { - return $this->_get(self::KEY_ID); - } + public function getId(); /** - * Get region + * Get region name * - * @return \Magento\Checkout\Service\V1\Data\Cart\Address\Region|null + * @return string + */ + public function getRegion(); + + /** + * Get region id + * + * @return string + */ + public function getRegionId(); + + /** + * Get region code + * + * @return string */ - public function getRegion() - { - return $this->_get(self::KEY_REGION); - } + public function getRegionCode(); /** * Get country id * * @return string */ - public function getCountryId() - { - return $this->_get(self::KEY_COUNTRY_ID); - } + public function getCountryId(); /** * Get street * * @return string[] */ - public function getStreet() - { - return $this->_get(self::KEY_STREET); - } + public function getStreet(); /** * Get company * * @return string|null */ - public function getCompany() - { - return $this->_get(self::KEY_COMPANY); - } + public function getCompany(); /** * Get telephone number * * @return string */ - public function getTelephone() - { - return $this->_get(self::KEY_TELEPHONE); - } + public function getTelephone(); /** * Get fax number * * @return string|null */ - public function getFax() - { - return $this->_get(self::KEY_FAX); - } + public function getFax(); /** * Get postcode * * @return string */ - public function getPostcode() - { - return $this->_get(self::KEY_POSTCODE); - } + public function getPostcode(); /** * Get city name * * @return string */ - public function getCity() - { - return $this->_get(self::KEY_CITY); - } + public function getCity(); /** * Get first name * * @return string */ - public function getFirstname() - { - return $this->_get(self::KEY_FIRSTNAME); - } + public function getFirstname(); /** * Get last name * * @return string */ - public function getLastname() - { - return $this->_get(self::KEY_LASTNAME); - } + public function getLastname(); /** * Get middle name * * @return string|null */ - public function getMiddlename() - { - return $this->_get(self::KEY_MIDDLENAME); - } + public function getMiddlename(); /** * Get prefix * * @return string|null */ - public function getPrefix() - { - return $this->_get(self::KEY_PREFIX); - } + public function getPrefix(); /** * Get suffix * * @return string|null */ - public function getSuffix() - { - return $this->_get(self::KEY_SUFFIX); - } + public function getSuffix(); /** * Get Vat id * * @return string|null */ - public function getVatId() - { - return $this->_get(self::KEY_VAT_ID); - } + public function getVatId(); /** * Get customer id * * @return string|null */ - public function getCustomerId() - { - return $this->_get(self::KEY_CUSTOMER_ID); - } + public function getCustomerId(); /** * Get billing/shipping email * * @return string */ - public function getEmail() - { - return $this->_get(self::KEY_EMAIL); - } + public function getEmail(); } diff --git a/app/code/Magento/Quote/Api/Data/CartInterface.php b/app/code/Magento/Quote/Api/Data/CartInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..50df790dee2f0c836d95967402fe0df441a9b32b --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/CartInterface.php @@ -0,0 +1,151 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface CartInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Returns the cart/quote ID. + * + * @return int Cart/quote ID. + */ + public function getId(); + + /** + * Returns the cart creation date and time. + * + * @return string|null Cart creation date and time. Otherwise, null. + */ + public function getCreatedAt(); + + /** + * Returns the cart last update date and time. + * + * @return string|null Cart last update date and time. Otherwise, null. + */ + public function getUpdatedAt(); + + /** + * Returns the cart conversion date and time. + * + * @return string|null Cart conversion date and time. Otherwise, null. + */ + public function getConvertedAt(); + + /** + * Determines whether the cart is still active. + * + * @return bool|null Active status flag value. Otherwise, null. + */ + public function getIsActive(); + + /** + * Determines whether the cart is a virtual cart. + * + * A virtual cart contains virtual items. + * + * @return bool|null Virtual flag value. Otherwise, null. + */ + public function getIsVirtual(); + + /** + * Lists items in the cart. + * + * @return \Magento\Quote\Api\Data\CartItemInterface[]|null Array of items. Otherwise, null. + */ + public function getItems(); + + /** + * Returns the number of different items or products in the cart. + * + * @return int|null Number of different items or products in the cart. Otherwise, null. + */ + public function getItemsCount(); + + /** + * Returns the total quantity of all cart items. + * + * @return float|null Total quantity of all cart items. Otherwise, null. + */ + public function getItemsQty(); + + /** + * Returns information about the customer who is assigned to the cart. + * + * @return \Magento\Customer\Api\Data\CustomerInterface Information about the customer who is assigned to the cart. + */ + public function getCustomer(); + + /** + * Returns the payment method that is used to process the cart. + * + * @return string|null Payment method. Otherwise, null. + */ + public function getCheckoutMethod(); + + /** + * Returns the cart shipping address. + * + * @return \Magento\Quote\Api\Data\AddressInterface|null Cart shipping address. Otherwise, null. + */ + public function getShippingAddress(); + + /** + * Returns the cart billing address. + * + * @return \Magento\Quote\Api\Data\AddressInterface|null Cart billing address. Otherwise, null. + */ + public function getBillingAddress(); + + /** + * Returns the reserved order ID for the cart. + * + * @return string|null Reserved order ID. Otherwise, null. + */ + public function getReservedOrderId(); + + /** + * Returns the original order ID for the cart. + * + * @return string|null Original order ID. Otherwise, null. + */ + public function getOrigOrderId(); + + /** + * Returns information about quote currency, such as code, exchange rate, and so on. + * + * @return \Magento\Quote\Api\Data\CurrencyInterface|null Quote currency information. Otherwise, null. + */ + public function getCurrency(); + + /** + * True for guest customers, false for logged in customers + * + * @return bool|null + */ + public function getCustomerIsGuest(); + + /** + * Customer notice text + * + * @return string|null + */ + public function getCustomerNote(); + + /** + * Send customer notification flag + * + * @return bool|null + */ + public function getCustomerNoteNotify(); + + /** + * Get customer tax class ID. + * + * @return string|null + */ + public function getCustomerTaxClassId(); +} diff --git a/app/code/Magento/Quote/Api/Data/CartItemInterface.php b/app/code/Magento/Quote/Api/Data/CartItemInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..7e931438f86548944e6e44ba4298fc52fda22db8 --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/CartItemInterface.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface CartItemInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Returns the item ID. + * + * @return int|null Item ID. Otherwise, null. + */ + public function getItemId(); + + /** + * Returns the product SKU. + * + * @return string|null Product SKU. Otherwise, null. + */ + public function getSku(); + + /** + * Returns the product quantity. + * + * @return int Product quantity. + */ + public function getQty(); + + /** + * Returns the product name. + * + * @return string|null Product name. Otherwise, null. + */ + public function getName(); + + /** + * Returns the product price. + * + * @return float|null Product price. Otherwise, null. + */ + public function getPrice(); + + /** + * Returns the product type. + * + * @return string|null Product type. Otherwise, null. + */ + public function getProductType(); + + /** + * Returns Quote id. + * + * @return int + */ + public function getQuoteId(); +} diff --git a/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php b/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..7ffaa3fafb78215cb3e772ceaafe0430881d571e --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface CartSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface +{ + /** + * Get carts list. + * + * @return \Magento\Quote\Api\Data\CartInterface[] + */ + public function getItems(); +} diff --git a/app/code/Magento/Quote/Api/Data/CurrencyInterface.php b/app/code/Magento/Quote/Api/Data/CurrencyInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..4577709e3e9a1280a6428a705fe0099e6911c772 --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/CurrencyInterface.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface CurrencyInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Get global currency code + * + * @return string|null + */ + public function getGlobalCurrencyCode(); + + /** + * Get base currency code + * + * @return string|null + */ + public function getBaseCurrencyCode(); + + /** + * Get store currency code + * + * @return string|null + */ + public function getStoreCurrencyCode(); + + /** + * Get quote currency code + * + * @return string|null + */ + public function getQuoteCurrencyCode(); + + /** + * Get store currency to base currency rate + * + * @return float|null + */ + public function getStoreToBaseRate(); + + /** + * Get store currency to quote currency rate + * + * @return float|null + */ + public function getStoreToQuoteRate(); + + /** + * Get base currency to global currency rate + * + * @return float|null + */ + public function getBaseToGlobalRate(); + + /** + * Get base currency to quote currency rate + * + * @return float|null + */ + public function getBaseToQuoteRate(); +} diff --git a/app/code/Magento/Quote/Api/Data/PaymentInterface.php b/app/code/Magento/Quote/Api/Data/PaymentInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..c6b00bc9cd5210c8dc0fbd516541372da79c08c4 --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/PaymentInterface.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface PaymentInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Get purchase order number + * + * @return string|null + */ + public function getPoNumber(); + + /** + * Get payment method code + * + * @return string + */ + public function getMethod(); + + /** + * Get credit card owner + * + * @return string|null + */ + public function getCcOwner(); + + /** + * Get credit card number + * + * @return string|null + */ + public function getCcNumber(); + + /** + * Get credit card type + * + * @return string|null + */ + public function getCcType(); + + /** + * Get credit card expiration year + * + * @return string|null + */ + public function getCcExpYear(); + + /** + * Get credit card expiration month + * + * @return string|null + */ + public function getCcExpMonth(); + + /** + * Get payment additional details + * + * @return string[]|null + */ + public function getAdditionalData(); +} diff --git a/app/code/Magento/Quote/Api/Data/PaymentMethodInterface.php b/app/code/Magento/Quote/Api/Data/PaymentMethodInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..3be900400f305ed076761bfab80a498dd7637d24 --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/PaymentMethodInterface.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface PaymentMethodInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Get payment method code + * + * @return string + */ + public function getCode(); + + /** + * Get payment method title + * + * @return string + */ + public function getTitle(); +} diff --git a/app/code/Magento/Quote/Api/Data/ShippingMethodInterface.php b/app/code/Magento/Quote/Api/Data/ShippingMethodInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..62dafce5a1dce5b5541d9c851fb3ea3c85b20e8e --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/ShippingMethodInterface.php @@ -0,0 +1,94 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface ShippingMethodInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Shipping carrier code. + */ + const CARRIER_CODE = 'carrier_code'; + + /** + * Shipping method code. + */ + const METHOD_CODE = 'method_code'; + + /** + * Shipping carrier title. + */ + const CARRIER_TITLE = 'carrier_title'; + + /** + * Shipping method title. + */ + const METHOD_TITLE = 'method_title'; + + /** + * Shipping amount in store currency. + */ + const SHIPPING_AMOUNT = 'amount'; + + /** + * Shipping amount in base currency. + */ + const BASE_SHIPPING_AMOUNT = 'base_amount'; + + /** + * Available. + */ + const AVAILABLE = 'available'; + + /** + * Returns the shipping carrier code. + * + * @return string Shipping carrier code. + */ + public function getCarrierCode(); + + /** + * Returns the shipping method code. + * + * @return string Shipping method code. + */ + public function getMethodCode(); + + /** + * Returns the shipping carrier title. + * + * @return string|null Shipping carrier title. Otherwise, null. + */ + public function getCarrierTitle(); + + /** + * Returns the shipping method title. + * + * @return string|null Shipping method title. Otherwise, null. + */ + public function getMethodTitle(); + + /** + * Returns the shipping amount in store currency. + * + * @return float Shipping amount in store currency. + */ + public function getAmount(); + + /** + * Returns the shipping amount in base currency. + * + * @return float Shipping amount in base currency. + */ + public function getBaseAmount(); + + /** + * Returns the value of the availability flag for the current shipping method. + * + * @return bool + * @SuppressWarnings(PHPMD.BooleanGetMethodName) + */ + public function getAvailable(); +} diff --git a/app/code/Magento/Quote/Api/Data/TotalsInterface.php b/app/code/Magento/Quote/Api/Data/TotalsInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..a07bd69c683f4d365b97a524530759ad3c40392f --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/TotalsInterface.php @@ -0,0 +1,170 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface TotalsInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Get grand total in quote currency + * + * @return float|null + */ + public function getGrandTotal(); + + /** + * Get grand total in base currency + * + * @return float|null + */ + public function getBaseGrandTotal(); + + /** + * Get subtotal in quote currency + * + * @return float|null + */ + public function getSubtotal(); + + /** + * Get subtotal in base currency + * + * @return float|null + */ + public function getBaseSubtotal(); + + /** + * Get discount amount in quote currency + * + * @return float|null + */ + public function getDiscountAmount(); + + /** + * Get discount amount in base currency + * + * @return float|null + */ + public function getBaseDiscountAmount(); + + /** + * Get subtotal in quote currency with applied discount + * + * @return float|null + */ + public function getSubtotalWithDiscount(); + + /** + * Get subtotal in base currency with applied discount + * + * @return float|null + */ + public function getBaseSubtotalWithDiscount(); + + /** + * Get shipping amount in quote currency + * + * @return float|null + */ + public function getShippingAmount(); + + /** + * Get shipping amount in base currency + * + * @return float|null + */ + public function getBaseShippingAmount(); + + /** + * Get shipping discount amount in quote currency + * + * @return float|null + */ + public function getShippingDiscountAmount(); + + /** + * Get shipping discount amount in base currency + * + * @return float|null + */ + public function getBaseShippingDiscountAmount(); + + /** + * Get tax amount in quote currency + * + * @return float|null + */ + public function getTaxAmount(); + + /** + * Get tax amount in base currency + * + * @return float|null + */ + public function getBaseTaxAmount(); + + /** + * Get shipping tax amount in quote currency + * + * @return float|null + */ + public function getShippingTaxAmount(); + + /** + * Get shipping tax amount in base currency + * + * @return float|null + */ + public function getBaseShippingTaxAmount(); + + /** + * Get subtotal including tax in quote currency + * + * @return float|null + */ + public function getSubtotalInclTax(); + + /** + * Get subtotal including tax in base currency + * + * @return float|null + */ + public function getBaseSubtotalInclTax(); + + /** + * Get shipping including tax in quote currency + * + * @return float|null + */ + public function getShippingInclTax(); + + /** + * Get shipping including tax in base currency + * + * @return float|null + */ + public function getBaseShippingInclTax(); + + /** + * Get base currency code + * + * @return string|null + */ + public function getBaseCurrencyCode(); + + /** + * Get quote currency code + * + * @return string|null + */ + public function getQuoteCurrencyCode(); + + /** + * Get totals by items + * + * @return \Magento\Quote\Api\Data\TotalsItemInterface[]|null + */ + public function getItems(); +} diff --git a/app/code/Magento/Quote/Api/Data/TotalsItemInterface.php b/app/code/Magento/Quote/Api/Data/TotalsItemInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..c600c7bc2cbffb81a55a9e9510b844b8fd8d2184 --- /dev/null +++ b/app/code/Magento/Quote/Api/Data/TotalsItemInterface.php @@ -0,0 +1,121 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api\Data; + +interface TotalsItemInterface extends \Magento\Framework\Api\ExtensibleDataInterface +{ + /** + * Returns the item price in quote currency. + * + * @return float Item price in quote currency. + */ + public function getPrice(); + + /** + * Returns the item price in base currency. + * + * @return float Item price in base currency. + */ + public function getBasePrice(); + + /** + * Returns the item quantity. + * + * @return int Item quantity. + */ + public function getQty(); + + /** + * Returns the row total in quote currency. + * + * @return float Row total in quote currency. + */ + public function getRowTotal(); + + /** + * Returns the row total in base currency. + * + * @return float Row total in base currency. + */ + public function getBaseRowTotal(); + + /** + * Returns the row total with discount in quote currency. + * + * @return float|null Row total with discount in quote currency. Otherwise, null. + */ + public function getRowTotalWithDiscount(); + + /** + * Returns the tax amount in quote currency. + * + * @return float|null Tax amount in quote currency. Otherwise, null. + */ + public function getTaxAmount(); + + /** + * Returns the tax amount in base currency. + * + * @return float|null Tax amount in base currency. Otherwise, null. + */ + public function getBaseTaxAmount(); + + /** + * Returns the tax percent. + * + * @return int|null Tax percent. Otherwise, null. + */ + public function getTaxPercent(); + + /** + * Returns the discount amount in quote currency. + * + * @return float|null Discount amount in quote currency. Otherwise, null. + */ + public function getDiscountAmount(); + + /** + * Returns the discount amount in base currency. + * + * @return float|null Discount amount in base currency. Otherwise, null. + */ + public function getBaseDiscountAmount(); + + /** + * Returns the discount percent. + * + * @return int|null Discount percent. Otherwise, null. + */ + public function getDiscountPercent(); + + /** + * Returns the price including tax in quote currency. + * + * @return float|null Price including tax in quote currency. Otherwise, null. + */ + public function getPriceInclTax(); + + /** + * Returns the price including tax in base currency. + * + * @return float|null Price including tax in base currency. Otherwise, null. + */ + public function getBasePriceInclTax(); + + /** + * Returns the row total including tax in quote currency. + * + * @return float|null Row total including tax in quote currency. Otherwise, null. + */ + public function getRowTotalInclTax(); + + /** + * Returns the row total including tax in base currency. + * + * @return float|null Row total including tax in base currency. Otherwise, null. + */ + public function getBaseRowTotalInclTax(); +} diff --git a/app/code/Magento/Quote/Api/PaymentMethodManagementInterface.php b/app/code/Magento/Quote/Api/PaymentMethodManagementInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..47fa55271c3c86742b444c7ba8d684516c7fd460 --- /dev/null +++ b/app/code/Magento/Quote/Api/PaymentMethodManagementInterface.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api; + +interface PaymentMethodManagementInterface +{ + /** + * Adds a specified payment method to a specified shopping cart. + * + * @param int $cartId The cart ID. + * @param \Magento\Quote\Api\Data\PaymentInterface $method The payment method. + * @return int Payment method ID. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + * @throws \Magento\Framework\Exception\State\InvalidTransitionException The billing or shipping address + * is not set, or the specified payment method is not available. + */ + public function set($cartId, \Magento\Quote\Api\Data\PaymentInterface $method); + + /** + * Returns the payment method for a specified shopping cart. + * + * @param int $cartId The cart ID. + * @return \Magento\Quote\Api\Data\PaymentInterface Payment method object. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + */ + public function get($cartId); + + /** + * Lists available payment methods for a specified shopping cart. + * + * @param int $cartId The cart ID. + * @return \Magento\Quote\Api\Data\PaymentMethodInterface[] Array of payment methods. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + */ + public function getList($cartId); +} diff --git a/app/code/Magento/Quote/Api/ShippingAddressManagementInterface.php b/app/code/Magento/Quote/Api/ShippingAddressManagementInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..c6fda8942d5b5a4006e47636b4873517501c1ed2 --- /dev/null +++ b/app/code/Magento/Quote/Api/ShippingAddressManagementInterface.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api; + +interface ShippingAddressManagementInterface +{ + /** + * Assigns a specified shipping address to a specified cart. + * + * @param int $cartId The cart ID. + * @param \Magento\Quote\Api\Data\AddressInterface $address The shipping address data. + * @return int Address ID. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + * @throws \Magento\Framework\Exception\InputException The specified cart ID or address data is not valid. + */ + public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address); + + /** + * Returns the shipping address for a specified quote. + * + * @param int $cartId The cart ID. + * @return \Magento\Quote\Api\Data\AddressInterface Shipping address object. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. + */ + public function get($cartId); +} diff --git a/app/code/Magento/Quote/Api/ShippingMethodManagementInterface.php b/app/code/Magento/Quote/Api/ShippingMethodManagementInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..9e7577a8f69614c328b50239b5fa9ef84032d571 --- /dev/null +++ b/app/code/Magento/Quote/Api/ShippingMethodManagementInterface.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Api; + +interface ShippingMethodManagementInterface +{ + /** + * Sets the carrier and shipping methods codes for a specified cart. + * + * @param int $cartId The shopping cart ID. + * @param string $carrierCode The carrier code. + * @param string $methodCode The shipping method code. + * @return bool + * @throws \Magento\Framework\Exception\InputException The shipping method is not valid for an empty cart. + * @throws \Magento\Framework\Exception\CouldNotSaveException The shipping method could not be saved. + * @throws \Magento\Framework\Exception\StateException The billing or shipping address is not set. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart contains only virtual products + * so the shipping method does not apply. + */ + public function set($cartId, $carrierCode, $methodCode); + + /** + * Returns selected shipping method for a specified quote. + * + * @param int $cartId The shopping cart ID. + * @return \Magento\Quote\Api\Data\ShippingMethodInterface Shipping method. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified shopping cart does not exist. + * @throws \Magento\Framework\Exception\StateException The shipping address is not set. + */ + public function get($cartId); + + /** + * Lists applicable shipping methods for a specified quote. + * + * @param int $cartId The shopping cart ID. + * @return \Magento\Quote\Api\Data\ShippingMethodInterface[] An array of shipping methods. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified quote does not exist. + * @throws \Magento\Framework\Exception\StateException The shipping address is not set. + */ + public function getList($cartId); +} diff --git a/app/code/Magento/Quote/Model/BillingAddressManagement.php b/app/code/Magento/Quote/Model/BillingAddressManagement.php new file mode 100644 index 0000000000000000000000000000000000000000..5e5140fc9e749bc5a05a04d3ccd79e73478c3a3a --- /dev/null +++ b/app/code/Magento/Quote/Model/BillingAddressManagement.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model; + +use Magento\Quote\Model\QuoteRepository; +use Magento\Framework\Exception\InputException; +use Psr\Log\LoggerInterface as Logger; +use Magento\Quote\Api\BillingAddressManagementInterface; + +/** Quote billing address write service object. */ +class BillingAddressManagement implements BillingAddressManagementInterface +{ + /** + * Validator. + * + * @var QuoteAddressValidator + */ + protected $addressValidator; + + /** + * Logger. + * + * @var Logger + */ + protected $logger; + + /** + * Quote repository. + * + * @var QuoteRepository + */ + protected $quoteRepository; + + /** + * Constructs a quote billing address service object. + * + * @param QuoteRepository $quoteRepository Quote repository. + * @param QuoteAddressValidator $addressValidator Address validator. + * @param Logger $logger Logger. + */ + public function __construct( + QuoteRepository $quoteRepository, + QuoteAddressValidator $addressValidator, + Logger $logger + ) { + $this->addressValidator = $addressValidator; + $this->logger = $logger; + $this->quoteRepository = $quoteRepository; + } + + /** + * {@inheritDoc} + */ + public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address) + { + $quote = $this->quoteRepository->getActive($cartId); + $this->addressValidator->validate($address); + $quote->setBillingAddress($address); + $quote->setDataChanges(true); + try { + $this->quoteRepository->save($quote); + } catch (\Exception $e) { + $this->logger->critical($e); + throw new InputException('Unable to save address. Please, check input data.'); + } + return $quote->getBillingAddress()->getId(); + } + + /** + * {@inheritDoc} + */ + public function get($cartId) + { + $cart = $this->quoteRepository->getActive($cartId); + return $cart->getBillingAddress(); + } +} diff --git a/app/code/Magento/Checkout/Model/Cart/Access/WritePlugin.php b/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php similarity index 81% rename from app/code/Magento/Checkout/Model/Cart/Access/WritePlugin.php rename to app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php index ee735b2e2aecb1ae8badeccd06270ee171ad0ca3..f46eee82917f5701cfd5c90a815b3a1c696e56ae 100644 --- a/app/code/Magento/Checkout/Model/Cart/Access/WritePlugin.php +++ b/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php @@ -4,12 +4,12 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Model\Cart\Access; +namespace Magento\Quote\Model\Cart\Access; use Magento\Framework\Exception\AuthorizationException; use Magento\Authorization\Model\UserContextInterface; -class WritePlugin +class CartManagementPlugin { /** * @var UserContextInterface @@ -35,18 +35,20 @@ class WritePlugin /** * Check whether access is allowed for create cart resource * - * @param \Magento\Checkout\Service\V1\Cart\WriteServiceInterface $subject + * @param \Magento\Quote\Api\CartManagementInterface $subject * @param int $cartId * @param int $customerId + * @param int $storeId * * @return void * @throws AuthorizationException if access denied * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeAssignCustomer( - \Magento\Checkout\Service\V1\Cart\WriteServiceInterface $subject, + \Magento\Quote\Api\CartManagementInterface $subject, $cartId, - $customerId + $customerId, + $storeId ) { if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { throw new AuthorizationException('Access denied'); diff --git a/app/code/Magento/Checkout/Model/Cart/Access/ReadPlugin.php b/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php similarity index 78% rename from app/code/Magento/Checkout/Model/Cart/Access/ReadPlugin.php rename to app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php index 3424273af6b570c7abfa8f7e4e32a722c403d45c..562332c96dcf6c5161ffa3384820484282900310 100644 --- a/app/code/Magento/Checkout/Model/Cart/Access/ReadPlugin.php +++ b/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php @@ -4,13 +4,13 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Model\Cart\Access; +namespace Magento\Quote\Model\Cart\Access; use Magento\Framework\Api\SearchCriteria; use Magento\Framework\Exception\AuthorizationException; use Magento\Authorization\Model\UserContextInterface; -class ReadPlugin +class CartRepositoryPlugin { /** * @var UserContextInterface @@ -36,15 +36,15 @@ class ReadPlugin /** * Check whether access is allowed for cart resource * - * @param \Magento\Checkout\Service\V1\Cart\ReadServiceInterface $subject + * @param \Magento\Quote\Api\CartRepositoryInterface $subject * @param int $cartId * * @return void * @throws AuthorizationException if access denied * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeGetCart( - \Magento\Checkout\Service\V1\Cart\ReadServiceInterface $subject, + public function beforeGet( + \Magento\Quote\Api\CartRepositoryInterface $subject, $cartId ) { if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { @@ -55,15 +55,15 @@ class ReadPlugin /** * Check whether access is allowed for cart list resource * - * @param \Magento\Checkout\Service\V1\Cart\ReadServiceInterface $subject + * @param \Magento\Quote\Api\CartRepositoryInterface $subject * @param SearchCriteria $searchCriteria * * @return void * @throws AuthorizationException if access denied * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeGetCartList( - \Magento\Checkout\Service\V1\Cart\ReadServiceInterface $subject, + public function beforeGetList( + \Magento\Quote\Api\CartRepositoryInterface $subject, SearchCriteria $searchCriteria ) { if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { diff --git a/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php b/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php new file mode 100644 index 0000000000000000000000000000000000000000..e0eda7e9b1c20ca8efd1b83afac2c0a6e601ba73 --- /dev/null +++ b/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php @@ -0,0 +1,66 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model\Cart; + +use Magento\Quote\Api; +use Magento\Quote\Model\QuoteRepository; +use Magento\Quote\Api\CartTotalRepositoryInterface; + +/** + * Cart totals data object. + */ +class CartTotalRepository implements CartTotalRepositoryInterface +{ + /** + * Cart totals builder. + * + * @var Api\Data\TotalsDataBuilder + */ + private $totalsBuilder; + + /** + * Quote repository. + * + * @var QuoteRepository + */ + private $quoteRepository; + + /** + * Constructs a cart totals data object. + * + * @param Api\Data\TotalsDataBuilder $totalsBuilder Cart totals builder. + * @param QuoteRepository $quoteRepository Quote repository. + */ + public function __construct( + Api\Data\TotalsDataBuilder $totalsBuilder, + QuoteRepository $quoteRepository + ) { + $this->totalsBuilder = $totalsBuilder; + $this->quoteRepository = $quoteRepository; + } + + /** + * {@inheritDoc} + * + * @param int $cartId The cart ID. + * @return Totals Quote totals data. + */ + public function get($cartId) + { + /** + * Quote. + * + * @var \Magento\Quote\Model\Quote $quote + */ + $quote = $this->quoteRepository->getActive($cartId); + $shippingAddress = $quote->getShippingAddress(); + $totals = array_merge($shippingAddress->getData(), $quote->getData()); + $this->totalsBuilder->populateWithArray($totals); + $this->totalsBuilder->setItems($quote->getAllItems()); + + return $this->totalsBuilder->create(); + } +} diff --git a/app/code/Magento/Quote/Model/Cart/Currency.php b/app/code/Magento/Quote/Model/Cart/Currency.php new file mode 100644 index 0000000000000000000000000000000000000000..343d02d04638b0de280f0f14849e1fcf02741697 --- /dev/null +++ b/app/code/Magento/Quote/Model/Cart/Currency.php @@ -0,0 +1,77 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model\Cart; + +/** + * @codeCoverageIgnore + */ +class Currency extends \Magento\Framework\Model\AbstractExtensibleModel implements + \Magento\Quote\Api\Data\CurrencyInterface +{ + /** + * {@inheritdoc} + */ + public function getGlobalCurrencyCode() + { + return $this->getData('global_currency_code'); + } + + /** + * {@inheritdoc} + */ + public function getBaseCurrencyCode() + { + return $this->getData('base_currency_code'); + } + + /** + * {@inheritdoc} + */ + public function getStoreCurrencyCode() + { + return $this->getData('store_currency_code'); + } + + /** + * {@inheritdoc} + */ + public function getQuoteCurrencyCode() + { + return $this->getData('quote_currency_code'); + } + + /** + * {@inheritdoc} + */ + public function getStoreToBaseRate() + { + return $this->getData('store_to_base_rate'); + } + + /** + * {@inheritdoc} + */ + public function getStoreToQuoteRate() + { + return $this->getData('store_to_quote_rate'); + } + + /** + * {@inheritdoc} + */ + public function getBaseToGlobalRate() + { + return $this->getData('base_to_global_rate'); + } + + /** + * {@inheritdoc} + */ + public function getBaseToQuoteRate() + { + return $this->getData('base_to_quote_rate'); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethod.php b/app/code/Magento/Quote/Model/Cart/ShippingMethod.php similarity index 72% rename from app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethod.php rename to app/code/Magento/Quote/Model/Cart/ShippingMethod.php index 1b821b603db8a1fb4d319745b6f7e53f43e2506b..7d12d08caa4826d9af91d9c9a52645cc8a36949c 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethod.php +++ b/app/code/Magento/Quote/Model/Cart/ShippingMethod.php @@ -3,50 +3,18 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Data\Cart; +namespace Magento\Quote\Model\Cart; + +use Magento\Quote\Api\Data\ShippingMethodInterface; /** * Quote shipping method data. * * @codeCoverageIgnore */ -class ShippingMethod extends \Magento\Framework\Api\AbstractExtensibleObject +class ShippingMethod extends \Magento\Framework\Api\AbstractExtensibleObject implements + ShippingMethodInterface { - /** - * Shipping carrier code. - */ - const CARRIER_CODE = 'carrier_code'; - - /** - * Shipping method code. - */ - const METHOD_CODE = 'method_code'; - - /** - * Shipping carrier title. - */ - const CARRIER_TITLE = 'carrier_title'; - - /** - * Shipping method title. - */ - const METHOD_TITLE = 'method_title'; - - /** - * Shipping amount in store currency. - */ - const SHIPPING_AMOUNT = 'amount'; - - /** - * Shipping amount in base currency. - */ - const BASE_SHIPPING_AMOUNT = 'base_amount'; - - /** - * Available. - */ - const AVAILABLE = 'available'; - /** * Returns the shipping carrier code. * diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php b/app/code/Magento/Quote/Model/Cart/ShippingMethodConverter.php similarity index 87% rename from app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php rename to app/code/Magento/Quote/Model/Cart/ShippingMethodConverter.php index b232b4629deb7ce6b41c1233c5806e48b8ea1af2..6a41f4a20ab267a29788320f4a600e5b56d2f435 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php +++ b/app/code/Magento/Quote/Model/Cart/ShippingMethodConverter.php @@ -3,30 +3,29 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Data\Cart; +namespace Magento\Quote\Model\Cart; /** * Quote shipping method data. * - * @codeCoverageIgnore */ class ShippingMethodConverter { /** * Shipping method builder. * - * @var ShippingMethodBuilder + * @var \Magento\Quote\Api\Data\ShippingMethodDataBuilder */ protected $builder; /** * Constructs a shipping method builder object. * - * @param ShippingMethodBuilder $builder Shipping method builder. + * @param \Magento\Quote\Api\Data\ShippingMethodDataBuilder $builder Shipping method builder. * @param \Magento\Store\Model\StoreManagerInterface $storeManager Store manager interface. */ public function __construct( - \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $builder, + \Magento\Quote\Api\Data\ShippingMethodDataBuilder $builder, \Magento\Store\Model\StoreManagerInterface $storeManager ) { $this->builder = $builder; diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals.php b/app/code/Magento/Quote/Model/Cart/Totals.php similarity index 75% rename from app/code/Magento/Checkout/Service/V1/Data/Cart/Totals.php rename to app/code/Magento/Quote/Model/Cart/Totals.php index f76f1e115a567ae1832c096140837464bb2e834b..db3783fe0a9bb1a6330e3d2ce112318a0bbf9f60 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals.php +++ b/app/code/Magento/Quote/Model/Cart/Totals.php @@ -3,14 +3,17 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Data\Cart; +namespace Magento\Quote\Model\Cart; + +use Magento\Quote\Api\Data\TotalsInterface; +use Magento\Framework\Model\AbstractExtensibleModel; /** * Cart Totals * * @codeCoverageIgnore */ -class Totals extends \Magento\Framework\Api\AbstractExtensibleObject +class Totals extends AbstractExtensibleModel implements TotalsInterface { /* TOTALS */ const GRAND_TOTAL = 'grand_total'; @@ -54,7 +57,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getGrandTotal() { - return $this->_get(self::GRAND_TOTAL); + return $this->getData(self::GRAND_TOTAL); } /** @@ -64,7 +67,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseGrandTotal() { - return $this->_get(self::BASE_GRAND_TOTAL); + return $this->getData(self::BASE_GRAND_TOTAL); } /** @@ -74,7 +77,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getSubtotal() { - return $this->_get(self::SUBTOTAL); + return $this->getData(self::SUBTOTAL); } /** @@ -84,7 +87,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseSubtotal() { - return $this->_get(self::BASE_SUBTOTAL); + return $this->getData(self::BASE_SUBTOTAL); } /** @@ -94,7 +97,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getDiscountAmount() { - return $this->_get(self::DISCOUNT_AMOUNT); + return $this->getData(self::DISCOUNT_AMOUNT); } /** @@ -104,7 +107,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseDiscountAmount() { - return $this->_get(self::BASE_DISCOUNT_AMOUNT); + return $this->getData(self::BASE_DISCOUNT_AMOUNT); } /** @@ -114,7 +117,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getSubtotalWithDiscount() { - return $this->_get(self::SUBTOTAL_WITH_DISCOUNT); + return $this->getData(self::SUBTOTAL_WITH_DISCOUNT); } /** @@ -124,7 +127,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseSubtotalWithDiscount() { - return $this->_get(self::BASE_SUBTOTAL_WITH_DISCOUNT); + return $this->getData(self::BASE_SUBTOTAL_WITH_DISCOUNT); } /** @@ -134,7 +137,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getShippingAmount() { - return $this->_get(self::SHIPPING_AMOUNT); + return $this->getData(self::SHIPPING_AMOUNT); } /** @@ -144,7 +147,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseShippingAmount() { - return $this->_get(self::BASE_SHIPPING_AMOUNT); + return $this->getData(self::BASE_SHIPPING_AMOUNT); } /** @@ -154,7 +157,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getShippingDiscountAmount() { - return $this->_get(self::SHIPPING_DISCOUNT_AMOUNT); + return $this->getData(self::SHIPPING_DISCOUNT_AMOUNT); } /** @@ -164,7 +167,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseShippingDiscountAmount() { - return $this->_get(self::BASE_SHIPPING_DISCOUNT_AMOUNT); + return $this->getData(self::BASE_SHIPPING_DISCOUNT_AMOUNT); } /** @@ -174,7 +177,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getTaxAmount() { - return $this->_get(self::TAX_AMOUNT); + return $this->getData(self::TAX_AMOUNT); } /** @@ -184,7 +187,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseTaxAmount() { - return $this->_get(self::BASE_TAX_AMOUNT); + return $this->getData(self::BASE_TAX_AMOUNT); } /** @@ -194,7 +197,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getShippingTaxAmount() { - return $this->_get(self::SHIPPING_TAX_AMOUNT); + return $this->getData(self::SHIPPING_TAX_AMOUNT); } /** @@ -204,7 +207,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseShippingTaxAmount() { - return $this->_get(self::BASE_SHIPPING_TAX_AMOUNT); + return $this->getData(self::BASE_SHIPPING_TAX_AMOUNT); } /** @@ -214,7 +217,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getSubtotalInclTax() { - return $this->_get(self::SUBTOTAL_INCL_TAX); + return $this->getData(self::SUBTOTAL_INCL_TAX); } /** @@ -224,7 +227,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseSubtotalInclTax() { - return $this->_get(self::BASE_SUBTOTAL_INCL_TAX); + return $this->getData(self::BASE_SUBTOTAL_INCL_TAX); } /** @@ -234,7 +237,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getShippingInclTax() { - return $this->_get(self::SHIPPING_INCL_TAX); + return $this->getData(self::SHIPPING_INCL_TAX); } /** @@ -244,7 +247,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseShippingInclTax() { - return $this->_get(self::BASE_SHIPPING_INCL_TAX); + return $this->getData(self::BASE_SHIPPING_INCL_TAX); } /** @@ -254,7 +257,7 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getBaseCurrencyCode() { - return $this->_get(self::BASE_CURRENCY_CODE); + return $this->getData(self::BASE_CURRENCY_CODE); } /** @@ -264,16 +267,16 @@ class Totals extends \Magento\Framework\Api\AbstractExtensibleObject */ public function getQuoteCurrencyCode() { - return $this->_get(self::QUOTE_CURRENCY_CODE); + return $this->getData(self::QUOTE_CURRENCY_CODE); } /** * Get totals by items * - * @return \Magento\Checkout\Service\V1\Data\Cart\Totals\Item[]|null + * @return \Magento\Quote\Api\Data\TotalsItemInterface[]|null */ public function getItems() { - return $this->_get(self::ITEMS); + return $this->getData(self::ITEMS); } } diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals/Item.php b/app/code/Magento/Quote/Model/Cart/Totals/Item.php similarity index 96% rename from app/code/Magento/Checkout/Service/V1/Data/Cart/Totals/Item.php rename to app/code/Magento/Quote/Model/Cart/Totals/Item.php index 7d81c3f85a756fc2cf383d0d84960dbaae937ad1..0ebed2fbadd184d086948f10d8f1f5b3ae4f2860 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals/Item.php +++ b/app/code/Magento/Quote/Model/Cart/Totals/Item.php @@ -3,14 +3,17 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Data\Cart\Totals; +namespace Magento\Quote\Model\Cart\Totals; + +use Magento\Quote\Api\Data\TotalsItemInterface; +use Magento\Framework\Api\AbstractExtensibleObject; /** * Cart item totals. * * @codeCoverageIgnore */ -class Item extends \Magento\Framework\Api\AbstractExtensibleObject +class Item extends AbstractExtensibleObject implements TotalsItemInterface { /** * Price. diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php b/app/code/Magento/Quote/Model/CouponManagement.php similarity index 61% rename from app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php rename to app/code/Magento/Quote/Model/CouponManagement.php index 7ce08e5e3f6cee785ffafb7a4291b17c417245b7..dc9fb49b6eacb87861b3fc8f0c468aacf8c9e5af 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php +++ b/app/code/Magento/Quote/Model/CouponManagement.php @@ -1,19 +1,21 @@ <?php /** + * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Coupon; -use Magento\Checkout\Service\V1\Data\Cart\CouponBuilder as CouponBuilder; +namespace Magento\Quote\Model; + +use \Magento\Quote\Api\CouponManagementInterface; use Magento\Framework\Exception\CouldNotDeleteException; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\NoSuchEntityException; /** - * Coupon write service object. + * Coupon management object. */ -class WriteService implements WriteServiceInterface +class CouponManagement implements CouponManagementInterface { /** * Quote repository. @@ -23,36 +25,30 @@ class WriteService implements WriteServiceInterface protected $quoteRepository; /** - * Coupon builder. - * - * @var CouponBuilder - */ - protected $couponBuilder; - - /** - * Constructs a coupon write service object. + * Constructs a coupon read service object. * * @param \Magento\Quote\Model\QuoteRepository $quoteRepository Quote repository. - * @param CouponBuilder $couponBuilder Coupon builder. */ public function __construct( - \Magento\Quote\Model\QuoteRepository $quoteRepository, - CouponBuilder $couponBuilder + \Magento\Quote\Model\QuoteRepository $quoteRepository ) { $this->quoteRepository = $quoteRepository; - $this->couponBuilder = $couponBuilder; } /** * {@inheritdoc} - * - * @param int $cartId The cart ID. - * @param \Magento\Checkout\Service\V1\Data\Cart\Coupon $couponCodeData The coupon code data. - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\CouldNotSaveException The specified coupon could not be added. */ - public function set($cartId, \Magento\Checkout\Service\V1\Data\Cart\Coupon $couponCodeData) + public function get($cartId) + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + return $quote->getCouponCode(); + } + + /** + * {@inheritdoc} + */ + public function set($cartId, $couponCode) { /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); @@ -60,7 +56,6 @@ class WriteService implements WriteServiceInterface throw new NoSuchEntityException("Cart $cartId doesn't contain products"); } $quote->getShippingAddress()->setCollectShippingRates(true); - $couponCode = trim($couponCodeData->getCouponCode()); try { $quote->setCouponCode($couponCode); @@ -76,13 +71,8 @@ class WriteService implements WriteServiceInterface /** * {@inheritdoc} - * - * @param int $cartId The cart ID. - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist. - * @throws \Magento\Framework\Exception\CouldNotDeleteException The specified coupon could not be deleted. */ - public function delete($cartId) + public function remove($cartId) { /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); diff --git a/app/code/Magento/Quote/Model/PaymentMethodManagement.php b/app/code/Magento/Quote/Model/PaymentMethodManagement.php new file mode 100644 index 0000000000000000000000000000000000000000..37a61c905ff4f160f3e3c873fe3d6a46e15344d4 --- /dev/null +++ b/app/code/Magento/Quote/Model/PaymentMethodManagement.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model; + +use Magento\Framework\Exception\State\InvalidTransitionException; + +class PaymentMethodManagement implements \Magento\Quote\Api\PaymentMethodManagementInterface +{ + /** + * @var \Magento\Quote\Model\QuoteRepository + */ + protected $quoteRepository; + + /** + * @var \Magento\Payment\Model\Checks\ZeroTotal + */ + protected $zeroTotalValidator; + + /** + * @var \Magento\Payment\Model\MethodList + */ + protected $methodList; + + /** + * @param QuoteRepository $quoteRepository + * @param \Magento\Payment\Model\Checks\ZeroTotal $zeroTotalValidator + * @param \Magento\Payment\Model\MethodList $methodList + */ + public function __construct( + \Magento\Quote\Model\QuoteRepository $quoteRepository, + \Magento\Payment\Model\Checks\ZeroTotal $zeroTotalValidator, + \Magento\Payment\Model\MethodList $methodList + ) { + $this->quoteRepository = $quoteRepository; + $this->zeroTotalValidator = $zeroTotalValidator; + $this->methodList = $methodList; + } + + /** + * {@inheritdoc} + */ + public function set($cartId, \Magento\Quote\Api\Data\PaymentInterface $method) + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + + $method->setChecks([ + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, + ]); + $payment = $quote->getPayment(); + $payment->importData($method->getData()); + + if ($quote->isVirtual()) { + // check if billing address is set + if (is_null($quote->getBillingAddress()->getCountryId())) { + throw new InvalidTransitionException('Billing address is not set'); + } + $quote->getBillingAddress()->setPaymentMethod($payment->getMethod()); + } else { + // check if shipping address is set + if (is_null($quote->getShippingAddress()->getCountryId())) { + throw new InvalidTransitionException('Shipping address is not set'); + } + $quote->getShippingAddress()->setPaymentMethod($payment->getMethod()); + } + if (!$quote->isVirtual() && $quote->getShippingAddress()) { + $quote->getShippingAddress()->setCollectShippingRates(true); + } + + if (!$this->zeroTotalValidator->isApplicable($payment->getMethodInstance(), $quote)) { + throw new InvalidTransitionException('The requested Payment Method is not available.'); + } + + $quote->setTotalsCollectedFlag(false)->collectTotals()->save(); + return $quote->getPayment()->getId(); + } + + /** + * {@inheritdoc} + */ + public function get($cartId) + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + $payment = $quote->getPayment(); + if (!$payment->getId()) { + return null; + } + return $payment; + } + + /** + * {@inheritdoc} + */ + public function getList($cartId) + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + return $this->methodList->getAvailableMethods($quote); + } +} diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index 16c402d18bf8344fb057fb6dc35119b11c536c68..9b46dff721101aad8a071638b96c6fc757fd7ee2 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -10,10 +10,11 @@ namespace Magento\Quote\Model; use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Api\Data\GroupInterface; -use Magento\Framework\Model\AbstractModel; +use Magento\Framework\Model\AbstractExtensibleModel; use Magento\Quote\Model\Quote\Address; use Magento\Sales\Model\Resource; use Magento\Sales\Model\Status; +use Magento\Framework\Api\AttributeDataBuilder; /** * Quote model @@ -26,22 +27,15 @@ use Magento\Sales\Model\Status; * sales_quote_delete_after * * @method Quote setStoreId(int $value) - * @method string getCreatedAt() * @method Quote setCreatedAt(string $value) - * @method string getUpdatedAt() * @method Quote setUpdatedAt(string $value) - * @method string getConvertedAt() * @method Quote setConvertedAt(string $value) - * @method int getIsActive() * @method Quote setIsActive(int $value) * @method Quote setIsVirtual(int $value) * @method int getIsMultiShipping() * @method Quote setIsMultiShipping(int $value) - * @method int getItemsCount() * @method Quote setItemsCount(int $value) - * @method float getItemsQty() * @method Quote setItemsQty(float $value) - * @method int getOrigOrderId() * @method Quote setOrigOrderId(int $value) * @method float getStoreToBaseRate() * @method Quote setStoreToBaseRate(float $value) @@ -76,17 +70,13 @@ use Magento\Sales\Model\Status; * @method Quote setCustomerSuffix(string $value) * @method string getCustomerDob() * @method Quote setCustomerDob(string $value) - * @method string getCustomerNote() * @method Quote setCustomerNote(string $value) - * @method int getCustomerNoteNotify() * @method Quote setCustomerNoteNotify(int $value) - * @method int getCustomerIsGuest() * @method Quote setCustomerIsGuest(int $value) * @method string getRemoteIp() * @method Quote setRemoteIp(string $value) * @method string getAppliedRuleIds() * @method Quote setAppliedRuleIds(string $value) - * @method string getReservedOrderId() * @method Quote setReservedOrderId(string $value) * @method string getPasswordHash() * @method Quote setPasswordHash(string $value) @@ -127,7 +117,7 @@ use Magento\Sales\Model\Status; * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Quote extends \Magento\Framework\Model\AbstractModel +class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\CartInterface { /** * Checkout login method key @@ -335,10 +325,17 @@ class Quote extends \Magento\Framework\Model\AbstractModel */ protected $customerRepository; + /** + * @var Cart\CurrencyFactory + */ + protected $currencyFactory; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Quote\Model\QuoteValidator $quoteValidator + * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param AttributeDataBuilder $customAttributeBuilder + * @param QuoteValidator $quoteValidator * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -364,6 +361,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel * @param \Magento\Customer\Api\Data\CustomerDataBuilder $customerBuilder * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository * @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter + * @param Cart\CurrencyFactory $currencyFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -372,6 +370,8 @@ class Quote extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, + \Magento\Framework\Api\MetadataServiceInterface $metadataService, + AttributeDataBuilder $customAttributeBuilder, \Magento\Quote\Model\QuoteValidator $quoteValidator, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, @@ -398,6 +398,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel \Magento\Customer\Api\Data\CustomerDataBuilder $customerBuilder, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter, + \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] @@ -428,7 +429,16 @@ class Quote extends \Magento\Framework\Model\AbstractModel $this->customerBuilder = $customerBuilder; $this->customerRepository = $customerRepository; $this->extensibleDataObjectConverter = $extensibleDataObjectConverter; - parent::__construct($context, $registry, $resource, $resourceCollection, $data); + $this->currencyFactory = $currencyFactory; + parent::__construct( + $context, + $registry, + $metadataService, + $customAttributeBuilder, + $resource, + $resourceCollection, + $data + ); } /** @@ -441,6 +451,126 @@ class Quote extends \Magento\Framework\Model\AbstractModel $this->_init('Magento\Quote\Model\Resource\Quote'); } + /** + * @codeCoverageIgnoreStart + * + * {@inheritdoc} + */ + public function getCurrency() + { + $currency = $this->getData('currency'); + if (!$currency) { + $currency = $this->currencyFactory->create() + ->setGlobalCurrencyCode($this->getGlobalCurrencyCode()) + ->setBaseCurrencyCode($this->getBaseCurrencyCode()) + ->setStoreCurrencyCode($this->getStoreCurrencyCode()) + ->setQuoteCurrencyCode($this->getQuoteCurrencyCode()) + ->setStoreToBaseRate($this->getStoreToBaseRate()) + ->setStoreToQuoteRate($this->getStoreToQuoteRate()) + ->setBaseToGlobalRate($this->getBaseToGlobalRate()) + ->setBaseToQuoteRate($this->getBaseToQuoteRate()); + } + return $currency; + } + + /** + * {@inheritdoc} + */ + public function getItems() + { + return $this->_getData('items'); + } + + /** + * {@inheritdoc} + */ + public function getCreatedAt() + { + return $this->_getData('created_at'); + } + + /** + * {@inheritdoc} + */ + public function getUpdatedAt() + { + return $this->_getData('updated_at'); + } + + /** + * {@inheritdoc} + */ + public function getConvertedAt() + { + return $this->_getData('converted_at'); + } + + /** + * {@inheritdoc} + */ + public function getIsActive() + { + return $this->_getData('is_active'); + } + + /** + * {@inheritdoc} + */ + public function getItemsCount() + { + return $this->_getData('items_count'); + } + + /** + * {@inheritdoc} + */ + public function getItemsQty() + { + return $this->_getData('items_qty'); + } + + /** + * {@inheritdoc} + */ + public function getOrigOrderId() + { + return $this->_getData('orig_order_id'); + + } + + /** + * {@inheritdoc} + */ + public function getReservedOrderId() + { + return $this->_getData('reserved_order_id'); + } + + /** + * {@inheritdoc} + */ + public function getCustomerIsGuest() + { + return $this->_getData('customer_is_guest'); + } + + /** + * {@inheritdoc} + */ + public function getCustomerNote() + { + return $this->_getData('customer_note'); + } + + /** + * {@inheritdoc} + */ + public function getCustomerNoteNotify() + { + return $this->_getData('customer_note_notify'); + } + //@codeCoverageIgnoreEnd + /** * Get quote store identifier * @@ -794,9 +924,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel } /** - * Get customer tax class ID. - * - * @return string + * {@inheritdoc} */ public function getCustomerTaxClassId() { diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php index ebdadc8f67809fee7b36efae95df8dd21d975886..b05e8b9cc713591b1084345baf1fbb0607b77b6e 100644 --- a/app/code/Magento/Quote/Model/Quote/Address.php +++ b/app/code/Magento/Quote/Model/Quote/Address.php @@ -19,7 +19,6 @@ use Magento\Framework\Api\AttributeDataBuilder; * @method Address setCreatedAt(string $value) * @method string getUpdatedAt() * @method Address setUpdatedAt(string $value) - * @method int getCustomerId() * @method Address setCustomerId(int $value) * @method int getSaveInAddressBook() * @method Address setSaveInAddressBook(int $value) @@ -29,14 +28,12 @@ use Magento\Framework\Api\AttributeDataBuilder; * @method Address setCustomerAddressData(\Magento\Customer\Api\Data\AddressInterface $value) * @method string getAddressType() * @method Address setAddressType(string $value) - * @method string getEmail() * @method Address setEmail(string $value) * @method Address setPrefix(string $value) * @method Address setFirstname(string $value) * @method Address setMiddlename(string $value) * @method Address setLastname(string $value) * @method Address setSuffix(string $value) - * @method string getCompany() * @method Address setCompany(string $value) * @method Address setCity(string $value) * @method Address setRegion(string $value) @@ -44,7 +41,6 @@ use Magento\Framework\Api\AttributeDataBuilder; * @method Address setPostcode(string $value) * @method Address setCountryId(string $value) * @method Address setTelephone(string $value) - * @method string getFax() * @method Address setFax(string $value) * @method int getSameAsBilling() * @method Address setSameAsBilling(int $value) @@ -117,7 +113,8 @@ use Magento\Framework\Api\AttributeDataBuilder; * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Address extends \Magento\Customer\Model\Address\AbstractAddress +class Address extends \Magento\Customer\Model\Address\AbstractAddress implements + \Magento\Quote\Api\Data\AddressInterface { const RATES_FETCH = 1; @@ -238,6 +235,11 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress */ protected $addressMapper; + /** + * @var Address\RateRequestFactory + */ + protected $_rateRequestFactory; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -1348,4 +1350,127 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress { return $this->validator; } + + /** + * {@inheritdoc} + * @codeCoverageIgnoreStart + */ + public function getCountryId() + { + return $this->getData(self::KEY_COUNTRY_ID); + } + + /** + * {@inheritdoc} + */ + public function getStreet() + { + $street = $this->getData(self::KEY_STREET); + return explode("\n", $street); + } + + /** + * {@inheritdoc} + */ + public function getCompany() + { + return $this->getData(self::KEY_COMPANY); + } + + /** + * {@inheritdoc} + */ + public function getTelephone() + { + return $this->getData(self::KEY_TELEPHONE); + } + + /** + * {@inheritdoc} + */ + public function getFax() + { + return $this->getData(self::KEY_FAX); + } + + /** + * {@inheritdoc} + */ + public function getPostcode() + { + return $this->getData(self::KEY_POSTCODE); + } + + /** + * {@inheritdoc} + */ + public function getCity() + { + return $this->getData(self::KEY_CITY); + } + + /** + * {@inheritdoc} + */ + public function getFirstname() + { + return $this->getData(self::KEY_FIRSTNAME); + } + + /** + * {@inheritdoc} + */ + public function getLastname() + { + return $this->getData(self::KEY_LASTNAME); + } + + /** + * {@inheritdoc} + */ + public function getMiddlename() + { + return $this->getData(self::KEY_MIDDLENAME); + } + + /** + * {@inheritdoc} + */ + public function getPrefix() + { + return $this->getData(self::KEY_PREFIX); + } + + /** + * {@inheritdoc} + */ + public function getSuffix() + { + return $this->getData(self::KEY_SUFFIX); + } + + /** + * {@inheritdoc} + */ + public function getVatId() + { + return $this->getData(self::KEY_VAT_ID); + } + + /** + * {@inheritdoc} + */ + public function getCustomerId() + { + return $this->getData(self::KEY_CUSTOMER_ID); + } + + /** + * {@inheritdoc} + */ + public function getEmail() + { + return $this->getData(self::KEY_EMAIL); + } + //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Quote/Model/Quote/Item.php b/app/code/Magento/Quote/Model/Quote/Item.php index 5cc00a9e3c50ed2bc4ba9fc85893fcbb32f74b06..80df19e6741dcb68a18321be00301336f67be031 100644 --- a/app/code/Magento/Quote/Model/Quote/Item.php +++ b/app/code/Magento/Quote/Model/Quote/Item.php @@ -8,18 +8,18 @@ namespace Magento\Quote\Model\Quote; +use Magento\Framework\Api\AttributeDataBuilder; +use Magento\Framework\Api\MetadataServiceInterface; + /** * Sales Quote Item Model * * @method \Magento\Quote\Model\Resource\Quote\Item _getResource() * @method \Magento\Quote\Model\Resource\Quote\Item getResource() - * @method int getQuoteId() - * @method \Magento\Quote\Model\Quote\Item setQuoteId(int $value) * @method string getCreatedAt() * @method \Magento\Quote\Model\Quote\Item setCreatedAt(string $value) * @method string getUpdatedAt() * @method \Magento\Quote\Model\Quote\Item setUpdatedAt(string $value) - * @method int getProductId() * @method \Magento\Quote\Model\Quote\Item setProductId(int $value) * @method int getStoreId() * @method \Magento\Quote\Model\Quote\Item setStoreId(int $value) @@ -27,10 +27,6 @@ namespace Magento\Quote\Model\Quote; * @method \Magento\Quote\Model\Quote\Item setParentItemId(int $value) * @method int getIsVirtual() * @method \Magento\Quote\Model\Quote\Item setIsVirtual(int $value) - * @method string getSku() - * @method \Magento\Quote\Model\Quote\Item setSku(string $value) - * @method string getName() - * @method \Magento\Quote\Model\Quote\Item setName(string $value) * @method string getDescription() * @method \Magento\Quote\Model\Quote\Item setDescription(string $value) * @method string getAdditionalData() @@ -102,7 +98,7 @@ namespace Magento\Quote\Model\Quote; * @method \Magento\Quote\Model\Quote\Item unsHasConfigurationUnavailableError() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem +class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem implements \Magento\Quote\Api\Data\CartItemInterface { /** * Prefix of model events names @@ -184,12 +180,14 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, + * @param MetadataServiceInterface $metadataService + * @param AttributeDataBuilder $customAttributeBuilder + * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Sales\Model\Status\ListFactory $statusListFactory * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param Item\OptionFactory $itemOptionFactory - * @param \Magento\Quote\Model\Quote\Item\Compare $quoteItemCompare + * @param Item\Compare $quoteItemCompare * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -200,6 +198,8 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, + MetadataServiceInterface $metadataService, + AttributeDataBuilder $customAttributeBuilder, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Sales\Model\Status\ListFactory $statusListFactory, @@ -219,6 +219,8 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem parent::__construct( $context, $registry, + $metadataService, + $customAttributeBuilder, $productRepository, $priceCurrency, $resource, @@ -900,4 +902,55 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem return $this; } + + /** + * @codeCoverageIgnoreStart + * + * {@inheritdoc} + */ + public function getItemId() + { + return $this->getData('item_id'); + } + + /** + * {@inheritdoc} + */ + public function getSku() + { + return $this->getData('sku'); + } + + /** + * {@inheritdoc} + */ + public function getQty() + { + return $this->getData('qty'); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->getData('name'); + } + + /** + * {@inheritdoc} + */ + public function getPrice() + { + return $this->getData('price'); + } + + /** + * {@inheritdoc} + */ + public function getQuoteId() + { + return $this->getData('quote_id'); + } + //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php b/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php index e6ba9a34bb09edb87338c38ad5b4d30dd4f26b62..b1740148f0f03bd26ab9631bc15f040565deccf1 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php +++ b/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php @@ -6,6 +6,7 @@ namespace Magento\Quote\Model\Quote\Item; use Magento\Quote\Model\Quote\Item; +use Magento\Framework\Api\AttributeDataBuilder; /** * Quote item abstract model @@ -44,7 +45,7 @@ use Magento\Quote\Model\Quote\Item; * @method float getPriceInclTax() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel implements +abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleModel implements \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface { /** @@ -82,6 +83,8 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param AttributeDataBuilder $customAttributeBuilder * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -91,13 +94,23 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, + \Magento\Framework\Api\MetadataServiceInterface $metadataService, + AttributeDataBuilder $customAttributeBuilder, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $metadataService, + $customAttributeBuilder, + $resource, + $resourceCollection, + $data + ); $this->productRepository = $productRepository; $this->priceCurrency = $priceCurrency; } diff --git a/app/code/Magento/Quote/Model/Quote/Item/Repository.php b/app/code/Magento/Quote/Model/Quote/Item/Repository.php new file mode 100644 index 0000000000000000000000000000000000000000..50c79c12f852f98830237bf6d48b7fe9f31aa9ef --- /dev/null +++ b/app/code/Magento/Quote/Model/Quote/Item/Repository.php @@ -0,0 +1,139 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model\Quote\Item; + +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\NoSuchEntityException; + +class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface +{ + /** + * Quote repository. + * + * @var \Magento\Quote\Model\QuoteRepository + */ + protected $quoteRepository; + + /** + * Product repository. + * + * @var \Magento\Catalog\Api\ProductRepositoryInterface + */ + protected $productRepository; + + /** + * @var \Magento\Quote\Api\Data\CartItemDataBuilder + */ + protected $itemDataBuilder; + + /** + * Constructs a read service object. + * + * @param \Magento\Quote\Model\QuoteRepository $quoteRepository + * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository + * @param \Magento\Quote\Api\Data\CartItemDataBuilder $itemDataBuilder + */ + public function __construct( + \Magento\Quote\Model\QuoteRepository $quoteRepository, + \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, + \Magento\Quote\Api\Data\CartItemDataBuilder $itemDataBuilder + ) { + $this->quoteRepository = $quoteRepository; + $this->productRepository = $productRepository; + $this->itemDataBuilder = $itemDataBuilder; + } + + /** + * {@inheritdoc} + */ + public function getList($cartId) + { + $output = []; + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + + /** @var \Magento\Quote\Model\Quote\Item $item */ + foreach ($quote->getAllItems() as $item) { + $output[] = $item; + } + return $output; + } + + /** + * {@inheritdoc} + */ + public function save(\Magento\Quote\Api\Data\CartItemInterface $cartItem) + { + $qty = $cartItem->getQty(); + if (!is_numeric($qty) || $qty <= 0) { + throw InputException::invalidFieldValue('qty', $qty); + } + $cartId = $cartItem->getQuoteId(); + + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + + $itemId = $cartItem->getItemId(); + try { + /** update item qty */ + if (isset($itemId)) { + $cartItem = $quote->getItemById($itemId); + if (!$cartItem) { + throw new NoSuchEntityException("Cart $cartId doesn't contain item $itemId"); + } + $product = $this->productRepository->get($cartItem->getSku()); + $cartItem->setData('qty', $qty); + } else { + $product = $this->productRepository->get($cartItem->getSku()); + $quote->addProduct($product, $qty); + } + $this->quoteRepository->save($quote->collectTotals()); + } catch (\Exception $e) { + if ($e instanceof NoSuchEntityException) { + throw $e; + } + throw new CouldNotSaveException('Could not save quote'); + } + return $quote->getItemByProduct($product); + } + + /** + * {@inheritdoc} + */ + public function delete(\Magento\Quote\Api\Data\CartItemInterface $cartItem) + { + $cartId = $cartItem->getQuoteId(); + $itemId = $cartItem->getItemId(); + /** + * Quote. + * + * @var \Magento\Quote\Model\Quote $quote + */ + $quote = $this->quoteRepository->getActive($cartId); + $quoteItem = $quote->getItemById($itemId); + if (!$quoteItem) { + throw new NoSuchEntityException("Cart $cartId doesn't contain item $itemId"); + } + try { + $quote->removeItem($itemId); + $this->quoteRepository->save($quote->collectTotals()); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not remove item from quote'); + } + } + + /** + * {@inheritdoc} + */ + public function deleteById($cartId, $itemId) + { + $item = $this->itemDataBuilder->setQuoteId($cartId)->setItemId($itemId)->create(); + $this->delete($item); + return true; + } +} diff --git a/app/code/Magento/Quote/Model/Quote/Payment.php b/app/code/Magento/Quote/Model/Quote/Payment.php index fb06beae42cf99780f51eb6ae8ca117495eb06d7..1b511c6d3428e384a11c9c689daf12bc395e717d 100644 --- a/app/code/Magento/Quote/Model/Quote/Payment.php +++ b/app/code/Magento/Quote/Model/Quote/Payment.php @@ -18,9 +18,7 @@ use Magento\Framework\Api\AttributeDataBuilder; * @method \Magento\Quote\Model\Quote\Payment setCreatedAt(string $value) * @method string getUpdatedAt() * @method \Magento\Quote\Model\Quote\Payment setUpdatedAt(string $value) - * @method string getMethod() * @method \Magento\Quote\Model\Quote\Payment setMethod(string $value) - * @method string getCcType() * @method \Magento\Quote\Model\Quote\Payment setCcType(string $value) * @method string getCcNumberEnc() * @method \Magento\Quote\Model\Quote\Payment setCcNumberEnc(string $value) @@ -34,9 +32,7 @@ use Magento\Framework\Api\AttributeDataBuilder; * @method \Magento\Quote\Model\Quote\Payment setCcSsStartMonth(int $value) * @method int getCcSsStartYear() * @method \Magento\Quote\Model\Quote\Payment setCcSsStartYear(int $value) - * @method string getPoNumber() * @method \Magento\Quote\Model\Quote\Payment setPoNumber(string $value) - * @method string getAdditionalData() * @method \Magento\Quote\Model\Quote\Payment setAdditionalData(string $value) * @method string getCcSsIssue() * @method \Magento\Quote\Model\Quote\Payment setCcSsIssue(string $value) @@ -44,7 +40,7 @@ use Magento\Framework\Api\AttributeDataBuilder; * @author Magento Core Team <core@magentocommerce.com> * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Payment extends \Magento\Payment\Model\Info +class Payment extends \Magento\Payment\Model\Info implements \Magento\Quote\Api\Data\PaymentInterface { /** * @var string @@ -237,4 +233,81 @@ class Payment extends \Magento\Payment\Model\Info $method = parent::getMethodInstance(); return $method->setStore($this->getQuote()->getStore()); } + + /** + * @codeCoverageIgnoreStart + * + * {@inheritdoc} + */ + public function getPoNumber() + { + return $this->getData('po_number'); + } + + /** + * {@inheritdoc} + */ + public function getMethod() + { + return $this->getData('method'); + } + + /** + * {@inheritdoc} + */ + public function getCcOwner() + { + return $this->getData('cc_owner'); + } + + /** + * {@inheritdoc} + */ + public function getCcNumber() + { + return $this->getData('cc_number'); + } + + /** + * {@inheritdoc} + */ + public function getCcType() + { + return $this->getData('cc_type'); + } + + /** + * {@inheritdoc} + */ + public function getCcExpYear() + { + $expirationYear = $this->getData('cc_exp_year') ?: null; + return $expirationYear; + } + + /** + * {@inheritdoc} + */ + public function getCcExpMonth() + { + return $this->getData('cc_exp_month'); + } + + /** + * {@inheritdoc} + */ + public function getAdditionalData() + { + $additionalDataValue = $this->getData('additional_data'); + if (is_string($additionalDataValue)) { + $additionalData = @unserialize($additionalDataValue); + if (is_array($additionalData)) { + return $additionalData; + } + } elseif (is_array($additionalDataValue)) { + return $additionalDataValue; + } + return null; + } + //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Checkout/Service/V1/Address/Validator.php b/app/code/Magento/Quote/Model/QuoteAddressValidator.php similarity index 89% rename from app/code/Magento/Checkout/Service/V1/Address/Validator.php rename to app/code/Magento/Quote/Model/QuoteAddressValidator.php index 1ca1d0677f2802531ae2da9afcf6ee2c48b29155..b195066721af0a0885cd49c631154d7fb0fe986a 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Validator.php +++ b/app/code/Magento/Quote/Model/QuoteAddressValidator.php @@ -3,10 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Address; +namespace Magento\Quote\Model; -/** Quote shipping address validator service. */ -class Validator +/** Quote shipping/billing address validator service. */ +class QuoteAddressValidator { /** * Address factory. @@ -39,12 +39,12 @@ class Validator /** * Validates the fields in a specified address data object. * - * @param \Magento\Checkout\Service\V1\Data\Cart\Address $addressData The address data object. + * @param \Magento\Quote\Api\Data\AddressInterface $addressData The address data object. * @return bool * @throws \Magento\Framework\Exception\InputException The specified address belongs to another customer. * @throws \Magento\Framework\Exception\NoSuchEntityException The specified customer ID or address ID is not valid. */ - public function validate($addressData) + public function validate(\Magento\Quote\Api\Data\AddressInterface $addressData) { //validate customer id if ($addressData->getCustomerId()) { diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index e8c66eddd8a196a32974facea3b5d6bb30480086..7ff8097290597cf1d68362f18427680d498b0ef8 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -14,11 +14,16 @@ use Magento\Quote\Model\Quote\Address\ToOrder as ToOrderConverter; use Magento\Quote\Model\Quote\Address\ToOrderAddress as ToOrderAddressConverter; use Magento\Quote\Model\Quote\Item\ToOrderItem as ToOrderItemConverter; use Magento\Quote\Model\Quote\Payment\ToOrderPayment as ToOrderPaymentConverter; +use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\StateException; /** * Class QuoteManagement + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class QuoteManagement +class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface { /** * @var EventManager @@ -65,6 +70,26 @@ class QuoteManagement */ protected $quotePaymentToOrderPayment; + /** + * @var UserContextInterface + */ + protected $userContext; + + /** + * @var QuoteRepository + */ + protected $quoteRepository; + + /** + * @var \Magento\Customer\Api\CustomerRepositoryInterface + */ + protected $customerRepository; + + /** + * @var \Magento\Customer\Model\CustomerFactory + */ + protected $customerModelFactory; + /** * @param EventManager $eventManager * @param QuoteValidator $quoteValidator @@ -75,6 +100,11 @@ class QuoteManagement * @param ToOrderAddressConverter $quoteAddressToOrderAddress * @param ToOrderItemConverter $quoteItemToOrderItem * @param ToOrderPaymentConverter $quotePaymentToOrderPayment + * @param UserContextInterface $userContext + * @param QuoteRepository $quoteRepository + * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository + * @param \Magento\Customer\Model\CustomerFactory $customerModelFactory + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( EventManager $eventManager, @@ -85,7 +115,11 @@ class QuoteManagement ToOrderConverter $quoteAddressToOrder, ToOrderAddressConverter $quoteAddressToOrderAddress, ToOrderItemConverter $quoteItemToOrderItem, - ToOrderPaymentConverter $quotePaymentToOrderPayment + ToOrderPaymentConverter $quotePaymentToOrderPayment, + UserContextInterface $userContext, + QuoteRepository $quoteRepository, + \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, + \Magento\Customer\Model\CustomerFactory $customerModelFactory ) { $this->eventManager = $eventManager; $this->quoteValidator = $quoteValidator; @@ -96,9 +130,119 @@ class QuoteManagement $this->quoteAddressToOrderAddress = $quoteAddressToOrderAddress; $this->quoteItemToOrderItem = $quoteItemToOrderItem; $this->quotePaymentToOrderPayment = $quotePaymentToOrderPayment; + $this->userContext = $userContext; + $this->quoteRepository = $quoteRepository; + $this->customerRepository = $customerRepository; + $this->customerModelFactory = $customerModelFactory; + } + + /** + * {@inheritdoc} + */ + public function createEmptyCart($storeId) + { + $quote = $this->userContext->getUserType() == UserContextInterface::USER_TYPE_CUSTOMER + ? $this->createCustomerCart($storeId) + : $this->createAnonymousCart($storeId); + + try { + $this->quoteRepository->save($quote); + } catch (\Exception $e) { + throw new CouldNotSaveException('Cannot create quote'); + } + return $quote->getId(); + } + + /** + * {@inheritdoc} + */ + public function assignCustomer($cartId, $customerId, $storeId) + { + $quote = $this->quoteRepository->getActive($cartId); + $customer = $this->customerRepository->getById($customerId); + $customerModel = $this->customerModelFactory->create(); + + if (!in_array($storeId, $customerModel->load($customerId)->getSharedStoreIds())) { + throw new StateException('Cannot assign customer to the given cart. The cart belongs to different store.'); + } + if ($quote->getCustomerId()) { + throw new StateException('Cannot assign customer to the given cart. The cart is not anonymous.'); + } + try { + $this->quoteRepository->getForCustomer($customerId); + throw new StateException('Cannot assign customer to the given cart. Customer already has active cart.'); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + + } + + $quote->setCustomer($customer); + $quote->setCustomerIsGuest(0); + $this->quoteRepository->save($quote); + return true; + + } + + /** + * Creates an anonymous cart. + * + * @param int $storeId + * @return \Magento\Quote\Model\Quote Cart object. + */ + protected function createAnonymousCart($storeId) + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->create(); + $quote->setStoreId($storeId); + return $quote; } /** + * Creates a cart for the currently logged-in customer. + * + * @param int $storeId + * @return \Magento\Quote\Model\Quote Cart object. + * @throws CouldNotSaveException The cart could not be created. + */ + protected function createCustomerCart($storeId) + { + $customer = $this->customerRepository->getById($this->userContext->getUserId()); + + try { + $this->quoteRepository->getActiveForCustomer($this->userContext->getUserId()); + throw new CouldNotSaveException('Cannot create quote'); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + + } + + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->create(); + $quote->setStoreId($storeId); + $quote->setCustomer($customer); + $quote->setCustomerIsGuest(0); + return $quote; + } + + /** + * {@inheritdoc} + */ + public function placeOrder($cartId) + { + $quote = $this->quoteRepository->getActive($cartId); + $order = $this->submit($quote); + return $order->getId(); + } + + /** + * {@inheritdoc} + */ + public function getCartForCustomer($customerId) + { + return $this->quoteRepository->getActiveForCustomer($customerId); + } + + /** + * Delete quote item + * * @param Quote $quote * @param array $orderData * @return \Magento\Framework\Model\AbstractExtensibleModel|\Magento\Sales\Api\Data\OrderInterface|object|void @@ -216,6 +360,7 @@ class QuoteManagement 'quote' => $quote ] ); + $this->quoteRepository->save($quote); } catch (\Exception $e) { $this->eventManager->dispatch( 'sales_model_service_quote_submit_failure', diff --git a/app/code/Magento/Quote/Model/QuoteRepository.php b/app/code/Magento/Quote/Model/QuoteRepository.php index b0c8927015f864c8268faf3042344ce9f40b8780..82c02292af678aa8d41d0fbd0df22a9e32452458 100644 --- a/app/code/Magento/Quote/Model/QuoteRepository.php +++ b/app/code/Magento/Quote/Model/QuoteRepository.php @@ -5,12 +5,15 @@ */ namespace Magento\Quote\Model; -use \Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Quote\Model\Quote; -use Magento\Quote\Model\QuoteFactory; use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\Api\SearchCriteria; +use Magento\Framework\Api\Search\FilterGroup; +use Magento\Quote\Model\Resource\Quote\Collection as QuoteCollection; +use Magento\Framework\Exception\InputException; -class QuoteRepository +class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface { /** * @var Quote[] @@ -32,16 +35,32 @@ class QuoteRepository */ protected $storeManager; + /** + * @var \Magento\Quote\Model\Resource\Quote\Collection + */ + protected $quoteCollection; + + /** + * @var \Magento\Quote\Api\Data\CartSearchResultsDataBuilder + */ + protected $searchResultsBuilder; + /** * @param QuoteFactory $quoteFactory * @param StoreManagerInterface $storeManager + * @param \Magento\Quote\Model\Resource\Quote\Collection $quoteCollection + * @param \Magento\Quote\Api\Data\CartSearchResultsDataBuilder $searchResultsBuilder */ public function __construct( QuoteFactory $quoteFactory, - StoreManagerInterface $storeManager + StoreManagerInterface $storeManager, + \Magento\Quote\Model\Resource\Quote\Collection $quoteCollection, + \Magento\Quote\Api\Data\CartSearchResultsDataBuilder $searchResultsBuilder ) { $this->quoteFactory = $quoteFactory; $this->storeManager = $storeManager; + $this->searchResultsBuilder = $searchResultsBuilder; + $this->quoteCollection = $quoteCollection; } /** @@ -61,7 +80,7 @@ class QuoteRepository * @param int $cartId * @param int[] $sharedStoreIds * @throws NoSuchEntityException - * @return Quote + * @return \Magento\Quote\Api\Data\CartInterface */ public function get($cartId, array $sharedStoreIds = []) { @@ -176,4 +195,55 @@ class QuoteRepository } return $quote; } + + /** + * {@inheritdoc} + */ + public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) + { + $this->searchResultsBuilder->setSearchCriteria($searchCriteria); + + foreach ($searchCriteria->getFilterGroups() as $group) { + $this->addFilterGroupToCollection($group, $this->quoteCollection); + } + + $this->searchResultsBuilder->setTotalCount($this->quoteCollection->getSize()); + $sortOrders = $searchCriteria->getSortOrders(); + if ($sortOrders) { + foreach ($sortOrders as $sortOrder) { + $this->quoteCollection->addOrder( + $sortOrder->getField(), + $sortOrder->getDirection() == SearchCriteria::SORT_ASC ? 'ASC' : 'DESC' + ); + } + } + $this->quoteCollection->setCurPage($searchCriteria->getCurrentPage()); + $this->quoteCollection->setPageSize($searchCriteria->getPageSize()); + + $this->searchResultsBuilder->setItems($this->quoteCollection->getItems()); + + return $this->searchResultsBuilder->create(); + } + + /** + * Adds a specified filter group to the specified quote collection. + * + * @param FilterGroup $filterGroup The filter group. + * @param QuoteCollection $collection The quote collection. + * @return void + * @throws InputException The specified filter group or quote collection does not exist. + */ + protected function addFilterGroupToCollection(FilterGroup $filterGroup, QuoteCollection $collection) + { + $fields = []; + $conditions = []; + foreach ($filterGroup->getFilters() as $filter) { + $fields[] = $filter->getField(); + $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq'; + $conditions[] = [$condition => $filter->getValue()]; + } + if ($fields) { + $collection->addFieldToFilter($fields, $conditions); + } + } } diff --git a/app/code/Magento/Quote/Model/ShippingAddressManagement.php b/app/code/Magento/Quote/Model/ShippingAddressManagement.php new file mode 100644 index 0000000000000000000000000000000000000000..13b92793ab36844f3cdf414f76379990ebf86dda --- /dev/null +++ b/app/code/Magento/Quote/Model/ShippingAddressManagement.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model; + +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\NoSuchEntityException; +use Psr\Log\LoggerInterface as Logger; +use Magento\Quote\Api\ShippingAddressManagementInterface; + +/** Quote shipping address write service object. */ +class ShippingAddressManagement implements ShippingAddressManagementInterface +{ + /** + * Quote repository. + * + * @var \Magento\Quote\Model\QuoteRepository + */ + protected $quoteRepository; + + /** + * Logger. + * + * @var Logger + */ + protected $logger; + + /** + * Validator. + * + * @var QuoteAddressValidator + */ + protected $addressValidator; + + /** + * Constructs a quote shipping address write service object. + * + * @param QuoteRepository $quoteRepository + * @param QuoteAddressValidator $addressValidator + * @param Logger $logger + */ + public function __construct( + \Magento\Quote\Model\QuoteRepository $quoteRepository, + QuoteAddressValidator $addressValidator, + Logger $logger + ) { + $this->quoteRepository = $quoteRepository; + $this->addressValidator = $addressValidator; + $this->logger = $logger; + } + + /** + * {@inheritDoc} + */ + public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address) + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + if ($quote->isVirtual()) { + throw new NoSuchEntityException( + 'Cart contains virtual product(s) only. Shipping address is not applicable' + ); + } + $this->addressValidator->validate($address); + $address->setSameAsBilling(0); + $address->setCollectShippingRates(true); + + $quote->setShippingAddress($address); + $quote->setDataChanges(true); + try { + $this->quoteRepository->save($quote); + } catch (\Exception $e) { + $this->logger->critical($e); + throw new InputException('Unable to save address. Please, check input data.'); + } + return $quote->getShippingAddress()->getId(); + } + + /** + * {@inheritDoc} + */ + public function get($cartId) + { + /** + * Quote. + * + * @var \Magento\Quote\Model\Quote $quote + */ + $quote = $this->quoteRepository->getActive($cartId); + if ($quote->isVirtual()) { + throw new NoSuchEntityException( + 'Cart contains virtual product(s) only. Shipping address is not applicable' + ); + } + + /** + * Address. + * + * @var \Magento\Quote\Model\Quote\Address $address + */ + return $quote->getShippingAddress(); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php similarity index 50% rename from app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php rename to app/code/Magento/Quote/Model/ShippingMethodManagement.php index 72ca2acbd5037ee07fcc7c6e7a17263c97da5f11..b73445ce19a533d0d2d24475a9ce93f3181c4760 100644 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -6,19 +6,19 @@ // @codingStandardsIgnoreFile -namespace Magento\Checkout\Service\V1\ShippingMethod; +namespace Magento\Quote\Model; -use Magento\Checkout\Service\V1\Data\Cart\ShippingMethod; -use Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder; -use Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\StateException; -use Magento\Quote\Model\QuoteRepository; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Quote\Api\ShippingMethodManagementInterface; +use Magento\Quote\Api\Data\ShippingMethodInterface; /** * Shipping method read service. */ -class ReadService implements ReadServiceInterface +class ShippingMethodManagement implements ShippingMethodManagementInterface { /** * Quote repository. @@ -30,14 +30,14 @@ class ReadService implements ReadServiceInterface /** * Shipping method builder. * - * @var \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder + * @var \Magento\Quote\Api\Data\ShippingMethodDataBuilder */ protected $methodBuilder; /** - * Shipping method converter. + * Shipping method converter * - * @var ShippingMethodConverter + * @var \Magento\Quote\Model\Cart\ShippingMethodConverter */ protected $converter; @@ -45,28 +45,23 @@ class ReadService implements ReadServiceInterface * Constructs a shipping method read service object. * * @param QuoteRepository $quoteRepository Quote repository. - * @param ShippingMethodConverter $converter Shipping method converter. - * @param \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $methodBuilder Shipping method builder. + * @param \Magento\Quote\Api\Data\ShippingMethodDataBuilder $methodBuilder Shipping method builder. + * @param \Magento\Quote\Model\Cart\ShippingMethodConverter $converter Shipping method builder converter. */ public function __construct( QuoteRepository $quoteRepository, - ShippingMethodConverter $converter, - \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $methodBuilder + \Magento\Quote\Api\Data\ShippingMethodDataBuilder $methodBuilder, + Cart\ShippingMethodConverter $converter ) { $this->quoteRepository = $quoteRepository; - $this->converter = $converter; $this->methodBuilder = $methodBuilder; + $this->converter = $converter; } /** * {@inheritDoc} - * - * @param int $cartId The shopping cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\ShippingMethod Shipping method. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified shopping cart does not exist. - * @throws \Magento\Framework\Exception\StateException The shipping address is not set. */ - public function getMethod($cartId) + public function get($cartId) { /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); @@ -86,13 +81,13 @@ class ReadService implements ReadServiceInterface list($carrierTitle, $methodTitle) = $this->divideNames(' - ', $shippingAddress->getShippingDescription()); $output = [ - ShippingMethod::CARRIER_CODE => $carrierCode, - ShippingMethod::METHOD_CODE => $methodCode, - ShippingMethod::CARRIER_TITLE => $carrierTitle, - ShippingMethod::METHOD_TITLE => $methodTitle, - ShippingMethod::SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), - ShippingMethod::BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), - ShippingMethod::AVAILABLE => true, + ShippingMethodInterface::CARRIER_CODE => $carrierCode, + ShippingMethodInterface::METHOD_CODE => $methodCode, + ShippingMethodInterface::CARRIER_TITLE => $carrierTitle, + ShippingMethodInterface::METHOD_TITLE => $methodTitle, + ShippingMethodInterface::SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), + ShippingMethodInterface::BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), + ShippingMethodInterface::AVAILABLE => true, ]; return $this->methodBuilder->populateWithArray($output)->create(); @@ -116,11 +111,6 @@ class ReadService implements ReadServiceInterface /** * {@inheritDoc} - * - * @param int $cartId The shopping cart ID. - * @return \Magento\Checkout\Service\V1\Data\Cart\ShippingMethod[] An array of shipping methods. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified quote does not exist. - * @throws \Magento\Framework\Exception\StateException The shipping address is not set. */ public function getList($cartId) { @@ -147,4 +137,50 @@ class ReadService implements ReadServiceInterface } return $output; } + + /** + * {@inheritDoc} + * + * @param int $cartId The shopping cart ID. + * @param string $carrierCode The carrier code. + * @param string $methodCode The shipping method code. + * @return bool + * @throws \Magento\Framework\Exception\InputException The shipping method is not valid for an empty cart. + * @throws \Magento\Framework\Exception\CouldNotSaveException The shipping method could not be saved. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart contains only virtual products and the shipping method is not applicable. + * @throws \Magento\Framework\Exception\StateException The billing or shipping address is not set. + */ + public function set($cartId, $carrierCode, $methodCode) + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->quoteRepository->getActive($cartId); + if (0 == $quote->getItemsCount()) { + throw new InputException('Shipping method is not applicable for empty cart'); + } + + if ($quote->isVirtual()) { + throw new NoSuchEntityException( + 'Cart contains virtual product(s) only. Shipping method is not applicable.' + ); + } + $shippingAddress = $quote->getShippingAddress(); + if (!$shippingAddress->getCountryId()) { + throw new StateException('Shipping address is not set'); + } + $billingAddress = $quote->getBillingAddress(); + if (!$billingAddress->getCountryId()) { + throw new StateException('Billing address is not set'); + } + + $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode); + if (!$shippingAddress->requestShippingRates()) { + throw new NoSuchEntityException('Carrier with such method not found: ' . $carrierCode . ', ' . $methodCode); + } + try { + $this->quoteRepository->save($quote->collectTotals()); + } catch (\Exception $e) { + throw new CouldNotSaveException('Cannot set shipping method. ' . $e->getMessage()); + } + return true; + } } diff --git a/app/code/Magento/Quote/composer.json b/app/code/Magento/Quote/composer.json index 0d64fd35ee6ad41bec792cc50caa58ae629dbc65..b01897f371404e532c6ee8517f34b88e4812cac7 100644 --- a/app/code/Magento/Quote/composer.json +++ b/app/code/Magento/Quote/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-authorization": "0.42.0-beta4", - "magento/module-payment": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-authorization": "0.42.0-beta5", + "magento/module-payment": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Quote/etc/di.xml b/app/code/Magento/Quote/etc/di.xml index 072334a39d2fc9961d7968732dd09abffabea23e..d6e44321ac6f3f887a5b7b505e53fd0622e45e40 100644 --- a/app/code/Magento/Quote/etc/di.xml +++ b/app/code/Magento/Quote/etc/di.xml @@ -6,6 +6,11 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\Quote\Api\ShippingMethodManagementInterface" type="Magento\Quote\Model\ShippingMethodManagement" /> + <preference for="Magento\Quote\Api\Data\ShippingMethodInterface" type="Magento\Quote\Model\Cart\ShippingMethod" /> + <preference for="Magento\Quote\Api\BillingAddressManagementInterface" type="Magento\Quote\Model\BillingAddressManagement" /> + <preference for="Magento\Quote\Api\ShippingAddressManagementInterface" type="Magento\Quote\Model\ShippingAddressManagement" /> + <preference for="Magento\Quote\Api\Data\AddressInterface" type="Magento\Quote\Model\Quote\Address" /> <type name="Magento\Framework\Module\Updater\SetupFactory"> <arguments> <argument name="resourceTypes" xsi:type="array"> @@ -13,4 +18,18 @@ </argument> </arguments> </type> + <preference for="Magento\Quote\Api\Data\CartItemInterface" type="Magento\Quote\Model\Quote\Item" /> + <preference for="Magento\Quote\Api\Data\CartInterface" type="Magento\Quote\Model\Quote" /> + <preference for="Magento\Quote\Api\CartItemRepositoryInterface" type="Magento\Quote\Model\Quote\Item\Repository" /> + <preference for="Magento\Quote\Api\CartRepositoryInterface" type="Magento\Quote\Model\QuoteRepository" /> + <preference for="Magento\Quote\Api\Data\CartSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Quote\Api\PaymentMethodManagementInterface" type="\Magento\Quote\Model\PaymentMethodManagement" /> + <preference for="Magento\Quote\Api\Data\PaymentInterface" type="\Magento\Quote\Model\Quote\Payment" /> + <preference for="Magento\Quote\Api\CouponManagementInterface" type="Magento\Quote\Model\CouponManagement" /> + <preference for="Magento\Quote\Api\CartManagementInterface" type="Magento\Quote\Model\QuoteManagement" /> + <preference for="Magento\Authorization\Model\UserContextInterface" type="Magento\Authorization\Model\CompositeUserContext"/> + <preference for="Magento\Quote\Api\CartTotalRepositoryInterface" type="\Magento\Quote\Model\Cart\CartTotalRepository" /> + <preference for="Magento\Quote\Api\Data\TotalsInterface" type="\Magento\Quote\Model\Cart\Totals" /> + <preference for="Magento\Quote\Api\Data\TotalsItemInterface" type="\Magento\Quote\Model\Quote\Cart\Totals\Item" /> + <preference for="Magento\Quote\Api\Data\CurrencyInterface" type="\Magento\Quote\Model\Cart\Currency" /> </config> diff --git a/app/code/Magento/Checkout/etc/webapi.xml b/app/code/Magento/Quote/etc/webapi.xml similarity index 59% rename from app/code/Magento/Checkout/etc/webapi.xml rename to app/code/Magento/Quote/etc/webapi.xml index 786e9bb82884ab54de2ae696feffe794ce409a8c..2a4e83c5597b137926a0726771adae2d41836969 100644 --- a/app/code/Magento/Checkout/etc/webapi.xml +++ b/app/code/Magento/Quote/etc/webapi.xml @@ -7,148 +7,148 @@ --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> - <route url="/V1/carts/" method="POST"> - <service class="Magento\Checkout\Service\V1\Cart\WriteServiceInterface" method="create"/> + <route url="/V1/carts/:cartId" method="GET"> + <service class="Magento\Quote\Api\CartRepositoryInterface" method="get"/> <resources> - <resource ref="Magento_Sales::create" /> + <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/carts/:cartId" method="PUT"> - <service class="Magento\Checkout\Service\V1\Cart\WriteServiceInterface" method="assignCustomer"/> + <route url="/V1/carts" method="PUT"> + <service class="Magento\Quote\Api\CartRepositoryInterface" method="getList"/> <resources> - <resource ref="Magento_Sales::create" /> + <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/carts/:cartId/items" method="GET"> - <service class="Magento\Checkout\Service\V1\Item\ReadServiceInterface" method="getList"/> + <route url="/V1/carts/" method="POST"> + <service class="Magento\Quote\Api\CartManagementInterface" method="createEmptyCart"/> <resources> - <resource ref="Magento_Catalog::products" /> + <resource ref="Magento_Sales::create" /> </resources> </route> - <route url="/V1/carts/:cartId/items" method="POST"> - <service class="Magento\Checkout\Service\V1\Item\WriteServiceInterface" method="addItem"/> + <route url="/V1/carts/:cartId" method="PUT"> + <service class="Magento\Quote\Api\CartManagementInterface" method="assignCustomer"/> <resources> - <resource ref="Magento_Catalog::products" /> + <resource ref="Magento_Sales::create" /> </resources> </route> - <route url="/V1/carts/:cartId/items/:itemId" method="PUT"> - <service class="Magento\Checkout\Service\V1\Item\WriteServiceInterface" method="updateItem"/> + <route url="/V1/carts/:cartId/selected-shipping-method" method="PUT"> + <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="set"/> <resources> - <resource ref="Magento_Catalog::products" /> + <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId/items/:itemId" method="DELETE"> - <service class="Magento\Checkout\Service\V1\Item\WriteServiceInterface" method="removeItem"/> + <route url="/V1/carts/:cartId/selected-shipping-method" method="GET"> + <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="get"/> <resources> - <resource ref="Magento_Catalog::products" /> + <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId" method="GET"> - <service class="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" method="getCart"/> + <route url="/V1/carts/:cartId/shipping-methods" method="GET"> + <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="getList"/> <resources> - <resource ref="Magento_Catalog::products" /> - </resources> + <resource ref="Magento_Sales::sales" /> + </resources> </route> - <route url="/V1/customer/:customerId/cart" method="GET"> - <service class="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" method="getCartForCustomer"/> + <route url="/V1/carts/:cartId/items" method="GET"> + <service class="Magento\Quote\Api\CartItemRepositoryInterface" method="getList"/> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/carts" method="GET"> - <service class="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" method="getCartList"/> + <route url="/V1/carts/items" method="POST"> + <service class="Magento\Quote\Api\CartItemRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/carts/:cartId/shipping-address" method="GET"> - <service class="Magento\Checkout\Service\V1\Address\Shipping\ReadServiceInterface" method="getAddress"/> + <route url="/V1/carts/items/:itemId" method="PUT"> + <service class="Magento\Quote\Api\CartItemRepositoryInterface" method="save"/> <resources> - <resource ref="Magento_Sales::sales" /> + <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/carts/:cartId/shipping-address" method="POST"> - <service class="Magento\Checkout\Service\V1\Address\Shipping\WriteServiceInterface" method="setAddress"/> + <route url="/V1/carts/:cartId/items/:itemId" method="DELETE"> + <service class="Magento\Quote\Api\CartItemRepositoryInterface" method="deleteById"/> <resources> - <resource ref="Magento_Sales::sales" /> + <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/carts/:cartId/billing-address" method="GET"> - <service class="Magento\Checkout\Service\V1\Address\Billing\ReadServiceInterface" method="getAddress"/> + <route url="/V1/carts/:cartId/selected-payment-methods" method="GET"> + <service class="Magento\Quote\Api\PaymentMethodManagementInterface" method="get"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId/billing-address" method="POST"> - <service class="Magento\Checkout\Service\V1\Address\Billing\WriteServiceInterface" method="setAddress"/> + <route url="/V1/carts/:cartId/selected-payment-methods" method="PUT"> + <service class="Magento\Quote\Api\PaymentMethodManagementInterface" method="set"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId/selected-shipping-method" method="PUT"> - <service class="Magento\Checkout\Service\V1\ShippingMethod\WriteServiceInterface" method="setMethod"/> + <route url="/V1/carts/:cartId/payment-methods" method="GET"> + <service class="Magento\Quote\Api\PaymentMethodManagementInterface" method="getList"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId/selected-shipping-method" method="GET"> - <service class="Magento\Checkout\Service\V1\ShippingMethod\ReadServiceInterface" method="getMethod"/> + <route url="/V1/carts/:cartId/billing-address" method="GET"> + <service class="Magento\Quote\Api\BillingAddressManagementInterface" method="get"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId/shipping-methods" method="GET"> - <service class="Magento\Checkout\Service\V1\ShippingMethod\ReadServiceInterface" method="getList"/> + <route url="/V1/carts/:cartId/billing-address" method="POST"> + <service class="Magento\Quote\Api\BillingAddressManagementInterface" method="assign"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> <route url="/V1/carts/:cartId/coupons" method="GET"> - <service class="Magento\Checkout\Service\V1\Coupon\ReadServiceInterface" method="get"/> + <service class="Magento\Quote\Api\CouponManagementInterface" method="get"/> <resources> <resource ref="Magento_SalesRule::quote" /> </resources> </route> - <route url="/V1/carts/:cartId/coupons" method="PUT"> - <service class="Magento\Checkout\Service\V1\Coupon\WriteServiceInterface" method="set"/> + <route url="/V1/carts/:cartId/coupons/:couponCode" method="PUT"> + <service class="Magento\Quote\Api\CouponManagementInterface" method="set"/> <resources> <resource ref="Magento_SalesRule::quote" /> </resources> </route> <route url="/V1/carts/:cartId/coupons" method="DELETE"> - <service class="Magento\Checkout\Service\V1\Coupon\WriteServiceInterface" method="delete"/> + <service class="Magento\Quote\Api\CouponManagementInterface" method="remove"/> <resources> <resource ref="Magento_SalesRule::quote" /> </resources> </route> - <route url="/V1/carts/:cartId/selected-payment-methods" method="GET"> - <service class="Magento\Checkout\Service\V1\PaymentMethod\ReadServiceInterface" method="getPayment"/> + <route url="/V1/carts/:cartId/shipping-address" method="GET"> + <service class="Magento\Quote\Api\ShippingAddressManagementInterface" method="get"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId/selected-payment-methods" method="PUT"> - <service class="Magento\Checkout\Service\V1\PaymentMethod\WriteServiceInterface" method="set"/> + <route url="/V1/carts/:cartId/shipping-address" method="POST"> + <service class="Magento\Quote\Api\ShippingAddressManagementInterface" method="assign"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId/payment-methods" method="GET"> - <service class="Magento\Checkout\Service\V1\PaymentMethod\ReadServiceInterface" method="getList"/> + <route url="/V1/carts/:cartId/order" method="PUT"> + <service class="Magento\Quote\Api\CartManagementInterface" method="placeOrder"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> <route url="/V1/carts/:cartId/totals" method="GET"> - <service class="Magento\Checkout\Service\V1\Cart\TotalsServiceInterface" method="getTotals"/> + <service class="Magento\Quote\Api\CartTotalRepositoryInterface" method="get"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/carts/:cartId/order" method="PUT"> - <service class="Magento\Checkout\Service\V1\Cart\WriteServiceInterface" method="order"/> + <route url="/V1/customer/:customerId/cart" method="GET"> + <service class="Magento\Quote\Api\CartManagementInterface" method="getCartForCustomer"/> <resources> - <resource ref="Magento_Sales::sales" /> + <resource ref="Magento_Catalog::products" /> </resources> </route> </routes> diff --git a/app/code/Magento/Checkout/etc/webapi_rest/di.xml b/app/code/Magento/Quote/etc/webapi_rest/di.xml similarity index 50% rename from app/code/Magento/Checkout/etc/webapi_rest/di.xml rename to app/code/Magento/Quote/etc/webapi_rest/di.xml index 637fd9850d74dd1fd48b61687ba9cea64f0ce408..67774a740401df953616e1fedae05e822e81d32e 100644 --- a/app/code/Magento/Checkout/etc/webapi_rest/di.xml +++ b/app/code/Magento/Quote/etc/webapi_rest/di.xml @@ -6,10 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Checkout\Service\V1\Cart\ReadServiceInterface"> - <plugin name="admin_access" type="\Magento\Checkout\Model\Cart\Access\ReadPlugin" /> + <type name="Magento\Quote\Api\CartRepositoryInterface"> + <plugin name="admin_access" type="\Magento\Quote\Model\Cart\Access\CartRepositoryPlugin" /> </type> - <type name="Magento\Checkout\Service\V1\Cart\WriteServiceInterface"> - <plugin name="admin_access" type="\Magento\Checkout\Model\Cart\Access\WritePlugin" /> + <type name="Magento\Quote\Api\CartManagementInterface"> + <plugin name="admin_access" type="\Magento\Quote\Model\Cart\Access\CartManagementPlugin" /> </type> </config> diff --git a/app/code/Magento/Checkout/etc/webapi_soap/di.xml b/app/code/Magento/Quote/etc/webapi_soap/di.xml similarity index 50% rename from app/code/Magento/Checkout/etc/webapi_soap/di.xml rename to app/code/Magento/Quote/etc/webapi_soap/di.xml index 637fd9850d74dd1fd48b61687ba9cea64f0ce408..67774a740401df953616e1fedae05e822e81d32e 100644 --- a/app/code/Magento/Checkout/etc/webapi_soap/di.xml +++ b/app/code/Magento/Quote/etc/webapi_soap/di.xml @@ -6,10 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Checkout\Service\V1\Cart\ReadServiceInterface"> - <plugin name="admin_access" type="\Magento\Checkout\Model\Cart\Access\ReadPlugin" /> + <type name="Magento\Quote\Api\CartRepositoryInterface"> + <plugin name="admin_access" type="\Magento\Quote\Model\Cart\Access\CartRepositoryPlugin" /> </type> - <type name="Magento\Checkout\Service\V1\Cart\WriteServiceInterface"> - <plugin name="admin_access" type="\Magento\Checkout\Model\Cart\Access\WritePlugin" /> + <type name="Magento\Quote\Api\CartManagementInterface"> + <plugin name="admin_access" type="\Magento\Quote\Model\Cart\Access\CartManagementPlugin" /> </type> </config> diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index 26cb3045f2757bdc39349819c800c1142fa8d65e..de229ca20183b46e481dd50b7c5fd520ef6aaabc 100644 --- a/app/code/Magento/Reports/composer.json +++ b/app/code/Magento/Reports/composer.json @@ -3,28 +3,28 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-widget": "0.42.0-beta4", - "magento/module-log": "0.42.0-beta4", - "magento/module-wishlist": "0.42.0-beta4", - "magento/module-review": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-downloadable": "0.42.0-beta4", - "magento/module-sales-rule": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-widget": "0.42.0-beta5", + "magento/module-log": "0.42.0-beta5", + "magento/module-wishlist": "0.42.0-beta5", + "magento/module-review": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-downloadable": "0.42.0-beta5", + "magento/module-sales-rule": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index c6f02b72628d15c6f9506b70e09800c5109b03cb..8a8d4a11cba2cf63c60a0607c626fd4b18703a50 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|~5.6.0", - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index 92cb207a7bbd5f7c40d9a680a6d1d21a65f6d90f..86ab8469257f45de1c3ef274ca491cfb0dd347e5 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-newsletter": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-ui": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-newsletter": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-ui": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index fe710939ed4ef69c9cead129c1f7256c28fcfad6..d4674385ee6388d504df66c225ac455d1c707bdc 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index eec6ca407f75ee77e05c12abf4cd33fcd63c227c..c33e68f3dd58d9a69975273bcea8557708301904 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index 73a47c528068b6339626ad8781132882fa7a0b08..244f8caa3bb50fd4be4c42939f6b5060c58398b6 100644 --- a/app/code/Magento/Sales/composer.json +++ b/app/code/Magento/Sales/composer.json @@ -3,33 +3,33 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-authorization": "0.42.0-beta4", - "magento/module-payment": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-sales-rule": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-widget": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-gift-message": "0.42.0-beta4", - "magento/module-reports": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-wishlist": "0.42.0-beta4", - "magento/module-email": "0.42.0-beta4", - "magento/module-shipping": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-ui": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-authorization": "0.42.0-beta5", + "magento/module-payment": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-sales-rule": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-widget": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-gift-message": "0.42.0-beta5", + "magento/module-reports": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-wishlist": "0.42.0-beta5", + "magento/module-email": "0.42.0-beta5", + "magento/module-shipping": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-ui": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index 59aa6097d19404d67ff1fe8525be22ab41072c86..c48970a4b49a99bd4b105af1e7e783f99e32f84b 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-rule": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-shipping": "0.42.0-beta4", - "magento/module-payment": "0.42.0-beta4", - "magento/module-reports": "0.42.0-beta4", - "magento/module-catalog-rule": "0.42.0-beta4", - "magento/module-widget": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-rule": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-shipping": "0.42.0-beta5", + "magento/module-payment": "0.42.0-beta5", + "magento/module-reports": "0.42.0-beta5", + "magento/module-catalog-rule": "0.42.0-beta5", + "magento/module-widget": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Search/composer.json b/app/code/Magento/Search/composer.json index 3d147502ec1a19fd91630fd94088af4d2f862254..89713fffbc009e098aa868b2fcda1834348809c7 100644 --- a/app/code/Magento/Search/composer.json +++ b/app/code/Magento/Search/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/framework": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-reports": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-reports": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index b853f7ff19105fff96b91dd39db6aea2f1bdde3c..565943993ff4d28afab3babaebcb6ca1467ee119 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 51fdbde0fac25f786574e9a137b6f92c91f90a2f..8b6a5d9857372bdad08a42de616ceb114f255d6c 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -3,28 +3,28 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-contact": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-payment": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-contact": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-payment": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-fedex": "0.42.0-beta4", - "magento/module-ups": "0.42.0-beta4" + "magento/module-fedex": "0.42.0-beta5", + "magento/module-ups": "0.42.0-beta5" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 7b21180eaec2aa200b208711d09e23a5084a4a47..fcebc2d231237a5a775ed21b882adbbb838da898 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-catalog-url-rewrite": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-catalog-url-rewrite": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index ad58e23e2a93afc02b151da2d967ffc0434caa62..24de401a9a62c4c71661a0620539fb46a83c4d56 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|~5.6.0", - "magento/module-core": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-ui": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-core": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-ui": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php b/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php index 5db47dec6ea8fefee047dd95d3508c231f6f0db7..18fa11ad4c952efca48bdee43123e2e7a6588d36 100644 --- a/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php +++ b/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php @@ -21,8 +21,9 @@ class ToOrderConverter * @param QuoteAddress $address * @param array $additional * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeConvert(QuoteAddressToOrder $subject, QuoteAddress $address, $additional) + public function beforeConvert(QuoteAddressToOrder $subject, QuoteAddress $address, $additional = []) { $this->quoteAddress = $address; return [$address, $additional]; @@ -32,6 +33,7 @@ class ToOrderConverter * @param QuoteAddressToOrder $subject * @param OrderInterface $order * @return OrderInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterConvert(QuoteAddressToOrder $subject, OrderInterface $order) { diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index 492b2967c644c3ebcd3b8e14e2076de7746123db..8f1fe4ce289579f629c0aca53b618b2a5ec16002 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-shipping": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-reports": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-shipping": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-reports": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/TaxImportExport/composer.json b/app/code/Magento/TaxImportExport/composer.json index 7c7f0e8ed4897aac376f430eb6e5c91ecb1225d4..1249485a16a889267b3f404e8b0dc29fdefc07bc 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|~5.6.0", - "magento/module-tax": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-tax": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index d79abd45addbc8af98f600e0307d6e46229701b0..cf599aa603f79ee4608a62d6da53434eb13c499c 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-require-js": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-require-js": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-translation": "0.42.0-beta4" + "magento/module-translation": "0.42.0-beta5" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Translation/composer.json b/app/code/Magento/Translation/composer.json index aa68217911935b5c88f1d439f8b7dd42b932d91e..373564113a79312c4bded4ac0122dc4e94c62daf 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|~5.6.0", - "magento/module-core": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-core": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Ui/composer.json b/app/code/Magento/Ui/composer.json index b70905d24ced0402f6b30dfc9eb81996fb506e5a..117fa952a7f2fc9439de6c58b1360fe849ad2401 100644 --- a/app/code/Magento/Ui/composer.json +++ b/app/code/Magento/Ui/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-backend": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", + "magento/module-backend": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index 61a2a252971274ea7795b4322b2dd8e418232d39..8b79b79ffa1e149f7c4d14b80589895cef801eb5 100644 --- a/app/code/Magento/Ups/composer.json +++ b/app/code/Magento/Ups/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-shipping": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-shipping": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/UrlRewrite/composer.json b/app/code/Magento/UrlRewrite/composer.json index ae89d8f05a90d61270060ec98da0106b0c916390..526e9ddb89ea238eb6f8452b2101852fffefd805 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|~5.6.0", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-catalog-url-rewrite": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/module-cms-url-rewrite": "0.42.0-beta4", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-catalog-url-rewrite": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/module-cms-url-rewrite": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/User/composer.json b/app/code/Magento/User/composer.json index 9f4842f6d67f0cd205619aa4cf9a4445279f74d0..dd4e422f4c957a107bd9947c9166a9c19a5b7d01 100644 --- a/app/code/Magento/User/composer.json +++ b/app/code/Magento/User/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-authorization": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-integration": "0.42.0-beta4", - "magento/module-store": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-require-js": "0.42.0-beta4", + "magento/module-authorization": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-integration": "0.42.0-beta5", + "magento/module-store": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-require-js": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index 22293faecc5144f527a98817794ab7e6ab85a539..33db2ad9aa8f5b4ddeee87946465e4913b59f724 100644 --- a/app/code/Magento/Usps/composer.json +++ b/app/code/Magento/Usps/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-shipping": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-shipping": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Webapi/composer.json b/app/code/Magento/Webapi/composer.json index 8e6634134a19419b7d2cabe9007de4df15aeaf02..9b6a7828b0b78d2f50b9b26908858ace0423b54c 100644 --- a/app/code/Magento/Webapi/composer.json +++ b/app/code/Magento/Webapi/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-authorization": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-integration": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-authorization": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-integration": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-user": "0.42.0-beta4" + "magento/module-user": "0.42.0-beta5" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Weee/composer.json b/app/code/Magento/Weee/composer.json index e8390ef55ea8c4aba0ddd68b532d18645ca4af90..854ad3aa4294823b0687d9de8114d7efdc5e6e2b 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-tax": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-directory": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-eav": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-quote": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-tax": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-directory": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-eav": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-quote": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index 367b733b445c5ada85f07063dea7a1091deb335a..345e79062cc40d82124501f23221a218782cfaf2 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|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-cms": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-cms": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index 64e96470ea8bda644c612b3f723096a38de3b3dd..4fc5acc0ebbde60d54d9bb1c6457bd8ae83d8d29 100644 --- a/app/code/Magento/Wishlist/composer.json +++ b/app/code/Magento/Wishlist/composer.json @@ -3,28 +3,28 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.42.0-beta4", - "magento/module-customer": "0.42.0-beta4", - "magento/module-catalog": "0.42.0-beta4", - "magento/module-core": "0.42.0-beta4", - "magento/module-checkout": "0.42.0-beta4", - "magento/module-theme": "0.42.0-beta4", - "magento/module-catalog-inventory": "0.42.0-beta4", - "magento/module-rss": "0.42.0-beta4", - "magento/module-backend": "0.42.0-beta4", - "magento/module-sales": "0.42.0-beta4", - "magento/module-grouped-product": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", - "magento/module-ui": "0.42.0-beta4", + "magento/module-store": "0.42.0-beta5", + "magento/module-customer": "0.42.0-beta5", + "magento/module-catalog": "0.42.0-beta5", + "magento/module-core": "0.42.0-beta5", + "magento/module-checkout": "0.42.0-beta5", + "magento/module-theme": "0.42.0-beta5", + "magento/module-catalog-inventory": "0.42.0-beta5", + "magento/module-rss": "0.42.0-beta5", + "magento/module-backend": "0.42.0-beta5", + "magento/module-sales": "0.42.0-beta5", + "magento/module-grouped-product": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", + "magento/module-ui": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-configurable-product": "0.42.0-beta4", - "magento/module-downloadable": "0.42.0-beta4", - "magento/module-bundle": "0.42.0-beta4" + "magento/module-configurable-product": "0.42.0-beta5", + "magento/module-downloadable": "0.42.0-beta5", + "magento/module-bundle": "0.42.0-beta5" }, "type": "magento2-module", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index 7081c61cc05e10aff97eab8499f1da3820ce4f74..2b1a901322dcb02e19f100ff97c03b09f29e37e2 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|~5.6.0", - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index 90ed8e25844025c525ed12aa7e52362275c6622b..a8cbfaa048b4592d49290e8edf40e9b3d37cb5da 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|~5.6.0", - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/frontend/Magento/luma/composer.json b/app/design/frontend/Magento/luma/composer.json index ad479e7f35ca538163e6a6e2723b1df6e4ccd914..37bf74e93d4e5b7abe1dabd1baaa83a25750cebc 100644 --- a/app/design/frontend/Magento/luma/composer.json +++ b/app/design/frontend/Magento/luma/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/theme-frontend-blank": "0.42.0-beta4", - "magento/framework": "0.42.0-beta4", + "magento/theme-frontend-blank": "0.42.0-beta5", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index 3e3ea88931ee72dfe6fc860e20bc920c57a6aedb..0879bcecd8de28409843441fe1877da66b28dea0 100644 --- a/app/i18n/magento/de_de/composer.json +++ b/app/i18n/magento/de_de/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-de_de", "description": "German (Germany) language", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "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 36452489550b9a0d21154eab938d30569f005d0d..4414fdc54585558cf9359ff608a4302a1fde154e 100644 --- a/app/i18n/magento/en_us/composer.json +++ b/app/i18n/magento/en_us/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-en_us", "description": "English (United States) language", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "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 c2129b9d9f67d45c53b4d9c939fe32b12d64a880..a74846002684c360240de260f3c32da844d0f9dd 100644 --- a/app/i18n/magento/es_es/composer.json +++ b/app/i18n/magento/es_es/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-es_es", "description": "Spanish (Spain) language", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "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 1b5f86ba485f07009f136bf0de9c49df2d20863f..d381bc48d6efb3d167150ef317adf42899624816 100644 --- a/app/i18n/magento/fr_fr/composer.json +++ b/app/i18n/magento/fr_fr/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-fr_fr", "description": "French (France) language", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "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 f1ea5b69ca99d248ef60621dfb618e7639a3bc8e..470273ce423a5e2fd3d5a1b13b61611bfd006f44 100644 --- a/app/i18n/magento/nl_nl/composer.json +++ b/app/i18n/magento/nl_nl/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-nl_nl", "description": "Dutch (Netherlands) language", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "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 a2e727e6b9ee9605948d14dd3b65f91f300184d5..c346c0177c61e24ca9b34b2e21fe969380b49418 100644 --- a/app/i18n/magento/pt_br/composer.json +++ b/app/i18n/magento/pt_br/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-pt_br", "description": "Portuguese (Brazil) language", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "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 75e74d0940dd4bc7ec5979f76babf42b2027c9f4..ef24f4717fa4dc35c29cccb5b5fd85ad10588aea 100644 --- a/app/i18n/magento/zh_cn/composer.json +++ b/app/i18n/magento/zh_cn/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-zh_cn", "description": "Chinese (China) language", - "version": "0.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.42.0-beta4", + "magento/framework": "0.42.0-beta5", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index 64f4d82c9d865f6e72914ece47865acfa5d54131..6de5bd137c7ec9937e0f137b62027bf6496c74f2 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.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/composer.lock b/composer.lock index 7b97eaf296a318fe02d104c15f032bca9537ba42..ea9bad3526069363200decb3a1acf7fcbc66f512 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "b2434120b753fdef32c2584eade97c9d", + "hash": "e24c7a4c699d06b73cd408289bb4f2d2", "packages": [ { "name": "composer/composer", diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeDataObject.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeDataObject.php index f6b61082458b361c76db197749a866d3cdc3d48e..54dbbdffc5accd97a9fe58f133001127574f8bf2 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeDataObject.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeDataObject.php @@ -9,9 +9,9 @@ namespace Magento\TestModuleMSC\Model\Data; use Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectInterface; +use Magento\Framework\Api\AbstractExtensibleObject; -class CustomAttributeDataObject extends \Magento\Framework\Api\AbstractExtensibleObject implements - CustomAttributeDataObjectInterface +class CustomAttributeDataObject extends AbstractExtensibleObject implements CustomAttributeDataObjectInterface { /** * @return string diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php deleted file mode 100644 index d5510f855ed522be2878d4dc137b4d9a4759da03..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Address\Billing; - -use Magento\Checkout\Service\V1\Data\Cart\Address; -use Magento\Checkout\Service\V1\Data\Cart\Address\Region; -use Magento\TestFramework\TestCase\WebapiAbstract; -use Magento\Webapi\Model\Rest\Config as RestConfig; - -class ReadServiceTest extends WebapiAbstract -{ - const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutAddressBillingReadServiceV1'; - const RESOURCE_PATH = '/V1/carts/'; - - /** - * @var \Magento\TestFramework\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testGetAddress() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - - /** @var \Magento\Quote\Model\Quote\Address $address */ - $address = $quote->getBillingAddress(); - - $data = [ - Address::KEY_COUNTRY_ID => $address->getCountryId(), - Address::KEY_ID => (int)$address->getId(), - Address::KEY_CUSTOMER_ID => $address->getCustomerId(), - Address::KEY_REGION => [ - Region::REGION => $address->getRegion(), - Region::REGION_ID => $address->getRegionId(), - Region::REGION_CODE => $address->getRegionCode(), - ], - Address::KEY_STREET => $address->getStreet(), - Address::KEY_COMPANY => $address->getCompany(), - Address::KEY_TELEPHONE => $address->getTelephone(), - Address::KEY_POSTCODE => $address->getPostcode(), - Address::KEY_CITY => $address->getCity(), - Address::KEY_FIRSTNAME => $address->getFirstname(), - Address::KEY_LASTNAME => $address->getLastname(), - Address::KEY_EMAIL => $address->getEmail(), - Address::CUSTOM_ATTRIBUTES_KEY => [['attribute_code' => 'disable_auto_group_change', 'value' => null]], - ]; - - $cartId = $quote->getId(); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/billing-address', - 'httpMethod' => RestConfig::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'GetAddress', - ], - ]; - - if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { - unset($data[Address::KEY_PREFIX]); - unset($data[Address::KEY_SUFFIX]); - unset($data[Address::KEY_MIDDLENAME]); - unset($data[Address::KEY_FAX]); - unset($data[Address::KEY_VAT_ID]); - } - - $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php deleted file mode 100644 index 21562162dad41a76b77b06eaecfefbf5ea1ef69e..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Address\Shipping; - -use Magento\Checkout\Service\V1\Data\Cart\Address; -use Magento\Checkout\Service\V1\Data\Cart\Address\Region; -use Magento\TestFramework\TestCase\WebapiAbstract; -use Magento\Webapi\Model\Rest\Config as RestConfig; - -class ReadServiceTest extends WebapiAbstract -{ - const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutAddressShippingReadServiceV1'; - const RESOURCE_PATH = '/V1/carts/'; - - /** - * @var \Magento\TestFramework\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testGetAddress() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - - /** @var \Magento\Quote\Model\Quote\Address $address */ - $address = $quote->getShippingAddress(); - - $data = [ - Address::KEY_COUNTRY_ID => $address->getCountryId(), - Address::KEY_ID => (int)$address->getId(), - Address::KEY_CUSTOMER_ID => $address->getCustomerId(), - Address::KEY_REGION => [ - Region::REGION => $address->getRegion(), - Region::REGION_ID => $address->getRegionId(), - Region::REGION_CODE => $address->getRegionCode(), - ], - Address::KEY_STREET => $address->getStreet(), - Address::KEY_COMPANY => $address->getCompany(), - Address::KEY_TELEPHONE => $address->getTelephone(), - Address::KEY_POSTCODE => $address->getPostcode(), - Address::KEY_CITY => $address->getCity(), - Address::KEY_FIRSTNAME => $address->getFirstname(), - Address::KEY_LASTNAME => $address->getLastname(), - Address::KEY_EMAIL => $address->getEmail(), - Address::CUSTOM_ATTRIBUTES_KEY => [['attribute_code' => 'disable_auto_group_change', 'value' => null]], - ]; - - $cartId = $quote->getId(); - - $serviceInfo = $this->getServiceInfo(); - $serviceInfo['rest']['resourcePath'] = str_replace('{cart_id}', $cartId, $serviceInfo['rest']['resourcePath']); - - if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { - unset($data[Address::KEY_PREFIX]); - unset($data[Address::KEY_SUFFIX]); - unset($data[Address::KEY_MIDDLENAME]); - unset($data[Address::KEY_FAX]); - unset($data[Address::KEY_VAT_ID]); - } - - $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php - * - * @expectedException \Exception - * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable - */ - public function testGetAddressOfQuoteWithVirtualProduct() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $cartId = $quote->load('test_order_with_virtual_product', 'reserved_order_id')->getId(); - - $serviceInfo = $this->getServiceInfo(); - $serviceInfo['rest']['resourcePath'] = str_replace('{cart_id}', $cartId, $serviceInfo['rest']['resourcePath']); - - $this->_webApiCall($serviceInfo, ["cartId" => $cartId]); - } - - /** - * @return array - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - protected function getServiceInfo() - { - return $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . '{cart_id}/shipping-address', - 'httpMethod' => RestConfig::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'GetAddress', - ], - ]; - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php deleted file mode 100644 index 4b8e7a4e32dcf154e99ae98945fd4b6bf1238845..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Coupon; - -use Magento\Checkout\Service\V1\Data\Cart\Coupon as Coupon; -use Magento\TestFramework\TestCase\WebapiAbstract; -use Magento\Webapi\Model\Rest\Config as RestConfig; - -class ReadServiceTest extends WebapiAbstract -{ - const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutCouponReadServiceV1'; - const RESOURCE_PATH = '/V1/carts/'; - - /** - * @var \Magento\TestFramework\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_coupon_saved.php - */ - public function testGet() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - $cartId = $quote->getId(); - $data = [ - Coupon::COUPON_CODE => $quote->getCouponCode(), - ]; - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/coupons', - 'httpMethod' => RestConfig::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Get', - ], - ]; - - $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Item/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Item/ReadServiceTest.php deleted file mode 100644 index af342783b7a84d74794b588cdc27a0f78babce12..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Item/ReadServiceTest.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Item; - -use Magento\Checkout\Service\V1\Data\Cart\Item as Item; -use Magento\TestFramework\TestCase\WebapiAbstract; -use Magento\Webapi\Model\Rest\Config as RestConfig; - -class ReadServiceTest extends WebapiAbstract -{ - const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutItemReadServiceV1'; - const RESOURCE_PATH = '/V1/carts/'; - - /** - * @var \Magento\TestFramework\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php - */ - public function testGetList() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_item_with_items', 'reserved_order_id'); - $cartId = $quote->getId(); - $output = []; - foreach ($quote->getAllItems() as $item) { - $data = [ - Item::ITEM_ID => $item->getId(), - Item::SKU => $item->getSku(), - Item::NAME => $item->getName(), - Item::PRICE => $item->getPrice(), - Item::QTY => $item->getQty(), - Item::PRODUCT_TYPE => $item->getProductType(), - ]; - - $output[] = $data; - } - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/items', - 'httpMethod' => RestConfig::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'GetList', - ], - ]; - - $requestData = ["cartId" => $cartId]; - $this->assertEquals($output, $this->_webApiCall($serviceInfo, $requestData)); - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php deleted file mode 100644 index 9a1a0126b96dc57a18f70f6e426bd6a88b77eba7..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\PaymentMethod; - -use Magento\Checkout\Service\V1\Data\PaymentMethod; -use Magento\TestFramework\TestCase\WebapiAbstract; -use Magento\Webapi\Model\Rest\Config as RestConfig; - -class ReadServiceTest extends WebapiAbstract -{ - const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutPaymentMethodReadServiceV1'; - const RESOURCE_PATH = '/V1/carts/'; - - /** - * @var \Magento\TestFramework\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testGetList() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - $cartId = $quote->getId(); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/payment-methods', - 'httpMethod' => RestConfig::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'getList', - ], - ]; - - $requestData = ["cartId" => $cartId]; - $requestResponse = $this->_webApiCall($serviceInfo, $requestData); - - $expectedResponse = [ - PaymentMethod::CODE => 'checkmo', - PaymentMethod::TITLE => 'Check / Money order', - ]; - - $this->assertGreaterThan(0, count($requestResponse)); - $this->assertContains($expectedResponse, $requestResponse); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_payment_saved.php - */ - public function testGetPayment() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1_with_payment', 'reserved_order_id'); - $cartId = $quote->getId(); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/selected-payment-methods', - 'httpMethod' => RestConfig::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'getPayment', - ], - ]; - - $requestData = ["cartId" => $cartId]; - $requestResponse = $this->_webApiCall($serviceInfo, $requestData); - - $this->assertArrayHasKey('method', $requestResponse); - $this->assertEquals('checkmo', $requestResponse['method']); - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php deleted file mode 100644 index 372088cd6e2a5c12fd4b84767447728ea25aa3c5..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\ShippingMethod; - -use Magento\TestFramework\ObjectManager; -use Magento\TestFramework\TestCase\WebapiAbstract; -use Magento\Webapi\Model\Rest\Config as RestConfig; - -class WriteServiceTest extends WebapiAbstract -{ - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var \Magento\Quote\Model\Quote - */ - protected $quote; - - protected function setUp() - { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - } - - protected function getServiceInfo() - { - return [ - 'rest' => [ - 'resourcePath' => '/V1/carts/' . $this->quote->getId() . '/selected-shipping-method', - 'httpMethod' => RestConfig::HTTP_METHOD_PUT, - ], - 'soap' => [ - 'service' => 'checkoutShippingMethodWriteServiceV1', - 'serviceVersion' => 'V1', - 'operation' => 'checkoutShippingMethodWriteServiceV1SetMethod', - ], - ]; - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetMethod() - { - $this->quote->load('test_order_1', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - - $requestData = [ - 'cartId' => $this->quote->getId(), - 'carrierCode' => 'flatrate', - 'methodCode' => 'flatrate', - ]; - $result = $this->_webApiCall($serviceInfo, $requestData); - $this->assertEquals(true, $result); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetMethodWrongMethod() - { - $this->quote->load('test_order_1', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - - $requestData = [ - 'cartId' => $this->quote->getId(), - 'carrierCode' => 'flatrate', - 'methodCode' => 'wrongMethod', - ]; - try { - $this->_webApiCall($serviceInfo, $requestData); - } catch (\SoapFault $e) { - $message = $e->getMessage(); - } catch (\Exception $e) { - $message = json_decode($e->getMessage())->message; - } - $this->assertEquals('Carrier with such method not found: flatrate, wrongMethod', $message); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php - */ - public function testSetMethodWithoutShippingAddress() - { - $this->quote->load('test_order_with_simple_product_without_address', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - - $requestData = [ - 'cartId' => $this->quote->getId(), - 'carrierCode' => 'flatrate', - 'methodCode' => 'flatrate', - ]; - try { - $this->_webApiCall($serviceInfo, $requestData); - } catch (\SoapFault $e) { - $message = $e->getMessage(); - } catch (\Exception $e) { - $message = json_decode($e->getMessage())->message; - } - $this->assertEquals('Shipping address is not set', $message); - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryTest.php similarity index 90% rename from dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryTest.php index 2e7bbc45370db071493ac57e783227d1181bcba9..392219a98f1469f8bac629e5fb666e4e858ac624 100644 --- a/dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryTest.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\CheckoutAgreements\Service\V1\Agreement; +namespace Magento\CheckoutAgreements\Api; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class ReadServiceTest extends WebapiAbstract +class CheckoutAgreementsRepositoryTest extends WebapiAbstract { /** * @var array @@ -19,9 +19,9 @@ class ReadServiceTest extends WebapiAbstract { $this->listServiceInfo = [ 'soap' => [ - 'service' => 'checkoutAgreementsAgreementReadServiceV1', + 'service' => 'checkoutAgreementsCheckoutAgreementsRepositoryV1', 'serviceVersion' => 'V1', - 'operation' => 'checkoutAgreementsAgreementReadServiceV1GetList', + 'operation' => 'checkoutAgreementsCheckoutAgreementsRepositoryV1getList', ], 'rest' => [ 'resourcePath' => '/V1/carts/licence/', @@ -74,12 +74,12 @@ class ReadServiceTest extends WebapiAbstract $agreements = $this->_webApiCall($this->listServiceInfo, []); $this->assertCount(1, $agreements); $agreementData = $agreements[0]; - $this->assertEquals($agreementModel->getId(), $agreementData['id']); + $this->assertEquals($agreementModel->getId(), $agreementData['agreement_id']); $this->assertEquals($agreementModel->getName(), $agreementData['name']); $this->assertEquals($agreementModel->getContent(), $agreementData['content']); $this->assertEquals($agreementModel->getContentHeight(), $agreementData['content_height']); $this->assertEquals($agreementModel->getCheckboxText(), $agreementData['checkbox_text']); - $this->assertEquals($agreementModel->getIsActive(), $agreementData['active']); - $this->assertEquals($agreementModel->getIsHtml(), $agreementData['html']); + $this->assertEquals($agreementModel->getIsActive(), $agreementData['is_active']); + $this->assertEquals($agreementModel->getIsHtml(), $agreementData['is_html']); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php index d4f800547232b22db12b28dcc42f7b4bb3552bac..c0ffddb6f33942b7fbfb650dc6947993e87f8bea 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php @@ -157,8 +157,6 @@ class CustomerMetadataTest extends WebapiAbstract $attributeMetadata = $this->_webApiCall($serviceInfo); - $this->assertCount(23, $attributeMetadata); - $firstName = $this->getAttributeMetadataDataProvider()[Customer::FIRSTNAME][1]; $validationResult = $this->checkMultipleAttributesValidationRules($firstName, $attributeMetadata); list($firstName, $attributeMetadata) = $validationResult; diff --git a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/CartRepositoryTest.php similarity index 63% rename from dev/tests/api-functional/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/CartRepositoryTest.php index 0f2b0fc0bac7b844346a0d99a1ecf54c5a1eb39d..b34a8ab1ff966768b881821568227a3fbc196895 100644 --- a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/CartRepositoryTest.php @@ -4,15 +4,15 @@ * See COPYING.txt for license details. */ -namespace Magento\GiftMessage\Service\V1; +namespace Magento\GiftMessage\Api; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class ReadServiceTest extends WebapiAbstract +class CartRepositoryTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'giftMessageReadServiceV1'; + const SERVICE_NAME = 'giftMessageCartRepositoryV1'; const RESOURCE_PATH = '/V1/carts/'; /** @@ -64,39 +64,43 @@ class ReadServiceTest extends WebapiAbstract /** * @magentoApiDataFixture Magento/GiftMessage/_files/quote_with_item_message.php */ - public function testGetItemMessage() + public function testSave() { + // sales/gift_options/allow_order must be set to 1 in system configuration + // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed + $this->markTestIncomplete('This test relies on system configuration state.'); /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); $quote->load('test_order_item_with_message', 'reserved_order_id'); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); - $product->load($product->getIdBySku('simple_with_message')); - $itemId = $quote->getItemByProduct($product)->getId(); - /** @var \Magento\Catalog\Model\Product $product */ + $cartId = $quote->getId(); $serviceInfo = [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/gift-message/' . $itemId, - 'httpMethod' => RestConfig::HTTP_METHOD_GET, + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/gift-message', + 'httpMethod' => RestConfig::HTTP_METHOD_POST, ], 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'getItemMessage', + 'operation' => self::SERVICE_NAME . 'Save', ], ]; - $expectedMessage = [ - 'recipient' => 'Jane Roe', - 'sender' => 'John Doe', - 'message' => 'Gift Message Text', + $requestData = [ + 'cartId' => $cartId, + 'giftMessage' => [ + 'recipient' => 'John Doe', + 'sender' => 'Jane Roe', + 'message' => 'Gift Message Text New', + ], ]; - - $requestData = ["cartId" => $cartId, "itemId" => $itemId]; - $resultMessage = $this->_webApiCall($serviceInfo, $requestData); - $this->assertCount(5, $resultMessage); - unset($resultMessage['gift_message_id']); - unset($resultMessage['customer_id']); - $this->assertEquals($expectedMessage, $resultMessage); + $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); + $quote->load('test_order_item_with_message', 'reserved_order_id'); + $quote->getGiftMessageId(); + /** @var \Magento\GiftMessage\Model\Message $message */ + $message = $this->objectManager->create('Magento\GiftMessage\Model\Message')->load($quote->getGiftMessageId()); + $this->assertEquals('John Doe', $message->getRecipient()); + $this->assertEquals('Jane Roe', $message->getSender()); + $this->assertEquals('Gift Message Text New', $message->getMessage()); } } diff --git a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/ItemRepositoryTest.php similarity index 67% rename from dev/tests/api-functional/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/ItemRepositoryTest.php index 501509ef33a63bbd7078812ff4c4bd14bfb0ab88..fe797f5fca2a55c626623d91eba06de51587904f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/ItemRepositoryTest.php @@ -6,15 +6,15 @@ // @codingStandardsIgnoreFile -namespace Magento\GiftMessage\Service\V1; +namespace Magento\GiftMessage\Api; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class WriteServiceTest extends WebapiAbstract +class ItemRepositoryTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'giftMessageWriteServiceV1'; + const SERVICE_NAME = 'giftMessageItemRepositoryV1'; const RESOURCE_PATH = '/V1/carts/'; /** @@ -30,50 +30,46 @@ class WriteServiceTest extends WebapiAbstract /** * @magentoApiDataFixture Magento/GiftMessage/_files/quote_with_item_message.php */ - public function testSetForQuote() + public function testGet() { - // sales/gift_options/allow_order must be set to 1 in system configuration - // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed - $this->markTestIncomplete('This test relies on system configuration state.'); /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); $quote->load('test_order_item_with_message', 'reserved_order_id'); - + $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product->load($product->getIdBySku('simple_with_message')); + $itemId = $quote->getItemByProduct($product)->getId(); + /** @var \Magento\Catalog\Model\Product $product */ $cartId = $quote->getId(); $serviceInfo = [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/gift-message', - 'httpMethod' => RestConfig::HTTP_METHOD_PUT, + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/gift-message/' . $itemId, + 'httpMethod' => RestConfig::HTTP_METHOD_GET, ], 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'SetForQuote', + 'operation' => self::SERVICE_NAME . 'Get', ], ]; - $requestData = [ - 'cartId' => $cartId, - 'giftMessage' => [ - 'recipient' => 'John Doe', - 'sender' => 'Jane Roe', - 'message' => 'Gift Message Text New', - ], + $expectedMessage = [ + 'recipient' => 'Jane Roe', + 'sender' => 'John Doe', + 'message' => 'Gift Message Text', ]; - $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); - $quote->load('test_order_item_with_message', 'reserved_order_id'); - $quote->getGiftMessageId(); - /** @var \Magento\GiftMessage\Model\Message $message */ - $message = $this->objectManager->create('Magento\GiftMessage\Model\Message')->load($quote->getGiftMessageId()); - $this->assertEquals('John Doe', $message->getRecipient()); - $this->assertEquals('Jane Roe', $message->getSender()); - $this->assertEquals('Gift Message Text New', $message->getMessage()); + + $requestData = ["cartId" => $cartId, "itemId" => $itemId]; + $resultMessage = $this->_webApiCall($serviceInfo, $requestData); + $this->assertCount(5, $resultMessage); + unset($resultMessage['gift_message_id']); + unset($resultMessage['customer_id']); + $this->assertEquals($expectedMessage, $resultMessage); } /** * @magentoApiDataFixture Magento/GiftMessage/_files/quote_with_item_message.php */ - public function testSetForItem() + public function testSave() { // sales/gift_options/allow_items must be set to 1 in system configuration // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed @@ -88,12 +84,12 @@ class WriteServiceTest extends WebapiAbstract $serviceInfo = [ 'rest' => [ 'resourcePath' => self::RESOURCE_PATH . $cartId . '/gift-message/' . $itemId, - 'httpMethod' => RestConfig::HTTP_METHOD_PUT, + 'httpMethod' => RestConfig::HTTP_METHOD_POST, ], 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'SetForItem', + 'operation' => self::SERVICE_NAME . 'Save', ], ]; diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php similarity index 50% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php index 4644c779b9bb50895ccda8993e7652be20049af3..ec4e8a0d5089878d61bbde2dda7be3194c552407 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php @@ -4,15 +4,16 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Address\Billing; +namespace Magento\Quote\Api; +use Magento\Quote\Api\Data\AddressInterface; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class WriteServiceTest extends WebapiAbstract +class BillingAddressManagementTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutAddressBillingWriteServiceV1'; + const SERVICE_NAME = 'quoteBillingAddressManagementV1'; const RESOURCE_PATH = '/V1/carts/'; /** @@ -20,15 +21,55 @@ class WriteServiceTest extends WebapiAbstract */ protected $objectManager; - /** - * @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder - */ - protected $builder; - protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->builder = $this->objectManager->create('Magento\Checkout\Service\V1\Data\Cart\AddressBuilder'); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + */ + public function testGetAddress() + { + $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote->load('test_order_1', 'reserved_order_id'); + + /** @var \Magento\Quote\Model\Quote\Address $address */ + $address = $quote->getBillingAddress(); + + $data = [ + AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), + AddressInterface::KEY_ID => (int)$address->getId(), + AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), + AddressInterface::REGION => $address->getRegion(), + AddressInterface::REGION_ID => $address->getRegionId(), + AddressInterface::REGION_CODE => $address->getRegionCode(), + AddressInterface::KEY_STREET => $address->getStreet(), + AddressInterface::KEY_COMPANY => $address->getCompany(), + AddressInterface::KEY_TELEPHONE => $address->getTelephone(), + AddressInterface::KEY_POSTCODE => $address->getPostcode(), + AddressInterface::KEY_CITY => $address->getCity(), + AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), + AddressInterface::KEY_LASTNAME => $address->getLastname(), + AddressInterface::KEY_EMAIL => $address->getEmail() + ]; + + $cartId = $quote->getId(); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/billing-address', + 'httpMethod' => RestConfig::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Get', + ], + ]; + + $requestData = ["cartId" => $cartId]; + $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); } /** @@ -48,7 +89,7 @@ class WriteServiceTest extends WebapiAbstract 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'SetAddress', + 'operation' => self::SERVICE_NAME . 'Assign', ], ]; @@ -59,11 +100,9 @@ class WriteServiceTest extends WebapiAbstract 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', - 'region' => [ - 'region_id' => 12, - 'region' => 'California', - 'region_code' => 'CA', - ], + 'region_id' => 12, + 'region' => 'California', + 'region_code' => 'CA', 'postcode' => '0985432', 'country_id' => 'US', 'telephone' => '88776655', @@ -71,7 +110,7 @@ class WriteServiceTest extends WebapiAbstract ]; $requestData = [ "cartId" => $quote->getId(), - 'addressData' => $addressData, + 'address' => $addressData, ]; $addressId = $this->_webApiCall($serviceInfo, $requestData); @@ -79,16 +118,15 @@ class WriteServiceTest extends WebapiAbstract //reset $quote to reload data $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); $quote->load('test_order_1', 'reserved_order_id'); - $savedData = $quote->getBillingAddress()->getData(); + $address = $quote->getBillingAddress(); + $address->getRegionCode(); + $savedData = $address->getData(); $this->assertEquals($addressId, $savedData['address_id']); //custom checks for street, region and address_type foreach ($addressData['street'] as $streetLine) { $this->assertContains($streetLine, $quote->getBillingAddress()->getStreet()); } unset($addressData['street']); - $this->assertEquals($addressData['region']['region_id'], $savedData['region_id']); - $this->assertEquals($addressData['region']['region'], $savedData['region']); - unset($addressData['region']); $this->assertEquals('billing', $savedData['address_type']); //check the rest of fields foreach ($addressData as $key => $value) { diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php similarity index 61% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php index 4faa6cd4ffebd6b4fcdf7209a1b7c492eb02162e..3938820417255b9ff5046eee897b84ee286df65a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php @@ -1,18 +1,18 @@ <?php /** + * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - -namespace Magento\Checkout\Service\V1\Item; +namespace Magento\Quote\Api; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class WriteServiceTest extends WebapiAbstract +class CartItemRepositoryTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutItemWriteServiceV1'; + const SERVICE_NAME = 'quoteCartItemRepositoryV1'; const RESOURCE_PATH = '/V1/carts/'; /** @@ -25,12 +25,53 @@ class WriteServiceTest extends WebapiAbstract $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); } + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php + */ + public function testGetList() + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote->load('test_order_item_with_items', 'reserved_order_id'); + $cartId = $quote->getId(); + $output = []; + /** @var \Magento\Quote\Api\Data\CartItemInterface $item */ + foreach ($quote->getAllItems() as $item) { + $data = [ + 'item_id' => $item->getItemId(), + 'sku' => $item->getSku(), + 'name' => $item->getName(), + 'price' => $item->getPrice(), + 'qty' => $item->getQty(), + 'product_type' => $item->getProductType(), + 'quote_id' => $item->getQuoteId() + ]; + + $output[] = $data; + } + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/items', + 'httpMethod' => RestConfig::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'GetList', + ], + ]; + + $requestData = ["cartId" => $cartId]; + $this->assertEquals($output, $this->_webApiCall($serviceInfo, $requestData)); + } + /** * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testAddItem() { + /** @var \Magento\Catalog\Model\Product $product */ $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(2); $productSku = $product->getSku(); /** @var \Magento\Quote\Model\Quote $quote */ @@ -39,21 +80,21 @@ class WriteServiceTest extends WebapiAbstract $cartId = $quote->getId(); $serviceInfo = [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/items', + 'resourcePath' => self::RESOURCE_PATH . 'items', 'httpMethod' => RestConfig::HTTP_METHOD_POST, ], 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'AddItem', + 'operation' => self::SERVICE_NAME . 'Save', ], ]; $requestData = [ - "cartId" => $cartId, - "data" => [ + "cartItem" => [ "sku" => $productSku, "qty" => 7, + "quote_id" => $cartId, ], ]; $this->_webApiCall($serviceInfo, $requestData); @@ -82,7 +123,7 @@ class WriteServiceTest extends WebapiAbstract 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'RemoveItem', + 'operation' => self::SERVICE_NAME . 'DeleteById', ], ]; @@ -111,27 +152,38 @@ class WriteServiceTest extends WebapiAbstract $itemId = $quote->getItemByProduct($product)->getId(); $serviceInfo = [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/items/' . $itemId, + 'resourcePath' => self::RESOURCE_PATH . 'items/' . $itemId, 'httpMethod' => RestConfig::HTTP_METHOD_PUT, ], 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'UpdateItem', + 'operation' => self::SERVICE_NAME . 'Save', ], ]; - $requestData = [ - "cartId" => $cartId, - "itemId" => $itemId, - "data" => [ - "qty" => 5, - ], - ]; - $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); + if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { + $requestData = [ + "cartItem" => [ + "qty" => 5, + "quote_id" => $cartId, + "itemId" => $itemId, + ], + ]; + } else { + $requestData = [ + "cartItem" => [ + "qty" => 5, + "quote_id" => $cartId, + ], + ]; + } + $this->_webApiCall($serviceInfo, $requestData); $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); $quote->load('test_order_item_with_items', 'reserved_order_id'); $this->assertTrue($quote->hasProductId(1)); - $this->assertEquals(5, $quote->getItemByProduct($product)->getQty()); + $item = $quote->getItemByProduct($product); + $this->assertEquals(5, $item->getQty()); + $this->assertEquals($itemId, $item->getItemId()); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php similarity index 68% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php index 70f3ba753b99bb0c189690edc10cacc17a1240fb..4a4be8cbde228eb1a957eebb672d9e8be4a7e144 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php @@ -4,15 +4,15 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Cart; +namespace Magento\Quote\Api; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class WriteServiceTest extends WebapiAbstract +class CartManagementTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutCartWriteServiceV1'; + const SERVICE_NAME = 'quoteCartManagementV1'; const RESOURCE_PATH = '/V1/carts/'; protected $createdQuotes = []; @@ -37,11 +37,12 @@ class WriteServiceTest extends WebapiAbstract 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Create', + 'operation' => self::SERVICE_NAME . 'CreateEmptyCart', ], ]; - $quoteId = $this->_webApiCall($serviceInfo); + $requestData = ['storeId' => 1]; + $quoteId = $this->_webApiCall($serviceInfo, $requestData); $this->assertGreaterThan(0, $quoteId); $this->createdQuotes[] = $quoteId; } @@ -77,15 +78,16 @@ class WriteServiceTest extends WebapiAbstract 'httpMethod' => RestConfig::HTTP_METHOD_PUT, ], 'soap' => [ - 'service' => 'checkoutCartWriteServiceV1', + 'service' => self::SERVICE_NAME, 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartWriteServiceV1AssignCustomer', + 'operation' => self::SERVICE_NAME . 'AssignCustomer', ], ]; $requestData = [ 'cartId' => $cartId, 'customerId' => $customerId, + 'storeId' => 1, ]; // Cart must be anonymous (see fixture) $this->assertEmpty($quote->getCustomerId()); @@ -112,8 +114,8 @@ class WriteServiceTest extends WebapiAbstract $serviceInfo = [ 'soap' => [ 'serviceVersion' => 'V1', - 'service' => 'checkoutCartWriteServiceV1', - 'operation' => 'checkoutCartWriteServiceV1AssignCustomer', + 'service' => self::SERVICE_NAME, + 'operation' => self::SERVICE_NAME . 'AssignCustomer', ], 'rest' => [ 'resourcePath' => '/V1/carts/' . $cartId, @@ -123,6 +125,7 @@ class WriteServiceTest extends WebapiAbstract $requestData = [ 'cartId' => $cartId, 'customerId' => $customerId, + 'storeId' => 1, ]; $this->_webApiCall($serviceInfo, $requestData); @@ -138,9 +141,9 @@ class WriteServiceTest extends WebapiAbstract $customerId = 1; $serviceInfo = [ 'soap' => [ - 'service' => 'checkoutCartWriteServiceV1', + 'service' => self::SERVICE_NAME, 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartWriteServiceV1AssignCustomer', + 'operation' => self::SERVICE_NAME . 'AssignCustomer', ], 'rest' => [ 'resourcePath' => '/V1/carts/' . $cartId, @@ -150,6 +153,7 @@ class WriteServiceTest extends WebapiAbstract $requestData = [ 'cartId' => $cartId, 'customerId' => $customerId, + 'storeId' => 1, ]; $this->_webApiCall($serviceInfo, $requestData); @@ -175,15 +179,16 @@ class WriteServiceTest extends WebapiAbstract 'resourcePath' => '/V1/carts/' . $cartId, ], 'soap' => [ - 'service' => 'checkoutCartWriteServiceV1', + 'service' => self::SERVICE_NAME, 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartWriteServiceV1AssignCustomer', + 'operation' => self::SERVICE_NAME . 'AssignCustomer', ], ]; $requestData = [ 'cartId' => $cartId, 'customerId' => $customerId, + 'storeId' => 1, ]; $this->_webApiCall($serviceInfo, $requestData); } @@ -207,9 +212,9 @@ class WriteServiceTest extends WebapiAbstract $serviceInfo = [ 'soap' => [ - 'service' => 'checkoutCartWriteServiceV1', + 'service' => self::SERVICE_NAME, 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartWriteServiceV1AssignCustomer', + 'operation' => self::SERVICE_NAME . 'AssignCustomer', ], 'rest' => [ 'httpMethod' => RestConfig::HTTP_METHOD_PUT, @@ -220,6 +225,7 @@ class WriteServiceTest extends WebapiAbstract $requestData = [ 'cartId' => $cartId, 'customerId' => $customerId, + 'storeId' => 1, ]; $this->_webApiCall($serviceInfo, $requestData); } @@ -247,8 +253,8 @@ class WriteServiceTest extends WebapiAbstract $serviceInfo = [ 'soap' => [ - 'service' => 'checkoutCartWriteServiceV1', - 'operation' => 'checkoutCartWriteServiceV1AssignCustomer', + 'service' => self::SERVICE_NAME, + 'operation' => self::SERVICE_NAME . 'AssignCustomer', 'serviceVersion' => 'V1', ], 'rest' => [ @@ -260,6 +266,7 @@ class WriteServiceTest extends WebapiAbstract $requestData = [ 'cartId' => $cartId, 'customerId' => $customerId, + 'storeId' => 1, ]; $this->_webApiCall($serviceInfo, $requestData); } @@ -267,17 +274,16 @@ class WriteServiceTest extends WebapiAbstract /** * @magentoApiDataFixture Magento/Checkout/_files/quote_with_check_payment.php */ - public function testOrderPlacesOrder() + public function testPlaceOrder() { /** @var $quote \Magento\Quote\Model\Quote */ $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test_order_1', 'reserved_order_id'); - $cartId = $quote->getId(); $serviceInfo = [ 'soap' => [ - 'service' => 'checkoutCartWriteServiceV1', - 'operation' => 'checkoutCartWriteServiceV1Order', + 'service' => 'quoteCartManagementV1', + 'operation' => 'quoteCartManagementV1PlaceOrder', 'serviceVersion' => 'V1', ], 'rest' => [ @@ -286,15 +292,76 @@ class WriteServiceTest extends WebapiAbstract ], ]; - $requestData = [ - 'cartId' => $cartId, - ]; - $this->_webApiCall($serviceInfo, $requestData); + $orderId = $this->_webApiCall($serviceInfo, ['cartId' => $cartId]); + /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order')->load(1); + $order = $this->objectManager->create('Magento\Sales\Model\Order')->load($orderId); $items = $order->getAllItems(); $this->assertCount(1, $items); $this->assertEquals('Simple Product', $items[0]->getName()); $quote->delete(); } + + /** + * @magentoApiDataFixture Magento/Sales/_files/quote_with_customer.php + */ + public function testGetCartForCustomer() + { + $cart = $this->getCart('test01'); + $customerId = $cart->getCustomer()->getId(); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/customer/' . $customerId . '/cart', + 'httpMethod' => RestConfig::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => 'quoteCartManagementV1', + 'serviceVersion' => 'V1', + 'operation' => 'quoteCartManagementV1GetCartForCustomer', + ], + ]; + + $requestData = ['customerId' => $customerId]; + $cartData = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertEquals($cart->getId(), $cartData['id']); + $this->assertEquals($cart->getCreatedAt(), $cartData['created_at']); + $this->assertEquals($cart->getUpdatedAt(), $cartData['updated_at']); + $this->assertEquals($cart->getIsActive(), $cartData['is_active']); + $this->assertEquals($cart->getIsVirtual(), $cartData['is_virtual']); + $this->assertEquals($cart->getOrigOrderId(), $cartData['orig_order_id']); + $this->assertEquals($cart->getItemsCount(), $cartData['items_count']); + $this->assertEquals($cart->getItemsQty(), $cartData['items_qty']); + + $this->assertContains('customer', $cartData); + $this->assertEquals(false, $cartData['customer_is_guest']); + $this->assertContains('currency', $cartData); + $this->assertEquals($cart->getGlobalCurrencyCode(), $cartData['currency']['global_currency_code']); + $this->assertEquals($cart->getBaseCurrencyCode(), $cartData['currency']['base_currency_code']); + $this->assertEquals($cart->getQuoteCurrencyCode(), $cartData['currency']['quote_currency_code']); + $this->assertEquals($cart->getStoreCurrencyCode(), $cartData['currency']['store_currency_code']); + $this->assertEquals($cart->getBaseToGlobalRate(), $cartData['currency']['base_to_global_rate']); + $this->assertEquals($cart->getBaseToQuoteRate(), $cartData['currency']['base_to_quote_rate']); + $this->assertEquals($cart->getStoreToBaseRate(), $cartData['currency']['store_to_base_rate']); + $this->assertEquals($cart->getStoreToQuoteRate(), $cartData['currency']['store_to_quote_rate']); + } + + /** + * Retrieve quote by given reserved order ID + * + * @param string $reservedOrderId + * @return \Magento\Quote\Model\Quote + * @throws \InvalidArgumentException + */ + protected function getCart($reservedOrderId) + { + /** @var $cart \Magento\Quote\Model\Quote */ + $cart = $this->objectManager->get('Magento\Quote\Model\Quote'); + $cart->load($reservedOrderId, 'reserved_order_id'); + if (!$cart->getId()) { + throw new \InvalidArgumentException('There is no quote with provided reserved order ID.'); + } + return $cart; + } } diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php similarity index 61% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php index c5f621411d6e96cea138e9e4fe17bea54e506bad..428d5cceeae59078e7c8c8225ea64d58b8d29818 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php @@ -3,17 +3,18 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Cart; +namespace Magento\Quote\Api; -use Magento\Checkout\Service\V1\Data\Cart; use Magento\Framework\Api\FilterBuilder; use Magento\Framework\Api\SearchCriteria; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Api\SortOrderBuilder; +use Magento\Framework\Api\SortOrder; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class ReadServiceTest extends WebapiAbstract +class CartRepositoryTest extends WebapiAbstract { /** * @var ObjectManager @@ -92,9 +93,9 @@ class ReadServiceTest extends WebapiAbstract 'httpMethod' => RestConfig::HTTP_METHOD_GET, ], 'soap' => [ - 'service' => 'checkoutCartReadServiceV1', + 'service' => 'quoteCartRepositoryV1', 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartReadServiceV1GetCart', + 'operation' => 'quoteCartRepositoryV1Get', ], ]; @@ -103,18 +104,14 @@ class ReadServiceTest extends WebapiAbstract $this->assertEquals($cart->getId(), $cartData['id']); $this->assertEquals($cart->getCreatedAt(), $cartData['created_at']); $this->assertEquals($cart->getUpdatedAt(), $cartData['updated_at']); - $this->assertEquals($cart->getStoreId(), $cartData['store_id']); $this->assertEquals($cart->getIsActive(), $cartData['is_active']); $this->assertEquals($cart->getIsVirtual(), $cartData['is_virtual']); $this->assertEquals($cart->getOrigOrderId(), $cartData['orig_order_id']); $this->assertEquals($cart->getItemsCount(), $cartData['items_count']); $this->assertEquals($cart->getItemsQty(), $cartData['items_qty']); - + //following checks will be uncommented when all cart related services are ready $this->assertContains('customer', $cartData); - $this->assertEquals(1, $cartData['customer']['is_guest']); - $this->assertContains('totals', $cartData); - $this->assertEquals($cart->getSubtotal(), $cartData['totals']['subtotal']); - $this->assertEquals($cart->getGrandTotal(), $cartData['totals']['grand_total']); + $this->assertEquals(true, $cartData['customer_is_guest']); $this->assertContains('currency', $cartData); $this->assertEquals($cart->getGlobalCurrencyCode(), $cartData['currency']['global_currency_code']); $this->assertEquals($cart->getBaseCurrencyCode(), $cartData['currency']['base_currency_code']); @@ -136,9 +133,9 @@ class ReadServiceTest extends WebapiAbstract $serviceInfo = [ 'soap' => [ - 'service' => 'checkoutCartReadServiceV1', + 'service' => 'quoteCartRepositoryV1', 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartReadServiceV1GetCart', + 'operation' => 'quoteCartRepositoryV1Get', ], 'rest' => [ 'resourcePath' => '/V1/carts/' . $cartId, @@ -151,60 +148,24 @@ class ReadServiceTest extends WebapiAbstract } /** - * @magentoApiDataFixture Magento/Sales/_files/quote_with_customer.php + * @magentoApiDataFixture Magento/Sales/_files/quote.php */ - public function testGetCartForCustomer() + public function testGetList() { $cart = $this->getCart('test01'); - $customerId = $cart->getCustomer()->getId(); $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/customer/' . $customerId . '/cart', - 'httpMethod' => RestConfig::HTTP_METHOD_GET, + 'resourcePath' => '/V1/carts', + 'httpMethod' => RestConfig::HTTP_METHOD_PUT, ], 'soap' => [ - 'service' => 'checkoutCartReadServiceV1', + 'service' => 'quoteCartRepositoryV1', 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartReadServiceV1GetCartForCustomer', + 'operation' => 'quoteCartRepositoryV1GetList', ], ]; - $requestData = ['customerId' => $customerId]; - $cartData = $this->_webApiCall($serviceInfo, $requestData); - $this->assertEquals($cart->getId(), $cartData['id']); - $this->assertEquals($cart->getCreatedAt(), $cartData['created_at']); - $this->assertEquals($cart->getUpdatedAt(), $cartData['updated_at']); - $this->assertEquals($cart->getStoreId(), $cartData['store_id']); - $this->assertEquals($cart->getIsActive(), $cartData['is_active']); - $this->assertEquals($cart->getIsVirtual(), $cartData['is_virtual']); - $this->assertEquals($cart->getOrigOrderId(), $cartData['orig_order_id']); - $this->assertEquals($cart->getItemsCount(), $cartData['items_count']); - $this->assertEquals($cart->getItemsQty(), $cartData['items_qty']); - - $this->assertContains('customer', $cartData); - $this->assertEquals(0, $cartData['customer']['is_guest']); - $this->assertContains('totals', $cartData); - $this->assertEquals($cart->getSubtotal(), $cartData['totals']['subtotal']); - $this->assertEquals($cart->getGrandTotal(), $cartData['totals']['grand_total']); - $this->assertContains('currency', $cartData); - $this->assertEquals($cart->getGlobalCurrencyCode(), $cartData['currency']['global_currency_code']); - $this->assertEquals($cart->getBaseCurrencyCode(), $cartData['currency']['base_currency_code']); - $this->assertEquals($cart->getQuoteCurrencyCode(), $cartData['currency']['quote_currency_code']); - $this->assertEquals($cart->getStoreCurrencyCode(), $cartData['currency']['store_currency_code']); - $this->assertEquals($cart->getBaseToGlobalRate(), $cartData['currency']['base_to_global_rate']); - $this->assertEquals($cart->getBaseToQuoteRate(), $cartData['currency']['base_to_quote_rate']); - $this->assertEquals($cart->getStoreToBaseRate(), $cartData['currency']['store_to_base_rate']); - $this->assertEquals($cart->getStoreToQuoteRate(), $cartData['currency']['store_to_quote_rate']); - } - - /** - * @magentoApiDataFixture Magento/Sales/_files/quote.php - */ - public function testGetCartList() - { - $cart = $this->getCart('test01'); - // The following two filters are used as alternatives. The target cart does not match the first one. $grandTotalFilter = $this->filterBuilder->setField('grand_total') ->setConditionType('gteq') @@ -217,11 +178,11 @@ class ReadServiceTest extends WebapiAbstract $yesterdayDate = (new \DateTime())->sub(new \DateInterval('P1D'))->format('Y-m-d'); $tomorrowDate = (new \DateTime())->add(new \DateInterval('P1D'))->format('Y-m-d'); - $minCreatedAtFilter = $this->filterBuilder->setField(Cart::CREATED_AT) + $minCreatedAtFilter = $this->filterBuilder->setField('created_at') ->setConditionType('gteq') ->setValue($yesterdayDate) ->create(); - $maxCreatedAtFilter = $this->filterBuilder->setField(Cart::CREATED_AT) + $maxCreatedAtFilter = $this->filterBuilder->setField('created_at') ->setConditionType('lteq') ->setValue($tomorrowDate) ->create(); @@ -235,17 +196,6 @@ class ReadServiceTest extends WebapiAbstract $searchCriteria = $this->searchBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchCriteria]; - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => '/V1/carts' . '?' . http_build_query($requestData), - 'httpMethod' => RestConfig::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => 'checkoutCartReadServiceV1', - 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartReadServiceV1GetCartList', - ], - ]; $searchResult = $this->_webApiCall($serviceInfo, $requestData); $this->assertArrayHasKey('total_count', $searchResult); $this->assertEquals(1, $searchResult['total_count']); @@ -257,21 +207,28 @@ class ReadServiceTest extends WebapiAbstract $this->assertEquals($cart->getCreatedAt(), $cartData['created_at']); $this->assertEquals($cart->getUpdatedAt(), $cartData['updated_at']); $this->assertEquals($cart->getIsActive(), $cartData['is_active']); - $this->assertEquals($cart->getStoreId(), $cartData['store_id']); - $this->assertContains('totals', $cartData); - $this->assertEquals($cart->getBaseSubtotal(), $cartData['totals']['base_subtotal']); - $this->assertEquals($cart->getBaseGrandTotal(), $cartData['totals']['base_grand_total']); - $this->assertContains('customer', $cartData); - $this->assertEquals(1, $cartData['customer']['is_guest']); + $this->assertContains('customer_is_guest', $cartData); + $this->assertEquals(1, $cartData['customer_is_guest']); } /** * @expectedException \Exception - * @expectedExceptionMessage Field 'invalid_field' cannot be used for search. */ - public function testGetCartListThrowsExceptionIfProvidedSearchFieldIsInvalid() + public function testGetListThrowsExceptionIfProvidedSearchFieldIsInvalid() { + $serviceInfo = [ + 'soap' => [ + 'service' => 'quoteCartRepositoryV1', + 'serviceVersion' => 'V1', + 'operation' => 'quoteCartRepositoryV1GetList', + ], + 'rest' => [ + 'resourcePath' => '/V1/carts', + 'httpMethod' => RestConfig::HTTP_METHOD_PUT, + ], + ]; + $invalidFilter = $this->filterBuilder->setField('invalid_field') ->setConditionType('eq') ->setValue(0) @@ -280,17 +237,6 @@ class ReadServiceTest extends WebapiAbstract $this->searchBuilder->addFilter([$invalidFilter]); $searchCriteria = $this->searchBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchCriteria]; - $serviceInfo = [ - 'soap' => [ - 'service' => 'checkoutCartReadServiceV1', - 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartReadServiceV1GetCartList', - ], - 'rest' => [ - 'resourcePath' => '/V1/carts' . '?' . http_build_query($requestData), - 'httpMethod' => RestConfig::HTTP_METHOD_GET, - ], - ]; $this->_webApiCall($serviceInfo, $requestData); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/TotalsServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php similarity index 94% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/TotalsServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php index 309f92958af160b4f56ad9cb875774d916ddfb58..d5a98ef36eb99e80c509f86311cc7ca69709e9f5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Cart/TotalsServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php @@ -4,17 +4,17 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Cart; +namespace Magento\Quote\Api; -use Magento\Checkout\Service\V1\Data\Cart\Totals; -use Magento\Checkout\Service\V1\Data\Cart\Totals\Item as ItemTotals; +use Magento\Quote\Model\Cart\Totals; +use Magento\Quote\Model\Cart\Totals\Item as ItemTotals; use Magento\Framework\Api\FilterBuilder; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class TotalsServiceTest extends WebapiAbstract +class CartTotalRepositoryTest extends WebapiAbstract { /** * @var ObjectManager @@ -109,9 +109,9 @@ class TotalsServiceTest extends WebapiAbstract { return [ 'soap' => [ - 'service' => 'checkoutCartTotalsServiceV1', + 'service' => 'quoteCartTotalRepositoryV1', 'serviceVersion' => 'V1', - 'operation' => 'checkoutCartTotalsServiceV1GetTotals', + 'operation' => 'quoteCartTotalRepositoryV1get', ], 'rest' => [ 'resourcePath' => '/V1/carts/' . $cartId . '/totals', diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php similarity index 74% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php index 0599c1d885fd131b1a6d35082c5fc50b3b2a2612..07d86c26ddd64da9594d2b0996aa4bc0dda45af7 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php @@ -1,19 +1,19 @@ <?php /** + * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Coupon; +namespace Magento\Quote\Api; -use Magento\Checkout\Service\V1\Data\Cart\Coupon; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class WriteServiceTest extends WebapiAbstract +class CouponManagementTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutCouponWriteServiceV1'; + const SERVICE_NAME = 'quoteCouponManagementV1'; const RESOURCE_PATH = '/V1/carts/'; /** @@ -26,6 +26,32 @@ class WriteServiceTest extends WebapiAbstract $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); } + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_coupon_saved.php + */ + public function testGet() + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote->load('test_order_1', 'reserved_order_id'); + $cartId = $quote->getId(); + $couponCode = $quote->getCouponCode(); + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/coupons/' , + 'httpMethod' => RestConfig::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Get', + ], + ]; + + $requestData = ["cartId" => $cartId]; + $this->assertEquals($couponCode, $this->_webApiCall($serviceInfo, $requestData)); + } + /** * @magentoApiDataFixture Magento/Checkout/_files/quote_with_coupon_saved.php */ @@ -43,7 +69,7 @@ class WriteServiceTest extends WebapiAbstract 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Delete', + 'operation' => self::SERVICE_NAME . 'Remove', ], ]; $requestData = ["cartId" => $cartId]; @@ -64,9 +90,11 @@ class WriteServiceTest extends WebapiAbstract $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); + $couponCode = 'invalid_coupon_code'; + $serviceInfo = [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/coupons', + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/coupons/' . $couponCode, 'httpMethod' => RestConfig::HTTP_METHOD_PUT, ], 'soap' => [ @@ -76,11 +104,9 @@ class WriteServiceTest extends WebapiAbstract ], ]; - $data = [Coupon::COUPON_CODE => 'invalid_coupon_code']; - $requestData = [ "cartId" => $cartId, - "couponCodeData" => $data, + "couponCode" => $couponCode, ]; $this->_webApiCall($serviceInfo, $requestData); @@ -96,10 +122,12 @@ class WriteServiceTest extends WebapiAbstract $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); $quote->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); - + $salesRule = $this->objectManager->create('Magento\SalesRule\Model\Rule'); + $salesRule->load('Test Coupon', 'name'); + $couponCode = $salesRule->getCouponCode(); $serviceInfo = [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/coupons', + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/coupons/' . $couponCode, 'httpMethod' => RestConfig::HTTP_METHOD_PUT, ], 'soap' => [ @@ -109,15 +137,9 @@ class WriteServiceTest extends WebapiAbstract ], ]; - $salesRule = $this->objectManager->create('Magento\SalesRule\Model\Rule'); - $salesRule->load('Test Coupon', 'name'); - - $couponCode = $salesRule->getCouponCode(); - $data = [Coupon::COUPON_CODE => $couponCode]; - $requestData = [ "cartId" => $cartId, - "couponCodeData" => $data, + "couponCode" => $couponCode, ]; $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php similarity index 63% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php index a4b9a3f485502c5c4026fcf2f315f3ec1e4c1ce0..d1f11c14fecfc3ae6960e65f8f1563180d4c27aa 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php @@ -3,15 +3,14 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\PaymentMethod; +namespace Magento\Quote\Api; -use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class WriteServiceTest extends WebapiAbstract +class PaymentMethodManagementTest extends \Magento\TestFramework\TestCase\WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutPaymentMethodWriteServiceV1'; + const SERVICE_NAME = 'quotePaymentMethodManagementV1'; const RESOURCE_PATH = '/V1/carts/'; /** @@ -30,7 +29,7 @@ class WriteServiceTest extends WebapiAbstract public function testReSetPayment() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); $quote->load('test_order_1_with_payment', 'reserved_order_id'); $cartId = $quote->getId(); @@ -58,7 +57,7 @@ class WriteServiceTest extends WebapiAbstract ], ]; - $this->_webApiCall($serviceInfo, $requestData); + $this->assertNotNull($this->_webApiCall($serviceInfo, $requestData)); } /** @@ -67,7 +66,7 @@ class WriteServiceTest extends WebapiAbstract public function testSetPaymentWithVirtualProduct() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); $quote->load('test_order_with_virtual_product', 'reserved_order_id'); $cartId = $quote->getId(); @@ -103,7 +102,7 @@ class WriteServiceTest extends WebapiAbstract public function testSetPaymentWithSimpleProduct() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -142,7 +141,7 @@ class WriteServiceTest extends WebapiAbstract public function testSetPaymentWithVirtualProductWithoutAddress() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); $quote->load('test_order_with_virtual_product_without_address', 'reserved_order_id'); $cartId = $quote->getId(); @@ -169,7 +168,7 @@ class WriteServiceTest extends WebapiAbstract 'cc_exp_month' => '1', ], ]; - $this->_webApiCall($serviceInfo, $requestData); + $this->assertNotNull($this->_webApiCall($serviceInfo, $requestData)); } /** @@ -180,7 +179,7 @@ class WriteServiceTest extends WebapiAbstract public function testSetPaymentWithSimpleProductWithoutAddress() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); $quote->load('test_order_with_simple_product_without_address', 'reserved_order_id'); $cartId = $quote->getId(); @@ -207,6 +206,84 @@ class WriteServiceTest extends WebapiAbstract 'cc_exp_month' => '1', ], ]; - $this->_webApiCall($serviceInfo, $requestData); + $this->assertNotNull($this->_webApiCall($serviceInfo, $requestData)); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + */ + public function testGetList() + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote->load('test_order_1', 'reserved_order_id'); + $cartId = $quote->getId(); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/payment-methods', + 'httpMethod' => RestConfig::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'getList', + ], + ]; + + $requestData = ["cartId" => $cartId]; + $requestResponse = $this->_webApiCall($serviceInfo, $requestData); + + $expectedResponse = [ + 'code' => 'checkmo', + 'title' => 'Check / Money order', + ]; + + $this->assertGreaterThan(0, count($requestResponse)); + $this->assertContains($expectedResponse, $requestResponse); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_payment_saved.php + */ + public function testGet() + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote->load('test_order_1_with_payment', 'reserved_order_id'); + $cartId = $quote->getId(); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . $cartId . '/selected-payment-methods', + 'httpMethod' => RestConfig::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'get', + ], + ]; + + $requestData = ["cartId" => $cartId]; + $requestResponse = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertArrayHasKey('method', $requestResponse); + $this->assertArrayHasKey('po_number', $requestResponse); + $this->assertArrayHasKey('cc_owner', $requestResponse); + $this->assertArrayHasKey('cc_type', $requestResponse); + $this->assertArrayHasKey('cc_exp_year', $requestResponse); + $this->assertArrayHasKey('cc_exp_month', $requestResponse); + $this->assertArrayHasKey('additional_data', $requestResponse); + + $this->assertNotNull($requestResponse['method']); + $this->assertNotNull($requestResponse['po_number']); + $this->assertNotNull($requestResponse['cc_owner']); + $this->assertNotNull($requestResponse['cc_type']); + $this->assertNotNull($requestResponse['cc_exp_year']); + $this->assertNotNull($requestResponse['cc_exp_month']); + $this->assertNotNull($requestResponse['additional_data']); + + $this->assertEquals('checkmo', $requestResponse['method']); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php similarity index 51% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php index a318918c707ff4e33b66497a5d2332103e345e74..64a93d6d1a34200a890cd6ed64b244cb5e1d71a1 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php @@ -4,15 +4,16 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Address\Shipping; +namespace Magento\Quote\Api; +use Magento\Quote\Api\Data\AddressInterface; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Webapi\Model\Rest\Config as RestConfig; -class WriteServiceTest extends WebapiAbstract +class ShippingAddressManagementTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutAddressShippingWriteServiceV1'; + const SERVICE_NAME = 'quoteShippingAddressManagementV1'; const RESOURCE_PATH = '/V1/carts/'; /** @@ -20,15 +21,81 @@ class WriteServiceTest extends WebapiAbstract */ protected $objectManager; + protected function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + /** - * @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php */ - protected $builder; + public function testGetAddress() + { + $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote->load('test_order_1', 'reserved_order_id'); - protected function setUp() + /** @var \Magento\Quote\Model\Quote\Address $address */ + $address = $quote->getShippingAddress(); + + $data = [ + AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), + AddressInterface::KEY_ID => (int)$address->getId(), + AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), + AddressInterface::REGION => $address->getRegion(), + AddressInterface::REGION_ID => $address->getRegionId(), + AddressInterface::REGION_CODE => $address->getRegionCode(), + AddressInterface::KEY_STREET => $address->getStreet(), + AddressInterface::KEY_COMPANY => $address->getCompany(), + AddressInterface::KEY_TELEPHONE => $address->getTelephone(), + AddressInterface::KEY_POSTCODE => $address->getPostcode(), + AddressInterface::KEY_CITY => $address->getCity(), + AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), + AddressInterface::KEY_LASTNAME => $address->getLastname(), + AddressInterface::KEY_EMAIL => $address->getEmail() + ]; + + $cartId = $quote->getId(); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . $quote->getId() . '/shipping-address', + 'httpMethod' => RestConfig::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Get', + ], + ]; + + $requestData = ["cartId" => $cartId]; + $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php + * + * @expectedException \Exception + * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable + */ + public function testGetAddressOfQuoteWithVirtualProduct() { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->builder = $this->objectManager->create('Magento\Checkout\Service\V1\Data\Cart\AddressBuilder'); + $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $cartId = $quote->load('test_order_with_virtual_product', 'reserved_order_id')->getId(); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . $quote->getId() . '/shipping-address', + 'httpMethod' => RestConfig::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Get', + ], + ]; + + $this->_webApiCall($serviceInfo, ["cartId" => $cartId]); } /** @@ -48,7 +115,7 @@ class WriteServiceTest extends WebapiAbstract 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'SetAddress', + 'operation' => self::SERVICE_NAME . 'Assign', ], ]; @@ -59,11 +126,9 @@ class WriteServiceTest extends WebapiAbstract 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', - 'region' => [ - 'region_id' => 12, - 'region' => 'California', - 'region_code' => 'CA', - ], + 'region_id' => 12, + 'region' => 'California', + 'region_code' => 'CA', 'postcode' => '0985432', 'country_id' => 'US', 'telephone' => '88776655', @@ -71,7 +136,7 @@ class WriteServiceTest extends WebapiAbstract ]; $requestData = [ "cartId" => $quote->getId(), - 'addressData' => $addressData, + 'address' => $addressData, ]; $addressId = $this->_webApiCall($serviceInfo, $requestData); @@ -79,19 +144,19 @@ class WriteServiceTest extends WebapiAbstract //reset $quote to reload data $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); $quote->load('test_order_1', 'reserved_order_id'); - $savedData = $quote->getShippingAddress()->getData(); - $this->assertEquals($addressId, $savedData['address_id']); + $address = $quote->getShippingAddress(); + $address->getRegionCode(); + $savedData = $address->getData(); + $this->assertEquals($addressId, $savedData['address_id'], 'Invalid address ID'); $this->assertEquals(0, $savedData['same_as_billing']); //custom checks for street, region and address_type $this->assertEquals($addressData['street'], $quote->getShippingAddress()->getStreet()); unset($addressData['street']); - $this->assertEquals($addressData['region']['region_id'], $savedData['region_id']); - $this->assertEquals($addressData['region']['region'], $savedData['region']); - unset($addressData['region']); + $this->assertEquals('shipping', $savedData['address_type']); //check the rest of fields foreach ($addressData as $key => $value) { - $this->assertEquals($value, $savedData[$key]); + $this->assertEquals($value, $savedData[$key], 'Invalid value for ' . $key); } } @@ -117,7 +182,7 @@ class WriteServiceTest extends WebapiAbstract 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'SetAddress', + 'operation' => self::SERVICE_NAME . 'Assign', ], ]; @@ -128,11 +193,9 @@ class WriteServiceTest extends WebapiAbstract 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', - 'region' => [ - 'region_id' => 12, - 'region' => 'California', - 'region_code' => 'CA', - ], + 'region_id' => 12, + 'region' => 'California', + 'region_code' => 'CA', 'postcode' => '0985432', 'country_id' => 'US', 'telephone' => '88776655', @@ -140,7 +203,7 @@ class WriteServiceTest extends WebapiAbstract ]; $requestData = [ "cartId" => $quote->getId(), - 'addressData' => $addressData, + 'address' => $addressData, ]; $this->_webApiCall($serviceInfo, $requestData); diff --git a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php similarity index 57% rename from dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php index 40cfd42c3a5b68a3609619c60187213680ccacb5..02c398ff921927fa1c5ede9c3d55194ab0303a9d 100644 --- a/dev/tests/api-functional/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php @@ -3,27 +3,111 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +namespace Magento\Quote\Api; -namespace Magento\Checkout\Service\V1\ShippingMethod; - -use Magento\Checkout\Service\V1\Data\Cart\ShippingMethod; +use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\WebapiAbstract; +use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Webapi\Model\Rest\Config as RestConfig; -class ReadServiceTest extends WebapiAbstract +class ShippingMethodManagementTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'checkoutShippingMethodReadServiceV1'; + const SERVICE_NAME = 'quoteShippingMethodManagementV1'; const RESOURCE_PATH = '/V1/carts/'; /** - * @var \Magento\TestFramework\ObjectManager + * @var ObjectManager */ - protected $objectManager; + private $objectManager; + + /** + * @var \Magento\Quote\Model\Quote + */ + protected $quote; protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + } + + protected function getServiceInfo() + { + return [ + 'rest' => [ + 'resourcePath' => '/V1/carts/' . $this->quote->getId() . '/selected-shipping-method', + 'httpMethod' => RestConfig::HTTP_METHOD_PUT, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Set', + ], + ]; + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + */ + public function testSetMethod() + { + $this->quote->load('test_order_1', 'reserved_order_id'); + $serviceInfo = $this->getServiceInfo(); + + $requestData = [ + 'cartId' => $this->quote->getId(), + 'carrierCode' => 'flatrate', + 'methodCode' => 'flatrate', + ]; + $result = $this->_webApiCall($serviceInfo, $requestData); + $this->assertEquals(true, $result); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + */ + public function testSetMethodWrongMethod() + { + $this->quote->load('test_order_1', 'reserved_order_id'); + $serviceInfo = $this->getServiceInfo(); + + $requestData = [ + 'cartId' => $this->quote->getId(), + 'carrierCode' => 'flatrate', + 'methodCode' => 'wrongMethod', + ]; + try { + $this->_webApiCall($serviceInfo, $requestData); + } catch (\SoapFault $e) { + $message = $e->getMessage(); + } catch (\Exception $e) { + $message = json_decode($e->getMessage())->message; + } + $this->assertEquals('Carrier with such method not found: flatrate, wrongMethod', $message); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php + */ + public function testSetMethodWithoutShippingAddress() + { + $this->quote->load('test_order_with_simple_product_without_address', 'reserved_order_id'); + $serviceInfo = $this->getServiceInfo(); + + $requestData = [ + 'cartId' => $this->quote->getId(), + 'carrierCode' => 'flatrate', + 'methodCode' => 'flatrate', + ]; + try { + $this->_webApiCall($serviceInfo, $requestData); + } catch (\SoapFault $e) { + $message = $e->getMessage(); + } catch (\Exception $e) { + $message = json_decode($e->getMessage())->message; + } + $this->assertEquals('Shipping address is not set', $message); } /** @@ -41,13 +125,13 @@ class ReadServiceTest extends WebapiAbstract list($carrierCode, $methodCode) = explode('_', $shippingAddress->getShippingMethod()); list($carrierTitle, $methodTitle) = explode(' - ', $shippingAddress->getShippingDescription()); $data = [ - ShippingMethod::CARRIER_CODE => $carrierCode, - ShippingMethod::METHOD_CODE => $methodCode, - ShippingMethod::CARRIER_TITLE => $carrierTitle, - ShippingMethod::METHOD_TITLE => $methodTitle, - ShippingMethod::SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), - ShippingMethod::BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), - ShippingMethod::AVAILABLE => true, + ShippingMethodInterface::CARRIER_CODE => $carrierCode, + ShippingMethodInterface::METHOD_CODE => $methodCode, + ShippingMethodInterface::CARRIER_TITLE => $carrierTitle, + ShippingMethodInterface::METHOD_TITLE => $methodTitle, + ShippingMethodInterface::SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), + ShippingMethodInterface::BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), + ShippingMethodInterface::AVAILABLE => true, ]; $requestData = ["cartId" => $cartId]; @@ -128,7 +212,7 @@ class ReadServiceTest extends WebapiAbstract 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'GetMethod', + 'operation' => self::SERVICE_NAME . 'Get', ], ]; } @@ -164,8 +248,8 @@ class ReadServiceTest extends WebapiAbstract protected function convertRates($groupedRates, $currencyCode) { $result = []; - /** @var \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter $converter */ - $converter = $this->objectManager->create('Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter'); + /** @var \Magento\Quote\Model\Cart\ShippingMethodConverter $converter */ + $converter = $this->objectManager->create('\Magento\Quote\Model\Cart\ShippingMethodConverter'); foreach ($groupedRates as $carrierRates) { foreach ($carrierRates as $rate) { $result[] = $converter->modelToDataObject($rate, $currencyCode)->__toArray(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerInjectable.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerInjectable.php index 8154cf0f2186fa1755228078d7b1a21458e99e5e..1e369f4420ab02afef8680ab4a8d67ff18dd3a5c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerInjectable.php @@ -19,6 +19,7 @@ class CustomerInjectable extends AbstractRepository * @param array $defaultData * * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function __construct(array $defaultConfig = [], array $defaultData = []) { @@ -116,5 +117,15 @@ class CustomerInjectable extends AbstractRepository 'password_confirmation' => '123123q', 'address' => ['presets' => 'US_address_TX'], ]; + + $this->_data['johndoe_with_multiple_addresses'] = [ + 'firstname' => 'John', + 'lastname' => 'Doe', + 'group_id' => ['dataSet' => 'General'], + 'email' => 'JohnDoe_%isolation%@example.com', + 'password' => '123123q', + 'password_confirmation' => '123123q', + 'address' => ['presets' => 'US_address_NY, US_address'], + ]; } } 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 ff6d1b7ffdc68df7cfaef5ede9887abd4e9ba072..3f164c9d5312577ca04f70532db1c2d2b787a4e8 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 @@ -42,7 +42,7 @@ class DataBuilderTest extends \PHPUnit_Framework_TestCase public function getBuildersToTest() { return [ - ['Magento\Checkout\Service\V1\Data\Cart\TotalsBuilder'], + ['Magento\Catalog\Api\Data\ProductDataBuilder'], ]; } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceFactory.php.sample b/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceFactory.php.sample index 1281407baeec07a22e0235d043d50b8bdb94a5d6..afecd37b4f60b92551c271fca5365c4483c11187 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceFactory.php.sample +++ b/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceFactory.php.sample @@ -2,7 +2,7 @@ namespace Magento\Framework\Code\GeneratorTest; /** - * Factory class for Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace + * Factory class for @see \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. diff --git a/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample b/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample index 99aa37fdd6361230ad1fd76a7bc852822774bcee..2b9106f61386e9e56b47e5d3a419a7ba467bc364 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample +++ b/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample @@ -2,7 +2,7 @@ namespace Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace; /** - * Proxy class for Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace + * Proxy class for @see \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. 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 0510c8cb4fec81748ad1b031a0ae9e31ee19a928..c382d8c2026f7d3f044fafbc136525ecffc220c3 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -257,8 +257,15 @@ class CompilerTest extends \PHPUnit_Framework_TestCase } $class = new \ReflectionClass($className); $parent = $class->getParentClass(); + $file = false; + if ($parent) { + $basePath = \Magento\Framework\Test\Utility\Files::init()->getPathToSource(); + $file = str_replace('\\', DIRECTORY_SEPARATOR, $parent->getFileName()); + $basePath = str_replace('\\', DIRECTORY_SEPARATOR, $basePath); + $file = str_replace($basePath . DIRECTORY_SEPARATOR, '', $file); + } /** Prevent analysis of non Magento classes */ - if ($parent && in_array($parent->getFileName(), $allowedFiles)) { + if ($parent && in_array($file, $allowedFiles)) { $output = array_merge( $this->_buildInheritanceHierarchyTree($parent->getName(), $allowedFiles), [$className], diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php index a266869939c2fb4daab08ac7e1590fad7d80de12..91f2539d15511b4790bf74e6c5eca6a5e6c07cda 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php @@ -70,5 +70,8 @@ return [ ['Magento\RecurringPayment'], ['Magento\PayPalRecurringPayment'], ['Magento\ConfigurableProduct\Service'], - ['Magento\Catalog\Service'] + ['Magento\Catalog\Service'], + ['Magento\CheckoutAgreements\Service'], + ['Magento\Checkout\Service'], + ['Magento\GiftMessage\Service'] ]; diff --git a/dev/tests/unit/framework/Magento/Test/AbstractFactoryTestCase.php b/dev/tests/unit/framework/Magento/Test/AbstractFactoryTestCase.php new file mode 100644 index 0000000000000000000000000000000000000000..3727868d8ab7095dca52c3be27706b0f6f548392 --- /dev/null +++ b/dev/tests/unit/framework/Magento/Test/AbstractFactoryTestCase.php @@ -0,0 +1,63 @@ +<?php +/** + * Framework for unit tests containing helper methods + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + * + * Number of fields is necessary because of the number of fields used by multiple layers + * of parent classes. + * + */ +namespace Magento\Test; + +abstract class AbstractFactoryTestCase extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var string + */ + protected $factoryClassName; + + /** + * @var string + */ + protected $instanceClassName; + + /** + * @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var object + */ + protected $factory; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->factory = $this->objectManager->getObject( + $this->factoryClassName, + ['objectManager' => $this->objectManagerMock] + ); + } + + public function testCreate() + { + $instanceMock = $this->getMockBuilder($this->instanceClassName) + ->disableOriginalConstructor() + ->getMock(); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($instanceMock)); + $this->assertSame($instanceMock, $this->factory->create()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php deleted file mode 100644 index bfe221961b52867e07b751c20336a15f763cb52c..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Address\Billing; - -class ReadServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $converterMock; - - protected function setUp() - { - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); - - $this->service = new ReadService($this->quoteRepositoryMock, $this->converterMock); - } - - public function testGetAddress() - { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once())->method('getActive') - ->with('cartId')->will($this->returnValue($quoteMock)); - - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); - $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock)); - - $this->converterMock->expects($this->once())->method('convertModelToDataObject') - ->with($addressMock)->will($this->returnValue('BillingAddress')); - - $this->assertEquals('BillingAddress', $this->service->getAddress('cartId')); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php deleted file mode 100644 index 58e217926cce6342968f95136b76e44728188a43..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php +++ /dev/null @@ -1,189 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Address\Billing; - -class WriteServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var WriteService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $addressFactoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteAddressMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $validatorMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $converterMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $loggerMock; - - protected function setUp() - { - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->addressFactoryMock = $this->getMock( - '\Magento\Quote\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false - ); - - $this->quoteAddressMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address', - ['getCustomerId', 'load', 'getData', 'setData', 'setStreet', 'setRegionId', 'setRegion', '__wakeup'], - [], - '', - false - ); - $this->addressFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->quoteAddressMock)); - - $this->validatorMock = $this->getMock( - '\Magento\Checkout\Service\V1\Address\Validator', [], [], '', false - ); - - $this->converterMock = $this->getMock( - '\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false - ); - - $this->loggerMock = $this->getMock('\Psr\Log\LoggerInterface', [], [], '', false); - - $this->service = new \Magento\Checkout\Service\V1\Address\Billing\WriteService( - $this->quoteRepositoryMock, - $this->converterMock, - $this->validatorMock, - $this->addressFactoryMock, - $this->loggerMock - ); - } - - /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage error123 - */ - public function testSetAddressValidationFailed() - { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with('cartId') - ->will($this->returnValue($quoteMock)); - - $this->validatorMock->expects($this->once())->method('validate') - ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error123'))); - - $this->service->setAddress('cartId', null); - } - - public function testSetAddress() - { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with('cartId') - ->will($this->returnValue($quoteMock)); - - $builder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder', ['create'], [], '', false - ); - - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - /** @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder $addressDataBuilder */ - $addressDataBuilder = $objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', - ['regionBuilder' => $builder] - ); - /** @var \Magento\Checkout\Service\V1\Data\Cart\Address $addressData */ - $addressData = $addressDataBuilder->setId(454)->create(); - - $this->validatorMock->expects($this->once())->method('validate') - ->with($addressData) - ->will($this->returnValue(true)); - - $this->converterMock->expects($this->once())->method('convertDataObjectToModel') - ->with($addressData, $this->quoteAddressMock) - ->will($this->returnValue($this->quoteAddressMock)); - - $quoteMock->expects($this->once())->method('setBillingAddress')->with($this->quoteAddressMock); - $quoteMock->expects($this->once())->method('setDataChanges')->with(true); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); - $addressId = 1; - $billingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); - $billingAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); - $quoteMock->expects($this->once())->method('getBillingAddress') - ->will($this->returnValue($billingAddressMock)); - - $this->assertEquals($addressId, $this->service->setAddress('cartId', $addressData)); - } - - /** - * @expectedException \Magento\Framework\Exception\InputException - * @expectedExceptionMessage Unable to save address. Please, check input data. - */ - public function testSetAddressWithInabilityToSaveQuote() - { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with('cartId') - ->will($this->returnValue($quoteMock)); - - $builder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder', ['create'], [], '', false - ); - - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - /** @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder $addressDataBuilder */ - $addressDataBuilder = $objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', - ['regionBuilder' => $builder] - ); - /** @var \Magento\Checkout\Service\V1\Data\Cart\Address $addressData */ - $addressData = $addressDataBuilder->setId(454)->create(); - - $this->validatorMock->expects($this->once())->method('validate') - ->with($addressData) - ->will($this->returnValue(true)); - - $this->converterMock->expects($this->once())->method('convertDataObjectToModel') - ->with($addressData, $this->quoteAddressMock) - ->will($this->returnValue($this->quoteAddressMock)); - - $quoteMock->expects($this->once())->method('setBillingAddress')->with($this->quoteAddressMock); - $quoteMock->expects($this->once())->method('setDataChanges')->with(true); - $this->quoteRepositoryMock->expects($this->once()) - ->method('save') - ->with($quoteMock) - ->willThrowException( - new \Exception('Some DB Error') - ); - $this->service->setAddress('cartId', $addressData); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.php deleted file mode 100644 index 3ee1ac05273836fd91952ae922c1d7a9bec9bc7e..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Address; - -use Magento\Checkout\Service\V1\Data\Cart\Address; -use Magento\Checkout\Service\V1\Data\Cart\Address\Region; -use Magento\Framework\Api\AttributeValue; - -class ConverterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var Converter - */ - protected $model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $addressBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $metadataServiceMock; - - protected function setUp() - { - $this->addressBuilderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', [], [], '', false - ); - $this->metadataServiceMock = $this - ->getMockBuilder('Magento\Customer\Api\CustomerMetadataInterface') - ->setMethods(['getCustomAttributesMetadata']) - ->getMockForAbstractClass(); - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->model = $objectManager->getObject( - 'Magento\Checkout\Service\V1\Address\Converter', - ['addressBuilder' => $this->addressBuilderMock, 'customerMetadata' => $this->metadataServiceMock] - ); - } - - public function testConvertModelToDataObject() - { - $addressMockMethods = [ - 'getCountryId', 'getId', 'getCustomerId', 'getRegion', 'getRegionId', 'getRegionCode', - 'getStreet', 'getCompany', 'getTelephone', 'getFax', 'getPostcode', 'getFirstname', 'getMiddlename', - 'getLastname', 'getPrefix', 'getSuffix', 'getEmail', 'getVatId', 'getCustomField', 'getCity', '__wakeup', - ]; - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', $addressMockMethods, [], '', false); - - $addressMock->expects($this->atLeastOnce())->method('getCountryId')->will($this->returnValue(1)); - $addressMock->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(2)); - $addressMock->expects($this->atLeastOnce())->method('getCustomerId')->will($this->returnValue(3)); - $addressMock->expects($this->atLeastOnce())->method('getRegion')->will($this->returnValue('Alabama')); - $addressMock->expects($this->atLeastOnce())->method('getRegionId')->will($this->returnValue(4)); - $addressMock->expects($this->atLeastOnce())->method('getRegionCode')->will($this->returnValue('aa')); - $addressMock->expects($this->atLeastOnce())->method('getStreet')->will($this->returnValue('street')); - $addressMock->expects($this->atLeastOnce())->method('getCompany')->will($this->returnValue('company')); - $addressMock->expects($this->atLeastOnce())->method('getTelephone')->will($this->returnValue('123-123')); - $addressMock->expects($this->atLeastOnce())->method('getFax')->will($this->returnValue('234-234')); - $addressMock->expects($this->atLeastOnce())->method('getPostcode')->will($this->returnValue('80010')); - $addressMock->expects($this->atLeastOnce())->method('getCity')->will($this->returnValue('Town')); - $addressMock->expects($this->atLeastOnce())->method('getFirstname')->will($this->returnValue('Vasya')); - $addressMock->expects($this->atLeastOnce())->method('getMiddlename')->will($this->returnValue('Vasya')); - $addressMock->expects($this->atLeastOnce())->method('getLastname')->will($this->returnValue('Pupkin')); - $addressMock->expects($this->atLeastOnce())->method('getPrefix')->will($this->returnValue('prefix')); - $addressMock->expects($this->atLeastOnce())->method('getSuffix')->will($this->returnValue('suffix')); - $addressMock->expects($this->atLeastOnce())->method('getEmail')->will($this->returnValue('aaa@aaa.com')); - $addressMock->expects($this->atLeastOnce())->method('getVatId')->will($this->returnValue(5)); - $addressMock->expects($this->atLeastOnce())->method('getCustomField')->will($this->returnValue('custom_value')); - - $testData = [ - Address::KEY_COUNTRY_ID => 1, - Address::KEY_ID => 2, - Address::KEY_CUSTOMER_ID => 3, - Address::KEY_REGION => [ - Region::REGION => 'Alabama', - Region::REGION_ID => 4, - Region::REGION_CODE => 'aa', - ], - Address::KEY_STREET => 'street', - Address::KEY_COMPANY => 'company', - Address::KEY_TELEPHONE => '123-123', - Address::KEY_FAX => '234-234', - Address::KEY_POSTCODE => '80010', - Address::KEY_CITY => 'Town', - Address::KEY_FIRSTNAME => 'Vasya', - Address::KEY_LASTNAME => 'Pupkin', - Address::KEY_MIDDLENAME => 'Vasya', - Address::KEY_PREFIX => 'prefix', - Address::KEY_SUFFIX => 'suffix', - Address::KEY_EMAIL => 'aaa@aaa.com', - Address::KEY_VAT_ID => 5, - Address::CUSTOM_ATTRIBUTES_KEY => [['attribute_code' => 'custom_field', 'value' => 'custom_value']], - ]; - - $this->metadataServiceMock - ->expects($this->any()) - ->method('getCustomAttributesMetadata') - ->will($this->returnValue([new \Magento\Framework\Object(['attribute_code' => 'custom_field'])])); - - $this->addressBuilderMock->expects($this->once())->method('populateWithArray')->with($testData)->will( - $this->returnValue($this->addressBuilderMock) - ); - $this->addressBuilderMock->expects($this->once())->method('create')->will( - $this->returnValue('Expected value') - ); - - $this->assertEquals('Expected value', $this->model->convertModelToDataObject($addressMock)); - } - - public function testConvertDataObjectToModel() - { - $dataObjectMock = $this->getMock('Magento\Checkout\Service\V1\Data\Cart\Address', [], [], '', false); - $methods = ['setData', 'setStreet', 'setRegionId', 'setRegion', '__wakeUp']; - $addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', $methods, [], '', false); - $attributeValueMock = $this->getMock('\Magento\Framework\Api\AttributeValue', [], [], '', false); - $attributeValueMock->expects($this->once())->method('getAttributeCode')->will($this->returnValue('value_code')); - $attributeValueMock->expects($this->once())->method('getValue')->will($this->returnValue('value')); - - $addressData = [ - 'some_code' => 'some_value', - ]; - $regionMock = $this->getMock('Magento\Checkout\Service\V1\Data\Cart\Address\Region', [], [], '', false); - - $dataObjectMock->expects($this->once())->method('__toArray')->will($this->returnValue($addressData)); - $valueMap = [ - [$addressData, null], - ['attribute_value', 'value'], - ]; - $addressMock->expects($this->any())->method('setData')->will($this->returnValueMap($valueMap)); - $dataObjectMock - ->expects($this->once()) - ->method('getCustomAttributes') - ->will($this->returnValue([$attributeValueMock])); - $dataObjectMock->expects($this->once())->method('getStreet')->will($this->returnValue('street')); - $addressMock->expects($this->once())->method('setStreet')->with('street'); - $dataObjectMock->expects($this->any())->method('getRegion')->will($this->returnValue($regionMock)); - $regionMock->expects($this->once())->method('getRegionId')->will($this->returnValue('regionId')); - $regionMock->expects($this->once())->method('getRegion')->will($this->returnValue('region')); - $addressMock->expects($this->once())->method('setRegionId')->with('regionId'); - $addressMock->expects($this->once())->method('setRegion')->with('region'); - $this->model->convertDataObjectToModel($dataObjectMock, $addressMock); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php deleted file mode 100644 index 54700a7b9c3bda0192ca91715da0d9235689409b..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\Address\Shipping; - -class ReadServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $converterMock; - - protected function setUp() - { - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); - - $this->service = new ReadService($this->quoteRepositoryMock, $this->converterMock); - } - - public function testGetAddress() - { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with('cartId')->will( - $this->returnValue($quoteMock) - ); - - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); - $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($addressMock)); - $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(false)); - - $this->converterMock->expects($this->once())->method('convertModelToDataObject') - ->with($addressMock)->will($this->returnValue('ShippingAddress')); - - $this->assertEquals('ShippingAddress', $this->service->getAddress('cartId')); - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable - */ - public function testGetAddressOfQuoteWithVirtualProducts() - { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with('cartId')->will( - $this->returnValue($quoteMock) - ); - - $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(true)); - $quoteMock->expects($this->never())->method('getShippingAddress'); - - $this->service->getAddress('cartId'); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/PaymentMethod/BuilderTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/PaymentMethod/BuilderTest.php deleted file mode 100644 index a8263d45545b8b6c656c07c903baaed588dfa926..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/PaymentMethod/BuilderTest.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Cart\PaymentMethod; - -class BuilderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder - */ - protected $builder; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->builder = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder' - ); - } - - public function testBuildPaymentObject() - { - $paymentData = [ - 'method' => 'checkmo', - 'payment_details' => 'paymentDetailsTest', - ]; - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); - $paymentMethodMock->expects($this->once())->method('__toArray')->will($this->returnValue($paymentData)); - $paymentMethodMock->expects($this->once()) - ->method('getPaymentDetails') - ->will($this->returnValue(serialize(['paymentDetailsTest']))); - - $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false); - $paymentMock->expects($this->once()) - ->method('importData') - ->with($this->contains('checkmo')) - ->will($this->returnSelf()); - - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - - $this->assertEquals($paymentMock, $this->builder->build($paymentMethodMock, $quoteMock)); - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage The requested Payment Method is not available. - */ - public function testBuildPaymentObjectThrowsExceptionIfPaymentMethodNotAvailable() - { - $paymentData = [ - 'method' => 'notAvailableMethod', - 'payment_details' => 'paymentDetailsTest', - ]; - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); - $paymentMethodMock->expects($this->once())->method('__toArray')->will($this->returnValue($paymentData)); - $paymentMethodMock->expects($this->once()) - ->method('getPaymentDetails') - ->will($this->returnValue(['paymentDetailsTest'])); - - $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false); - $paymentMock->expects($this->once()) - ->method('importData') - ->with($this->contains('notAvailableMethod')) - ->will($this->throwException( - new \Magento\Framework\Exception\LocalizedException('The requested Payment Method is not available.')) - ); - - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - - $this->assertEquals($paymentMock, $this->builder->build($paymentMethodMock, $quoteMock)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/PaymentMethod/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/PaymentMethod/ConverterTest.php deleted file mode 100644 index f048bcee73581aff98024601c0fbc360cf7cd57d..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/PaymentMethod/ConverterTest.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Cart\PaymentMethod; - -use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod; - -class ConverterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter - */ - protected $converter; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $objectManager; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $paymentMethodBuilderMock; - - protected function setUp() - { - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->paymentMethodBuilderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder', - ['populateWithArray', 'create'], - [], - '', - false - ); - - $this->converter = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter', - [ - 'builder' => $this->paymentMethodBuilderMock, - ] - ); - } - - public function testConvertQuotePaymentObjectToPaymentDataObject() - { - $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', - [ - 'getMethod', 'getPoNumber', 'getCcOwner', 'getCcNumber', - 'getCcType', 'getCcExpYear', 'getCcExpMonth', 'getAdditionalData', '__wakeup' - ], - [], - '', - false - ); - $paymentMock->expects($this->once())->method('getMethod')->will($this->returnValue('checkmo')); - $paymentMock->expects($this->once())->method('getPoNumber')->will($this->returnValue(100)); - $paymentMock->expects($this->once())->method('getCcOwner')->will($this->returnValue('tester')); - $paymentMock->expects($this->once())->method('getCcNumber')->will($this->returnValue(100200300)); - $paymentMock->expects($this->once())->method('getCcType')->will($this->returnValue('visa')); - $paymentMock->expects($this->once())->method('getCcExpYear')->will($this->returnValue(2014)); - $paymentMock->expects($this->once())->method('getCcExpMonth')->will($this->returnValue(10)); - $paymentMock->expects($this->once())->method('getAdditionalData')->will($this->returnValue('test')); - - $data = [ - PaymentMethod::METHOD => 'checkmo', - PaymentMethod::PO_NUMBER => 100, - PaymentMethod::CC_OWNER => 'tester', - PaymentMethod::CC_NUMBER => 100200300, - PaymentMethod::CC_TYPE => 'visa', - PaymentMethod::CC_EXP_YEAR => 2014, - PaymentMethod::CC_EXP_MONTH => 10, - PaymentMethod::PAYMENT_DETAILS => 'test', - ]; - - $this->paymentMethodBuilderMock->expects($this->once()) - ->method('populateWithArray') - ->with($data) - ->will($this->returnSelf()); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\PaymentMethod', [], [], '', false); - - $this->paymentMethodBuilderMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($paymentMethodMock)); - - $this->assertEquals($paymentMethodMock, $this->converter->toDataObject($paymentMock)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php deleted file mode 100644 index f1798271d892555039d2100e4c3173889db2a518..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Cart; - -use Magento\Framework\Api\SearchCriteria; - -/** - * @SuppressWarnings(PHPMD.TooManyFields) - */ -class ReadServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteCollectionMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $searchResultsBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cartMapperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteMock; - - protected function setUp() - { - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $methods = [ - 'getId', 'getStoreId', 'getCreatedAt', 'getUpdatedAt', 'getConvertedAt', - 'getIsActive', 'getIsVirtual', 'getItemsCount', 'getItemsQty', 'getCheckoutMethod', 'getReservedOrderId', - 'getOrigOrderId', 'getBaseGrandTotal', 'getBaseSubtotal', 'getSubtotal', 'getBaseSubtotalWithDiscount', - 'getSubtotalWithDiscount', 'getCustomerId', 'getCustomerEmail', 'getCustomerGroupId', - 'getCustomerTaxClassId', 'getCustomerPrefix', 'getCustomerFirstname', 'getCustomerMiddlename', - 'getCustomerLastname', 'getCustomerSuffix', 'getCustomerDob', 'getCustomerNote', 'getCustomerNoteNotify', - 'getCustomerIsGuest', 'getCustomerGender', 'getCustomerTaxvat', '__wakeup', 'load', 'getGrandTotal', - 'getGlobalCurrencyCode', 'getBaseCurrencyCode', 'getStoreCurrencyCode', 'getQuoteCurrencyCode', - 'getStoreToBaseRate', 'getStoreToQuoteRate', 'getBaseToGlobalRate', 'getBaseToQuoteRate', 'setStoreId', - 'getShippingAddress', 'getAllItems', - ]; - $this->quoteMock = $this->getMock('\Magento\Quote\Model\Quote', $methods, [], '', false); - $this->quoteCollectionMock = $objectManager->getCollectionMock( - 'Magento\Quote\Model\Resource\Quote\Collection', [$this->quoteMock]); - $this->searchResultsBuilderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\CartSearchResultsBuilder', [], [], '', false); - $this->cartMapperMock = $this->getMock('\Magento\Checkout\Service\V1\Data\CartMapper', ['map'], [], '', false); - - $this->service = new ReadService( - $this->quoteRepositoryMock, - $this->quoteCollectionMock, - $this->searchResultsBuilderMock, - $this->cartMapperMock - ); - } - - public function testGetCart() - { - $cartId = 12; - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId) - ->will($this->returnValue($this->quoteMock)); - - $this->cartMapperMock->expects($this->once())->method('map')->with($this->quoteMock); - - $this->service->getCart($cartId); - } - - public function testGetCartForCustomer() - { - $customerId = 12; - $this->quoteRepositoryMock->expects($this->once())->method('getActiveForCustomer')->with($customerId) - ->will($this->returnValue($this->quoteMock)); - - $this->cartMapperMock->expects($this->once())->method('map')->with($this->quoteMock); - - $this->service->getCartForCustomer($customerId); - } - - /** - * @param int $direction - * @param string $expected - * @dataProvider getCartListSuccessDataProvider - */ - public function testGetCartListSuccess($direction, $expected) - { - $searchResult = $this->getMock('\Magento\Checkout\Service\V1\Data\CartSearchResults', [], [], '', false); - $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false); - - $cartMock = $this->getMock('Magento\Payment\Model\Cart', [], [], '', false); - $this->searchResultsBuilderMock - ->expects($this->once()) - ->method('setSearchCriteria') - ->will($this->returnValue($searchCriteriaMock)); - $filterGroupMock = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false); - $searchCriteriaMock - ->expects($this->any()) - ->method('getFilterGroups') - ->will($this->returnValue([$filterGroupMock])); - - $filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false); - $filterGroupMock->expects($this->any())->method('getFilters')->will($this->returnValue([$filterMock])); - $filterMock->expects($this->once())->method('getField')->will($this->returnValue('store_id')); - $filterMock->expects($this->any())->method('getConditionType')->will($this->returnValue('eq')); - $filterMock->expects($this->once())->method('getValue')->will($this->returnValue('filter_value')); - $this->quoteCollectionMock - ->expects($this->once()) - ->method('addFieldToFilter') - ->with(['store_id'], [0 => ['eq' => 'filter_value']]); - - $this->quoteCollectionMock->expects($this->once())->method('getSize')->will($this->returnValue(10)); - $this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with(10); - $sortOrderMock = $this->getMockBuilder('Magento\Framework\Api\SortOrder') - ->setMethods(['getField', 'getDirection']) - ->disableOriginalConstructor() - ->getMock(); - $sortOrderMock->expects($this->once())->method('getField')->will($this->returnValue('id')); - $sortOrderMock->expects($this->once())->method('getDirection')->will($this->returnValue($direction)); - $searchCriteriaMock - ->expects($this->once()) - ->method('getSortOrders') - ->will($this->returnValue([$sortOrderMock])); - $this->quoteCollectionMock->expects($this->once())->method('addOrder')->with('entity_id', $expected); - $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->will($this->returnValue(1)); - $searchCriteriaMock->expects($this->once())->method('getPageSize')->will($this->returnValue(10)); - - $this->cartMapperMock->expects($this->once())->method('map')->with($this->quoteMock) - ->will($this->returnValue($cartMock)); - - $this->searchResultsBuilderMock->expects($this->once())->method('setItems')->with([$cartMock]); - $this->searchResultsBuilderMock - ->expects($this->once()) - ->method('create') - ->will($this->returnValue($searchResult)); - $this->assertEquals($searchResult, $this->service->getCartList($searchCriteriaMock)); - } - - /** - * @expectedException \Magento\Framework\Exception\InputException - * @expectedExceptionMessage Field 'any_value' cannot be used for search. - */ - public function testGetCartListWithNotExistingField() - { - $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false); - $this->searchResultsBuilderMock - ->expects($this->once()) - ->method('setSearchCriteria') - ->will($this->returnValue($searchCriteriaMock)); - - $filterGroupMock = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false); - $searchCriteriaMock - ->expects($this->any()) - ->method('getFilterGroups') - ->will($this->returnValue([$filterGroupMock])); - $filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false); - $filterGroupMock->expects($this->any())->method('getFilters')->will($this->returnValue([$filterMock])); - $filterMock->expects($this->once())->method('getField')->will($this->returnValue('any_value')); - $filterMock->expects($this->never())->method('getConditionType'); - $this->service->getCartList($searchCriteriaMock); - } - - /** - * @return array - */ - public function getCartListSuccessDataProvider() - { - return [ - 'asc' => [SearchCriteria::SORT_ASC, 'ASC'], - 'desc' => [SearchCriteria::SORT_DESC, 'DESC'] - ]; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/TotalsServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/TotalsServiceTest.php deleted file mode 100644 index 88a8d47d4b82f50215e5163008381c14cabc8d36..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/TotalsServiceTest.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Cart; - -class TotalsServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $quoteMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $itemTotalsMapperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $totalsMapperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $totalsBuilderMock; - - /** - * @var TotalsService - */ - private $service; - - public function setUp() - { - $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', [], [], '', false - ); - $this->totalsBuilderMock = $this->getMock( - 'Magento\Checkout\Service\V1\Data\Cart\TotalsBuilder', - ['populateWithArray', 'setItems', 'create'], - [], - '', - false - ); - $this->totalsMapperMock = $this->getMock( - 'Magento\Checkout\Service\V1\Data\Cart\TotalsMapper', [], [], '', false - ); - $this->quoteRepositoryMock = $this->getMock( - 'Magento\Quote\Model\QuoteRepository', [], [], '', false - ); - $this->itemTotalsMapperMock = $this->getMock( - 'Magento\Checkout\Service\V1\Data\Cart\Totals\ItemMapper', ['extractDto'], [], '', false - ); - - $this->service = new TotalsService( - $this->totalsBuilderMock, - $this->totalsMapperMock, - $this->quoteRepositoryMock, - $this->itemTotalsMapperMock - ); - } - - public function testGetTotals() - { - $cartId = 12; - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId) - ->will($this->returnValue($this->quoteMock)); - - $this->totalsMapperMock->expects($this->once()) - ->method('map') - ->with($this->quoteMock) - ->will($this->returnValue(['test'])); - - $item = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); - $this->quoteMock->expects($this->once())->method('getAllItems')->will($this->returnValue([$item])); - $this->service->getTotals($cartId); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php deleted file mode 100644 index dbddf607aef71273db4661f10a546ae7f68911c1..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php +++ /dev/null @@ -1,427 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Cart; - -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\TestFramework\Helper\ObjectManager; - -/** - * Class WriteServiceTest - */ -class WriteServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Checkout\Service\V1\Cart\WriteService - */ - protected $service; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $objectManager; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $userContextMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteServiceFactory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $customerRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $customerFactoryMock; - - public function setUp() - { - $this->objectManager = new ObjectManager($this); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->userContextMock = $this->getMock('\Magento\Authorization\Model\UserContextInterface'); - - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $this->quoteMock = - $this->getMock('\Magento\Quote\Model\Quote', - [ - 'setStoreId', - 'getId', - 'getStoreId', - 'getCustomerId', - 'setCustomer', - 'setCustomerIsGuest', - '__wakeup', - ], - [], '', false); - - $this->customerRepositoryMock = $this->getMock( - '\Magento\Customer\Api\CustomerRepositoryInterface', [], [], '', false - ); - - $this->customerFactoryMock = $this->getMock( - 'Magento\Customer\Model\CustomerFactory', - ['create'], - [], - '', - false - ); - - $this->quoteServiceFactory = $this->getMock( - 'Magento\Quote\Model\QuoteManagement', - [], - [], - '', - false - ); - $this->service = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Cart\WriteService', - [ - 'storeManager' => $this->storeManagerMock, - 'customerRepository' => $this->customerRepositoryMock, - 'quoteRepository' => $this->quoteRepositoryMock, - 'userContext' => $this->userContextMock, - 'quoteServiceFactory' => $this->quoteServiceFactory, - 'customerModelFactory' => $this->customerFactoryMock - ] - ); - } - - public function testCreateAnonymousCart() - { - $storeId = 345; - - $this->userContextMock->expects($this->once())->method('getUserType') - ->willReturn(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN); - $this->storeManagerMock->expects($this->once()) - ->method('getStore') - ->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once()) - ->method('getId') - ->will($this->returnValue($storeId)); - - $this->quoteRepositoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); - $this->quoteMock->expects($this->once())->method('setStoreId')->with($storeId); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); - $this->quoteMock->expects($this->once())->method('getId')->willReturn(100); - $this->assertEquals(100, $this->service->create()); - } - - /** - * @expectedException \Magento\Framework\Exception\CouldNotSaveException - * @expectedExceptionMessage Cannot create quote - */ - public function testCreateCustomerCartWhenCustomerHasActiveCart() - { - $storeId = 345; - $userId = 50; - - $customerMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', - [], - '', - false - ); - $this->customerRepositoryMock->expects($this->once()) - ->method('getById') - ->with($userId) - ->will($this->returnValue($customerMock)); - - $this->userContextMock->expects($this->once())->method('getUserType') - ->willReturn(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER); - $this->userContextMock->expects($this->any())->method('getUserId')->willReturn($userId); - $this->storeManagerMock->expects($this->once()) - ->method('getStore') - ->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - - $customerQuoteMock = $this->getMock('\Magento\Quote\Model\Quote', - [ - 'getIsActive', - 'getId', - '__wakeup' - ], - [], - '', - false - ); - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActiveForCustomer') - ->with($userId) - ->willReturn($customerQuoteMock); - $this->quoteRepositoryMock->expects($this->never())->method('save')->with($this->quoteMock); - - $this->service->create(); - } - - public function testCreateCustomerCart() - { - $storeId = 345; - $userId = 50; - - $customerMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', - [], - '', - false - ); - $this->customerRepositoryMock->expects($this->once()) - ->method('getById')->with($userId)->will($this->returnValue($customerMock)); - $this->userContextMock->expects($this->once())->method('getUserType') - ->willReturn(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER); - $this->userContextMock->expects($this->any())->method('getUserId')->willReturn($userId); - $this->storeManagerMock->expects($this->once()) - ->method('getStore') - ->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActiveForCustomer') - ->with($userId) - ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException()); - $this->quoteRepositoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); - - $this->quoteMock->expects($this->once())->method('setStoreId')->with($storeId); - $this->quoteMock->expects($this->once())->method('setCustomer')->with($customerMock); - $this->quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); - $this->quoteMock->expects($this->once())->method('getId')->willReturn(100); - $this->assertEquals(100, $this->service->create()); - } - - /** - * @expectedException \Magento\Framework\Exception\CouldNotSaveException - * @expectedExceptionMessage Cannot create quote - */ - public function testCreateWithException() - { - $storeId = 345; - - $this->storeManagerMock->expects($this->once()) - ->method('getStore') - ->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once()) - ->method('getId') - ->will($this->returnValue($storeId)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('setStoreId') - ->with($storeId); - $this->quoteRepositoryMock->expects($this->once()) - ->method('save') - ->will($this->throwException(new CouldNotSaveException('Cannot create quote'))); - - $this->service->create(); - } - - /** - * @expectedException \Magento\Framework\Exception\StateException - * @expectedExceptionMessage Cannot assign customer to the given cart. The cart belongs to different store. - */ - public function testAssignCustomerStateExceptionWithStoreId() - { - $cartId = 956; - $customerId = 125; - $storeId = 12; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $customerMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', - [], - '', - false - ); - $this->customerRepositoryMock->expects($this->once()) - ->method('getById')->with($customerId)->will($this->returnValue($customerMock)); - $customerModelMock = $this->getMockBuilder('Magento\Customer\Model\Customer') - ->disableOriginalConstructor() - ->setMethods(['load', 'getSharedStoreIds']) - ->getMock(); - $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock); - $customerModelMock->expects($this->once()) - ->method('load') - ->with($customerId) - ->willReturnSelf(); - $customerModelMock->expects($this->once())->method('getSharedStoreIds')->will( - $this->returnValue([11]) - ); - - $this->service->assignCustomer($cartId, $customerId); - } - - /** - * @expectedException \Magento\Framework\Exception\StateException - * @expectedExceptionMessage Cannot assign customer to the given cart. The cart is not anonymous. - */ - public function testAssignCustomerStateExceptionWithCustomerId() - { - $cartId = 956; - $customerId = 125; - $storeId = 12; - - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $customerMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', - [], - '', - false - ); - $this->customerRepositoryMock->expects($this->once()) - ->method('getById')->with($customerId)->will($this->returnValue($customerMock)); - - $customerModelMock = $this->getMockBuilder('Magento\Customer\Model\Customer') - ->disableOriginalConstructor() - ->setMethods(['load', 'getSharedStoreIds']) - ->getMock(); - $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock); - $customerModelMock->expects($this->once()) - ->method('load') - ->with($customerId) - ->willReturnSelf(); - $customerModelMock->expects($this->once())->method('getSharedStoreIds')->will( - $this->returnValue([$storeId]) - ); - $this->quoteMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId)); - $this->quoteMock->expects($this->never())->method('setCustomer'); - - $this->service->assignCustomer($cartId, $customerId); - } - - /** - * @expectedException \Magento\Framework\Exception\StateException - * @expectedExceptionMessage Cannot assign customer to the given cart. Customer already has active cart. - */ - public function testAssignCustomerStateExceptionWithAlreadyAssignedCustomer() - { - $cartId = 956; - $customerId = 125; - $storeId = 12; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - - $customerModelMock = $this->getMockBuilder('Magento\Customer\Model\Customer') - ->disableOriginalConstructor() - ->setMethods(['load', 'getSharedStoreIds']) - ->getMock(); - $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock); - $customerModelMock->expects($this->once())->method('getSharedStoreIds')->will($this->returnValue([$storeId])); - $customerModelMock->expects($this->once()) - ->method('load') - ->with($customerId) - ->willReturnSelf(); - $this->quoteMock->expects($this->once())->method('getCustomerId')->will($this->returnValue(null)); - - $customerQuoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once()) - ->method('getForCustomer') - ->with($customerId) - ->will($this->returnValue($customerQuoteMock)); - - $this->quoteMock->expects($this->never())->method('setCustomer'); - - $this->service->assignCustomer($cartId, $customerId); - } - - public function testAssignCustomer() - { - $cartId = 956; - $customerId = 125; - $storeId = 12; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $customerMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', - [], - '', - false, - true, - true - ); - $this->customerRepositoryMock->expects($this->once()) - ->method('getById')->with($customerId)->will($this->returnValue($customerMock)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getForCustomer') - ->with($customerId) - ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException()); - - $customerModelMock = $this->getMockBuilder('Magento\Customer\Model\Customer') - ->disableOriginalConstructor() - ->setMethods(['load', 'getSharedStoreIds']) - ->getMock(); - $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock); - $customerModelMock->expects($this->once())->method('getSharedStoreIds')->will($this->returnValue([$storeId])); - $customerModelMock->expects($this->once()) - ->method('load') - ->with($customerId) - ->willReturnSelf(); - $this->quoteMock->expects($this->once())->method('getCustomerId')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('setCustomer')->with($customerMock)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('setCustomerIsGuest')->with(0)->will($this->returnValue($this->quoteMock)); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); - - $this->assertTrue($this->service->assignCustomer($cartId, $customerId)); - } - - public function testOrder() - { - $cartId = 123; - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); - $orderMock->expects($this->any())->method('getId')->will($this->returnValue(5)); - $this->quoteServiceFactory->expects($this->once())->method('submit')->with($this->quoteMock) - ->will($this->returnValue($orderMock)); - $this->assertEquals(5, $this->service->order($cartId)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php deleted file mode 100644 index d22275df465db4b253bb51721b22cf8a697e4f8c..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Coupon; - -use Magento\Checkout\Service\V1\Data\Cart\Coupon as Coupon; - -class ReadServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $couponBuilderMock; - - protected function setUp() - { - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->couponBuilderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\CouponBuilder', [], [], '', false - ); - $this->service = $objectManager->getObject( - 'Magento\Checkout\Service\V1\Coupon\ReadService', - [ - 'quoteRepository' => $this->quoteRepositoryMock, - 'couponBuilder' => $this->couponBuilderMock, - ] - ); - } - - public function testGetCoupon() - { - $cartId = 11; - $couponCode = 'test_coupon_code'; - - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', ['getCouponCode', '__wakeup'], [], '', false); - $quoteMock->expects($this->any())->method('getCouponCode')->will($this->returnValue($couponCode)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $data = [Coupon::COUPON_CODE => $couponCode]; - - $this->couponBuilderMock->expects($this->once()) - ->method('populateWithArray') - ->with($data) - ->will($this->returnSelf()); - $this->couponBuilderMock->expects($this->once())->method('create')->will($this->returnValue('couponCode')); - - $this->assertEquals('couponCode', $this->service->get($cartId)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/CustomerMapperTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/CustomerMapperTest.php deleted file mode 100644 index 599757e903d3479080741bfb6c370912ad7c9ce5..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/CustomerMapperTest.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -class CustomerMapperTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Checkout\Service\V1\Data\Cart\CustomerMapper - */ - protected $mapper; - - protected function setUp() - { - $this->mapper = new \Magento\Checkout\Service\V1\Data\Cart\CustomerMapper(); - } - - public function testMap() - { - $methods = ['getCustomerId', 'getCustomerEmail', 'getCustomerGroupId', 'getCustomerTaxClassId', - 'getCustomerPrefix', 'getCustomerFirstname', 'getCustomerMiddlename', 'getCustomerLastname', - 'getCustomerSuffix', 'getCustomerDob', 'getCustomerNote', 'getCustomerNoteNotify', - 'getCustomerIsGuest', 'getCustomerGender', 'getCustomerTaxvat', '__wakeUp', ]; - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', $methods, [], '', false); - $expected = [ - Customer::ID => 10, - Customer::EMAIL => 'customer@example.com', - Customer::GROUP_ID => '4', - Customer::TAX_CLASS_ID => 10, - Customer::PREFIX => 'prefix_', - Customer::FIRST_NAME => 'First Name', - Customer::MIDDLE_NAME => 'Middle Name', - Customer::LAST_NAME => 'Last Name', - Customer::SUFFIX => 'suffix', - Customer::DOB => '1/1/1989', - Customer::NOTE => 'customer_note', - Customer::NOTE_NOTIFY => 'note_notify', - Customer::IS_GUEST => false, - Customer::GENDER => 'male', - Customer::TAXVAT => 'taxvat', - ]; - $expectedMethods = [ - 'getCustomerId' => 10, - 'getCustomerEmail' => 'customer@example.com', - 'getCustomerGroupId' => 4, - 'getCustomerTaxClassId' => 10, - 'getCustomerPrefix' => 'prefix_', - 'getCustomerFirstname' => 'First Name', - 'getCustomerMiddlename' => 'Middle Name', - 'getCustomerLastname' => 'Last Name', - 'getCustomerSuffix' => 'suffix', - 'getCustomerDob' => '1/1/1989', - 'getCustomerNote' => 'customer_note', - 'getCustomerNoteNotify' => 'note_notify', - 'getCustomerIsGuest' => false, - 'getCustomerGender' => 'male', - 'getCustomerTaxvat' => 'taxvat', - ]; - foreach ($expectedMethods as $method => $value) { - $quoteMock->expects($this->once())->method($method)->will($this->returnValue($value)); - } - $this->assertEquals($expected, $this->mapper->map($quoteMock)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/TotalsMapperTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/TotalsMapperTest.php deleted file mode 100644 index 0519c7928d2b172746f88187917cf578e9e673b8..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/TotalsMapperTest.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -class TotalsMapperTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Checkout\Service\V1\Data\Cart\TotalsMapper - */ - protected $mapper; - - protected function setUp() - { - $this->mapper = new \Magento\Checkout\Service\V1\Data\Cart\TotalsMapper(); - } - - public function testMap() - { - $methods = ['getBaseGrandTotal', 'getGrandTotal', 'getBaseSubtotal', 'getSubtotal','getBaseCurrencyCode', - 'getBaseSubtotalWithDiscount', 'getSubtotalWithDiscount', 'getShippingAddress', '__wakeUp', - 'getQuoteCurrencyCode', ]; - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', $methods, [], '', false); - $methods = [ - 'getDiscountAmount', 'getBaseDiscountAmount', 'getShippingAmount', 'getBaseShippingAmount', - 'getShippingDiscountAmount', 'getBaseShippingDiscountAmount', 'getTaxAmount', 'getBaseTaxAmount', - 'getShippingTaxAmount', 'getBaseShippingTaxAmount', 'getSubtotalInclTax', 'getBaseSubtotalTotalInclTax', - 'getShippingInclTax', 'getBaseShippingInclTax', 'getId', '__wakeUp', - ]; - - $shippingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', $methods, [], '', false); - - $quoteMock->expects($this->any())->method('getShippingAddress') - ->will($this->returnValue($shippingAddressMock)); - - $expected = [ - Totals::BASE_GRAND_TOTAL => 100, - Totals::GRAND_TOTAL => 150, - Totals::BASE_SUBTOTAL => 150, - Totals::SUBTOTAL => 150, - Totals::BASE_SUBTOTAL_WITH_DISCOUNT => 120, - Totals::SUBTOTAL_WITH_DISCOUNT => 120, - Totals::BASE_CURRENCY_CODE => 'EUR', - Totals::QUOTE_CURRENCY_CODE => 'BR', - Totals::DISCOUNT_AMOUNT => 110, - Totals::BASE_DISCOUNT_AMOUNT => 110, - Totals::SHIPPING_AMOUNT => 20, - Totals::BASE_SHIPPING_AMOUNT => 20, - Totals::SHIPPING_DISCOUNT_AMOUNT => 5, - Totals::BASE_SHIPPING_DISCOUNT_AMOUNT => 5, - Totals::TAX_AMOUNT => 3, - Totals::BASE_TAX_AMOUNT => 3, - Totals::SHIPPING_TAX_AMOUNT => 1, - Totals::BASE_SHIPPING_TAX_AMOUNT => 1, - Totals::SUBTOTAL_INCL_TAX => 153, - Totals::BASE_SUBTOTAL_INCL_TAX => 153, - Totals::SHIPPING_INCL_TAX => 21, - Totals::BASE_SHIPPING_INCL_TAX => 21, - ]; - $expectedQuoteMethods = [ - 'getBaseGrandTotal' => 100, - 'getGrandTotal' => 150, - 'getBaseSubtotal' => 150, - 'getSubtotal' => 150, - 'getBaseSubtotalWithDiscount' => 120, - 'getSubtotalWithDiscount' => 120, - ]; - - $addressMethods = [ - 'getDiscountAmount' => 110, - 'getBaseDiscountAmount' => 110, - 'getShippingAmount' => 20, - 'getBaseShippingAmount' => 20, - 'getShippingDiscountAmount' => 5, - 'getBaseShippingDiscountAmount' => 5, - 'getTaxAmount' => 3, - 'getBaseTaxAmount' => 3, - 'getShippingTaxAmount' => 1, - 'getBaseShippingTaxAmount' => 1, - 'getSubtotalInclTax' => 153, - 'getBaseSubtotalTotalInclTax' => 153, - 'getShippingInclTax' => 21, - 'getBaseShippingInclTax' => 21, - ]; - - $quoteMock->expects($this->atLeastOnce())->method('getBaseCurrencyCode')->will($this->returnValue('EUR')); - $quoteMock->expects($this->atLeastOnce())->method('getQuoteCurrencyCode')->will($this->returnValue('BR')); - - foreach ($expectedQuoteMethods as $method => $value) { - $quoteMock->expects($this->once())->method($method)->will($this->returnValue($value)); - } - foreach ($addressMethods as $method => $value) { - $shippingAddressMock->expects($this->once())->method($method)->will($this->returnValue($value)); - } - - $this->assertEquals($expected, $this->mapper->map($quoteMock)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/CartMapperTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/CartMapperTest.php deleted file mode 100644 index 19c4d479363d410e42aaf787a6fb7970ded51dc5..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/CartMapperTest.php +++ /dev/null @@ -1,170 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Service\V1\Data; - -class CartMapperTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Checkout\Service\V1\Data\CartMapper - */ - protected $mapper; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $totalsBuilder; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $cartBuilder; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $customerBuilder; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $customerMapper; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $totalsMapper; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $currencyMapper; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $itemTotalsMapper; - - protected function setUp() - { - $this->totalsBuilder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\TotalsBuilder', - ['populateWithArray', 'setItems', 'create'], - [], - '', - false - ); - $this->cartBuilder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\CartBuilder', - [], - [], - '', - false - ); - $this->customerBuilder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\CustomerBuilder', - [], - [], - '', - false - ); - $this->customerMapper = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\CustomerMapper', - [], - [], - '', - false - ); - $this->totalsMapper = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\TotalsMapper', [], [], '', false); - $this->currencyMapper = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\CurrencyMapper', - ['extractDto'], - [], - '', - false - ); - $this->itemTotalsMapper = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\Totals\ItemMapper', - ['extractDto'], - [], - '', - false - ); - - $this->mapper = new \Magento\Checkout\Service\V1\Data\CartMapper( - $this->totalsBuilder, - $this->cartBuilder, - $this->customerBuilder, - $this->customerMapper, - $this->totalsMapper, - $this->currencyMapper, - $this->itemTotalsMapper - ); - } - - public function testMap() - { - $methods = ['getId', 'getStoreId', 'getCreatedAt','getUpdatedAt', 'getConvertedAt', 'getIsActive', - 'getIsVirtual', 'getItemsCount', 'getItemsQty', 'getCheckoutMethod', 'getReservedOrderId', 'getOrigOrderId', - 'getAllItems', '__wakeUp', ]; - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', $methods, [], '', false); - $itemMock = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); - $quoteMock->expects($this->once())->method('getAllItems')->will($this->returnValue([$itemMock])); - $expected = [ - Cart::ID => 12, - Cart::STORE_ID => 1, - Cart::CREATED_AT => '2014-04-02 12:28:50', - Cart::UPDATED_AT => '2014-04-02 12:28:50', - Cart::CONVERTED_AT => '2014-04-02 12:28:50', - Cart::IS_ACTIVE => true, - Cart::IS_VIRTUAL => false, - Cart::ITEMS_COUNT => 10, - Cart::ITEMS_QUANTITY => 15, - Cart::CHECKOUT_METHOD => 'check mo', - Cart::RESERVED_ORDER_ID => 'order_id', - Cart::ORIG_ORDER_ID => 'orig_order_id', - ]; - $expectedMethods = [ - 'getId' => 12, - 'getStoreId' => 1, - 'getCreatedAt' => '2014-04-02 12:28:50', - 'getUpdatedAt' => '2014-04-02 12:28:50', - 'getConvertedAt' => '2014-04-02 12:28:50', - 'getIsActive' => true, - 'getIsVirtual' => false, - 'getItemsCount' => 10, - 'getItemsQty' => 15, - 'getCheckoutMethod' => 'check mo', - 'getReservedOrderId' => 'order_id', - 'getOrigOrderId' => 'orig_order_id', - ]; - foreach ($expectedMethods as $method => $value) { - $quoteMock->expects($this->once())->method($method)->will($this->returnValue($value)); - } - $this->customerMapper->expects($this->once())->method('map')->with($quoteMock) - ->will($this->returnValue(['testCustomer'])); - $this->customerBuilder->expects($this->once())->method('populateWithArray')->with(['testCustomer']); - $this->customerBuilder->expects($this->once())->method('create')->will($this->returnValue('customer')); - - $this->totalsMapper->expects($this->once())->method('map')->with($quoteMock) - ->will($this->returnValue(['testTotals'])); - $this->totalsBuilder->expects($this->once())->method('populateWithArray')->with(['testTotals']); - $this->totalsBuilder->expects($this->once())->method('create')->will($this->returnValue('totals')); - - $this->itemTotalsMapper->expects($this->once())->method('extractDto')->with($itemMock) - ->will($this->returnValue('mappedItem')); - - $this->totalsBuilder->expects($this->once())->method('setItems')->with(['mappedItem']); - - $this->currencyMapper->expects($this->once())->method('extractDto')->with($quoteMock) - ->will($this->returnValue('currency')); - - $this->cartBuilder->expects($this->once())->method('populateWithArray')->with($expected); - $this->cartBuilder->expects($this->once())->method('setCustomer')->with('customer'); - $this->cartBuilder->expects($this->once())->method('setTotals')->with('totals'); - $this->cartBuilder->expects($this->once())->method('setCurrency')->with('currency'); - $this->mapper->map($quoteMock); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/PaymentMethod/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/PaymentMethod/ConverterTest.php deleted file mode 100644 index db797717aca25c8d6f6cca034302c7d174015863..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/PaymentMethod/ConverterTest.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Data\PaymentMethod; - -use Magento\Checkout\Service\V1\Data\PaymentMethod; - -class ConverterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var Converter - */ - protected $converter; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $objectManager; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $paymentMethodBuilderMock; - - protected function setUp() - { - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->paymentMethodBuilderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\PaymentMethodBuilder', ['populateWithArray', 'create'], [], '', false - ); - - $this->converter = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\PaymentMethod\Converter', - [ - 'builder' => $this->paymentMethodBuilderMock, - ] - ); - } - - public function testConvertQuotePaymentObjectToPaymentDataObject() - { - $methodMock = $this->getMock('\Magento\Payment\Model\Method\AbstractMethod', [], [], '', false); - $methodMock->expects($this->once())->method('getCode')->will($this->returnValue('paymentCode')); - $methodMock->expects($this->once())->method('getTitle')->will($this->returnValue('paymentTitle')); - - $data = [ - PaymentMethod::TITLE => 'paymentTitle', - PaymentMethod::CODE => 'paymentCode', - ]; - - $this->paymentMethodBuilderMock->expects($this->once()) - ->method('populateWithArray') - ->with($data) - ->will($this->returnSelf()); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\PaymentMethod', [], [], '', false); - - $this->paymentMethodBuilderMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($paymentMethodMock)); - - $this->assertEquals($paymentMethodMock, $this->converter->toDataObject($methodMock)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/ReaderServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/ReaderServiceTest.php deleted file mode 100644 index c69f3100bb813c29babe09e10ff58d2765439dc0..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/ReaderServiceTest.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\Item; - -use Magento\Checkout\Service\V1\Data\Cart\Item as Item; - -class ReaderServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $itemMapperMock; - - protected function setUp() - { - $this->quoteRepositoryMock = $this->getMock('Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->itemMapperMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ItemMapper', ['extractDto'], [], '', false); - $this->service = new ReadService($this->quoteRepositoryMock, $this->itemMapperMock); - } - - public function testGetList() - { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once())->method('getActive') - ->with(33) - ->will($this->returnValue($quoteMock)); - $itemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', - ['getSku', 'getName', 'getPrice', 'getQty', 'getProductType', '__wakeup'], [], '', false); - $quoteMock->expects($this->any())->method('getAllItems')->will($this->returnValue([$itemMock])); - $testData = [ - Item::ITEM_ID => 7, - Item::SKU => 'prd_SKU', - Item::NAME => 'prd_NAME', - Item::PRICE => 100.15, - Item::QTY => 16, - Item::PRODUCT_TYPE => 'simple', - ]; - - $this->itemMapperMock - ->expects($this->once()) - ->method('extractDto') - ->with($itemMock) - ->will($this->returnValue($testData)); - $this->assertEquals([$testData], $this->service->getList(33)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php deleted file mode 100644 index f512c563edc02f8cdcd32798bd98841ba1b78d64..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\PaymentMethod; - -class ReadServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - protected $service; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $objectManager; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $paymentMethodConverterMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteMethodConverterMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $methodListMock; - - protected function setUp() - { - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->quoteMethodConverterMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter', [], [], '', false - ); - $this->paymentMethodConverterMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\PaymentMethod\Converter', [], [], '', false - ); - $this->methodListMock = $this->getMock('\Magento\Payment\Model\MethodList', [], [], '', false); - - $this->service = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\PaymentMethod\ReadService', - [ - 'quoteRepository' => $this->quoteRepositoryMock, - 'quoteMethodConverter' => $this->quoteMethodConverterMock, - 'paymentMethodConverter' => $this->paymentMethodConverterMock, - 'methodList' => $this->methodListMock, - ] - ); - } - - public function testGetPaymentIfPaymentMethodNotSet() - { - $cartId = 11; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false); - $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - $paymentMock->expects($this->once())->method('getId')->will($this->returnValue(null)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $this->assertNull($this->service->getPayment($cartId)); - } - - public function testGetPaymentSuccess() - { - $cartId = 11; - - $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false); - $paymentMock->expects($this->once())->method('getId')->will($this->returnValue(1)); - - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); - - $this->quoteMethodConverterMock->expects($this->once()) - ->method('toDataObject') - ->with($paymentMock) - ->will($this->returnValue($paymentMethodMock)); - - $this->assertEquals($paymentMethodMock, $this->service->getPayment($cartId)); - } - - public function testGetList() - { - $cartId = 10; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $methodList = [ - $this->getMock('\Magento\Payment\Model\MethodInterface'), - $this->getMock('\Magento\Payment\Model\MethodInterface'), - ]; - - $this->methodListMock->expects($this->once()) - ->method('getAvailableMethods') - ->with($quoteMock) - ->will($this->returnValue($methodList)); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\PaymentMethod', [], [], '', false); - - $this->paymentMethodConverterMock->expects($this->atLeastOnce()) - ->method('toDataObject') - ->will($this->returnValue($paymentMethodMock)); - - $expectedResult = [ - $this->getMock('\Magento\Checkout\Service\V1\Data\PaymentMethod', [], [], '', false), - $this->getMock('\Magento\Checkout\Service\V1\Data\PaymentMethod', [], [], '', false), - ]; - - $this->assertEquals($expectedResult, $this->service->getList($cartId)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php deleted file mode 100644 index b56618360da33ca5a9da58ce56503db33119ef80..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php +++ /dev/null @@ -1,307 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Checkout\Service\V1\PaymentMethod; - -class WriteServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var WriteService - */ - protected $service; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $objectManager; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $paymentMethodBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $methodListMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $validatorMock; - - protected function setUp() - { - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->paymentMethodBuilderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder', [], [], '', false - ); - $this->methodListMock = $this->getMock('\Magento\Payment\Model\MethodList', [], [], '', false); - $this->validatorMock = $this->getMock('\Magento\Payment\Model\Checks\ZeroTotal', [], [], '', false); - - $this->service = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\PaymentMethod\WriteService', - [ - 'quoteRepository' => $this->quoteRepositoryMock, - 'paymentMethodBuilder' => $this->paymentMethodBuilderMock, - 'methodList' => $this->methodListMock, - 'zeroTotalValidator' => $this->validatorMock, - ] - ); - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage Billing address is not set - */ - public function testSetVirtualQuotePaymentThrowsExceptionIfBillingAdressNotSet() - { - $cartId = 11; - - $paymentsCollectionMock = $this->getMock( - '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false - ); - - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $quoteMock->expects($this->any()) - ->method('getPaymentsCollection') - ->will($this->returnValue($paymentsCollectionMock)); - $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(true)); - - $billingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); - $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); - - $this->service->set($paymentMethodMock, $cartId); - } - - public function testSetVirtualQuotePaymentSuccess() - { - $cartId = 11; - $paymentId = 13; - $paymentsCollectionMock = $this->getMock( - '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false - ); - - $quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', - [ - 'setTotalsCollectedFlag', '__wakeup', 'getPaymentsCollection', 'getPayment', - 'getItemsCollection', 'isVirtual', 'getBillingAddress', 'collectTotals', 'save' - ], [], '', false - ); - $quoteMock->expects($this->any()) - ->method('getPaymentsCollection') - ->will($this->returnValue($paymentsCollectionMock)); - $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(true)); - - $billingAddressMock = - $this->getMock('\Magento\Quote\Model\Quote\Address', ['getCountryId', '__wakeup'], [], '', false); - $billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(1)); - $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); - - $quoteMock->expects($this->once())->method('setTotalsCollectedFlag')->will($this->returnSelf()); - $quoteMock->expects($this->once())->method('collectTotals')->will($this->returnSelf()); - - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); - $paymentMock->expects($this->once())->method('getId')->will($this->returnValue($paymentId)); - - $methodMock = $this->getMockForAbstractClass( - '\Magento\Payment\Model\Method\AbstractMethod', [], '', false, false - ); - - $paymentMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodMock)); - - $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); - $this->validatorMock->expects($this->once())->method('isApplicable') - ->with($methodMock, $quoteMock)->will($this->returnValue(true)); - - $this->paymentMethodBuilderMock->expects($this->once()) - ->method('build') - ->with($paymentMethodMock, $quoteMock) - ->will($this->returnValue($paymentMock)); - - $this->assertEquals($paymentId, $this->service->set($paymentMethodMock, $cartId)); - } - - /** - * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException - * @expectedExceptionMessage The requested Payment Method is not available. - */ - public function testSetVirtualQuotePaymentFail() - { - $cartId = 11; - - $paymentsCollectionMock = $this->getMock( - '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false - ); - - $quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', - [ - 'setTotalsCollectedFlag', '__wakeup', 'getPaymentsCollection', 'getPayment', - 'getItemsCollection', 'isVirtual', 'getBillingAddress', 'collectTotals' - ], [], '', false - ); - $quoteMock->expects($this->any()) - ->method('getPaymentsCollection') - ->will($this->returnValue($paymentsCollectionMock)); - $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(true)); - - $billingAddressMock = - $this->getMock('\Magento\Quote\Model\Quote\Address', ['getCountryId', '__wakeup'], [], '', false); - $billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(1)); - $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); - - $quoteMock->expects($this->never())->method('setTotalsCollectedFlag'); - $quoteMock->expects($this->never())->method('collectTotals'); - - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); - $paymentMock->expects($this->never())->method('getId'); - - $methodMock = $this->getMockForAbstractClass( - '\Magento\Payment\Model\Method\AbstractMethod', [], '', false, false - ); - - $paymentMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodMock)); - - $quoteMock->expects($this->never())->method('getPayment'); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); - $this->validatorMock->expects($this->once())->method('isApplicable') - ->with($methodMock, $quoteMock)->will($this->returnValue(false)); - - $this->paymentMethodBuilderMock->expects($this->once()) - ->method('build') - ->with($paymentMethodMock, $quoteMock) - ->will($this->returnValue($paymentMock)); - - $this->service->set($paymentMethodMock, $cartId); - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage Shipping address is not set - */ - public function testSetNotVirtualQuotePaymentThrowsExceptionIfShippingAddressNotSet() - { - $cartId = 11; - $quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', - ['__wakeup', 'getPaymentsCollection', 'isVirtual', 'getShippingAddress'], [], '', false - ); - - $paymentsCollectionMock = $this->getMock( - '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false - ); - - $quoteMock->expects($this->any()) - ->method('getPaymentsCollection') - ->will($this->returnValue($paymentsCollectionMock)); - $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(false)); - $quoteMock->expects($this->any()) - ->method('getShippingAddress') - ->will($this->returnValue($this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false))); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); - - $this->paymentMethodBuilderMock->expects($this->once()) - ->method('build') - ->with($paymentMethodMock, $quoteMock) - ->will($this->returnValue($paymentMock)); - - $this->service->set($paymentMethodMock, $cartId); - } - - public function testSetNotVirtualQuotePaymentSuccess() - { - $cartId = 11; - $paymentId = 13; - - $paymentsCollectionMock = $this->getMock( - '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false - ); - - $quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', - [ - 'setTotalsCollectedFlag', '__wakeup', 'getPaymentsCollection', 'getPayment', - 'getItemsCollection', 'isVirtual', 'getShippingAddress', 'collectTotals', 'save' - ], [], '', false - ); - $quoteMock->expects($this->any()) - ->method('getPaymentsCollection') - ->will($this->returnValue($paymentsCollectionMock)); - $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(false)); - - $shippingAddressMock = - $this->getMock('\Magento\Quote\Model\Quote\Address', ['getCountryId', '__wakeup'], [], '', false); - $shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(1)); - $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($shippingAddressMock)); - - $quoteMock->expects($this->once())->method('setTotalsCollectedFlag')->will($this->returnSelf()); - $quoteMock->expects($this->once())->method('collectTotals')->will($this->returnSelf()); - - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); - $paymentMock->expects($this->once())->method('getId')->will($this->returnValue($paymentId)); - - $methodMock = $this->getMockForAbstractClass( - '\Magento\Payment\Model\Method\AbstractMethod', [], '', false, false - ); - $paymentMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodMock)); - $this->validatorMock->expects($this->once())->method('isApplicable') - ->with($methodMock, $quoteMock)->will($this->returnValue(true)); - - $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($quoteMock)); - - $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); - - $this->paymentMethodBuilderMock->expects($this->once()) - ->method('build') - ->with($paymentMethodMock, $quoteMock) - ->will($this->returnValue($paymentMock)); - - $this->assertEquals($paymentId, $this->service->set($paymentMethodMock, $cartId)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php deleted file mode 100644 index 196f0db3ceb025f82061bbdaaa17ceea3a2b34d9..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php +++ /dev/null @@ -1,268 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Checkout\Service\V1\ShippingMethod; - -use Magento\Checkout\Service\V1\Data\Cart\ShippingMethod; -use Magento\TestFramework\Helper\ObjectManager; - -class ReadServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $shippingAddressMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $methodBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $converterMock; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = new ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->methodBuilderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', - ['populateWithArray', 'create'], - [], - '', - false - ); - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $this->quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', - [ - 'getShippingAddress', - 'isVirtual', - 'getItemsCount', - 'getQuoteCurrencyCode', - '__wakeup', - ], - [], - '', - false - ); - $this->shippingAddressMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address', - [ - 'getCountryId', - 'getShippingMethod', - 'getShippingDescription', - 'getShippingAmount', - 'getBaseShippingAmount', - 'getGroupedAllShippingRates', - 'collectShippingRates', - '__wakeup', - ], - [], - '', - false - ); - $this->converterMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter', - [], - [], - '', - false - ); - - $this->service = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\ShippingMethod\ReadService', - [ - 'quoteRepository' => $this->quoteRepositoryMock, - 'methodBuilder' => $this->methodBuilderMock, - 'converter' => $this->converterMock, - ] - ); - } - - /** - * @expectedException \Magento\Framework\Exception\StateException - * @expectedExceptionMessage Shipping address not set. - */ - public function testGetMethodWhenShippingAddressIsNotSet() - { - $cartId = 666; - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); - - $this->assertNull($this->service->getMethod($cartId)); - } - - /** - * @expectedException \Magento\Framework\Exception\InputException - * @expectedExceptionMessage Line "WrongShippingMethod" doesn't contain delimiter _ - */ - public function testGetMethodWhenShippingMethodIsInvalid() - { - $cartId = 884; - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(34)); - $this->shippingAddressMock->expects($this->exactly(2)) - ->method('getShippingMethod') - ->will($this->returnValue('WrongShippingMethod')); - - $this->assertNull($this->service->getMethod($cartId)); - } - - public function testGetMethod() - { - $cartId = 666; - $countryId = 1; - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->any()) - ->method('getCountryId')->will($this->returnValue($countryId)); - $this->shippingAddressMock->expects($this->any()) - ->method('getShippingMethod')->will($this->returnValue('one_two')); - $this->shippingAddressMock->expects($this->once()) - ->method('getShippingDescription')->will($this->returnValue('carrier - method')); - $this->shippingAddressMock->expects($this->once()) - ->method('getShippingAmount')->will($this->returnValue(123.56)); - $this->shippingAddressMock->expects($this->once()) - ->method('getBaseShippingAmount')->will($this->returnValue(100.06)); - $output = [ - ShippingMethod::CARRIER_CODE => 'one', - ShippingMethod::METHOD_CODE => 'two', - ShippingMethod::CARRIER_TITLE => 'carrier', - ShippingMethod::METHOD_TITLE => 'method', - ShippingMethod::SHIPPING_AMOUNT => 123.56, - ShippingMethod::BASE_SHIPPING_AMOUNT => 100.06, - ShippingMethod::AVAILABLE => true, - ]; - $this->methodBuilderMock->expects($this->once()) - ->method('populateWithArray')->with($output)->will($this->returnValue($this->methodBuilderMock)); - $this->methodBuilderMock->expects($this->once())->method('create'); - - $this->service->getMethod($cartId); - } - - public function testGetMethodIfMethodIsNotSet() - { - $cartId = 666; - $countryId = 1; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->any()) - ->method('getCountryId')->will($this->returnValue($countryId)); - $this->shippingAddressMock->expects($this->any()) - ->method('getShippingMethod')->will($this->returnValue(null)); - - $this->assertNull($this->service->getMethod($cartId)); - } - - public function testGetListForVirtualCart() - { - $cartId = 834; - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('isVirtual')->will($this->returnValue(true)); - - $this->assertEquals([], $this->service->getList($cartId)); - } - - public function testGetListForEmptyCart() - { - $cartId = 834; - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('isVirtual')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('getItemsCount')->will($this->returnValue(0)); - - $this->assertEquals([], $this->service->getList($cartId)); - } - - /** - * @expectedException \Magento\Framework\Exception\StateException - * @expectedExceptionMessage Shipping address not set. - */ - public function testGetListWhenShippingAddressIsNotSet() - { - $cartId = 834; - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('isVirtual')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('getItemsCount')->will($this->returnValue(3)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); - - $this->service->getList($cartId); - } - - public function testGetList() - { - $cartId = 834; - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('isVirtual')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('getItemsCount')->will($this->returnValue(3)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(345)); - $this->shippingAddressMock->expects($this->once())->method('collectShippingRates'); - $shippingRateMock = $this->getMock('\Magento\Quote\Model\Quote\Address\Rate', [], [], '', false); - $this->shippingAddressMock->expects($this->once()) - ->method('getGroupedAllShippingRates') - ->will($this->returnValue([[$shippingRateMock]])); - - $currencyCode = 'EUR'; - $this->quoteMock->expects($this->once()) - ->method('getQuoteCurrencyCode') - ->will($this->returnValue($currencyCode)); - - $this->converterMock->expects($this->once()) - ->method('modelToDataObject') - ->with($shippingRateMock, $currencyCode) - ->will($this->returnValue('RateValue')); - $this->assertEquals(['RateValue'], $this->service->getList($cartId)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepositoryTest.php b/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepositoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..24541f489f6e398f2e262d2de67de6df2c66f14b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepositoryTest.php @@ -0,0 +1,98 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CheckoutAgreements\Model; + +use Magento\Store\Model\ScopeInterface; +use Magento\TestFramework\Helper\ObjectManager; + +class CheckoutAgreementsRepositoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CheckoutAgreementsRepository + */ + private $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $factoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $scopeConfigMock; + + /** + * @var ObjectManager + */ + private $objectManager; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + + $this->factoryMock = $this->getMock( + 'Magento\CheckoutAgreements\Model\Resource\Agreement\CollectionFactory', + ['create'], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->model = new CheckoutAgreementsRepository( + $this->factoryMock, + $this->storeManagerMock, + $this->scopeConfigMock + ); + } + + public function testGetListReturnsEmptyListIfCheckoutAgreementsAreDisabledOnFrontend() + { + $this->scopeConfigMock->expects($this->once()) + ->method('isSetFlag') + ->with('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE, null) + ->will($this->returnValue(false)); + $this->factoryMock->expects($this->never())->method('create'); + $this->assertEmpty($this->model->getList()); + } + + public function testGetListReturnsTheListOfActiveCheckoutAgreements() + { + $this->scopeConfigMock->expects($this->once()) + ->method('isSetFlag') + ->with('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE, null) + ->will($this->returnValue(true)); + + $agreementDataObject = $this->getMock( + 'Magento\CheckoutAgreements\Model\Agreement', + [], + [], + '', + false + ); + + $storeId = 1; + $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId)); + $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); + + $collectionMock = $this->objectManager->getCollectionMock( + 'Magento\CheckoutAgreements\Model\Resource\Agreement\Collection', + [$agreementDataObject] + ); + $this->factoryMock->expects($this->once())->method('create')->will($this->returnValue($collectionMock)); + $collectionMock->expects($this->once())->method('addStoreFilter')->with($storeId); + $collectionMock->expects($this->once())->method('addFieldToFilter')->with('is_active', 1); + + $this->assertEquals([$agreementDataObject], $this->model->getList()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php deleted file mode 100644 index 14d2432ef89404909c151b7d7a84f9a0c02e6e23..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\CheckoutAgreements\Service\V1\Agreement; - -use Magento\Store\Model\ScopeInterface; -use Magento\TestFramework\Helper\ObjectManager; - -class ReadServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - private $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $factoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $agreementBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $scopeConfigMock; - - /** - * @var ObjectManager - */ - private $objectManager; - - protected function setUp() - { - $this->objectManager = new ObjectManager($this); - - $this->factoryMock = $this->getMock( - 'Magento\CheckoutAgreements\Model\Resource\Agreement\CollectionFactory', - ['create'], - [], - '', - false - ); - $this->agreementBuilderMock = $this->getMock( - 'Magento\CheckoutAgreements\Service\V1\Data\AgreementBuilder', - [], - [], - '', - false - ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->service = new ReadService( - $this->factoryMock, - $this->agreementBuilderMock, - $this->storeManagerMock, - $this->scopeConfigMock - ); - } - - public function testGetListReturnsEmptyListIfCheckoutAgreementsAreDisabledOnFrontend() - { - $this->scopeConfigMock->expects($this->once()) - ->method('isSetFlag') - ->with('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE, null) - ->will($this->returnValue(false)); - $this->factoryMock->expects($this->never())->method('create'); - $this->assertEmpty($this->service->getList()); - } - - public function testGetListReturnsTheListOfActiveCheckoutAgreements() - { - $this->scopeConfigMock->expects($this->once()) - ->method('isSetFlag') - ->with('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE, null) - ->will($this->returnValue(true)); - - $agreementData = [ - 'id' => 1, - 'name' => 'Checkout Agreement', - 'content' => 'Agreement content: <b>HTML</b>', - 'content_height' => '100px', - 'checkbox_text' => 'Checkout Agreement Checkbox Text', - 'active' => true, - 'html' => true, - ]; - - $storeId = 1; - $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); - - $collectionMock = $this->objectManager->getCollectionMock( - 'Magento\CheckoutAgreements\Model\Resource\Agreement\Collection', - [$this->getAgreementMock($agreementData)] - ); - $this->factoryMock->expects($this->once())->method('create')->will($this->returnValue($collectionMock)); - $collectionMock->expects($this->once())->method('addStoreFilter')->with($storeId); - $collectionMock->expects($this->once())->method('addFieldToFilter')->with('is_active', 1); - - $agreementDataObject = $this->getMock( - 'Magento\CheckoutAgreements\Service\V1\Data\Agreement', - [], - [], - '', - false - ); - $this->agreementBuilderMock->expects($this->once())->method('populateWithArray')->with($agreementData); - $this->agreementBuilderMock->expects($this->once())->method('create') - ->will($this->returnValue($agreementDataObject)); - - $this->assertEquals([$agreementDataObject], $this->service->getList()); - } - - /** - * Retrieve agreement mock based on given data - * - * @param array $agreementData - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function getAgreementMock(array $agreementData) - { - $agreementMock = $this->getMock( - 'Magento\CheckoutAgreements\Model\Agreement', - [ - 'getId', 'getName', 'getContent', 'getContentHeight', 'getCheckboxText', 'getIsActive', 'getIsHtml', - '__wakeup', '__sleep', - ], - [], - '', - false - ); - $agreementMock->expects($this->any())->method('getId') - ->will($this->returnValue($agreementData['id'])); - $agreementMock->expects($this->any())->method('getName') - ->will($this->returnValue($agreementData['name'])); - $agreementMock->expects($this->any())->method('getContent') - ->will($this->returnValue($agreementData['content'])); - $agreementMock->expects($this->any())->method('getContentHeight') - ->will($this->returnValue($agreementData['content_height'])); - $agreementMock->expects($this->any())->method('getCheckboxText') - ->will($this->returnValue($agreementData['checkbox_text'])); - $agreementMock->expects($this->any())->method('getIsActive') - ->will($this->returnValue($agreementData['active'])); - $agreementMock->expects($this->any())->method('getIsHtml') - ->will($this->returnValue($agreementData['html'])); - return $agreementMock; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleBuilder.txt b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleBuilder.txt index cd38526a0242951d97bcc9f403e121e6e3f37a24..147361604dce53b339f65b5c88a4b58244a36e6c 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleBuilder.txt +++ b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleBuilder.txt @@ -1,7 +1,7 @@ namespace \Magento\Framework\Api\Code\Generator; /** - * Builder class for \Magento\Framework\Api\Code\Generator\Sample + * Builder class for @see \Magento\Framework\Api\Code\Generator\Sample */ class SampleBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder { diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleMapper.txt b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleMapper.txt index b022751c544ea0dfbf774fed44ff1e0642ce1ec3..7ec692fc3fd5b7dc1d7ca21d1643e4ceff7c92a2 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleMapper.txt +++ b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleMapper.txt @@ -1,7 +1,7 @@ namespace \Magento\Framework\Api\Code\Generator; /** - * Mapper class for \Magento\Framework\Api\Code\Generator\Sample + * Mapper class for @see \Magento\Framework\Api\Code\Generator\Sample */ class SampleMapper { 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 96578961ade1fcb36bbeee70a249a9c31e18ec9f..29c9f9959380dc2de101d82b34116baa3d8dcd83 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 @@ -1,7 +1,7 @@ namespace \Magento\Framework\Api\Code\Generator; /** - * SearchResultsBuilder class for \Magento\Framework\Api\Code\Generator\Sample + * SearchResultsBuilder class for @see \Magento\Framework\Api\Code\Generator\Sample */ class SampleSearchResultsBuilder extends \Magento\Framework\Api\AbstractSearchResultsBuilder { diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/AreaTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/AreaTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bf2f452a45a18a25c4b183457c32aeaeea6fac5c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/AreaTest.php @@ -0,0 +1,316 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\App; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class AreaTest extends \PHPUnit_Framework_TestCase +{ + const SCOPE_ID = '1'; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Framework\Event\ManagerInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Framework\App\ObjectManager\ConfigLoader | \PHPUnit_Framework_MockObject_MockObject + */ + protected $diConfigLoaderMock; + + /** + * @var \Magento\Framework\TranslateInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $translatorMock; + + /** + * @var \Psr\Log\LoggerInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Framework\App\DesignInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $designMock; + + /** + * @var \Magento\Framework\App\ScopeResolverInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeResolverMock; + + /** + * @var \Magento\Framework\View\DesignExceptions | \PHPUnit_Framework_MockObject_MockObject + */ + protected $designExceptionsMock; + + /** + * @var string + */ + protected $areaCode; + + /** + * @var Area + */ + protected $object; + + /** @var \Magento\Framework\Phrase\RendererInterface */ + private $defaultRenderer; + + public function setUp() + { + $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->translatorMock = $this->getMockBuilder('Magento\Framework\TranslateInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->diConfigLoaderMock = $this->getMockBuilder('Magento\Framework\App\ObjectManager\ConfigLoader') + ->disableOriginalConstructor() + ->getMock(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->designMock = $this->getMockBuilder('Magento\Framework\App\DesignInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->scopeResolverMock = $this->getMockBuilder('Magento\Framework\App\ScopeResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + $scopeMock = $this->getMockBuilder('Magento\Framework\App\ScopeInterface') + ->disableOriginalConstructor() + ->getMock(); + $scopeMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue(self::SCOPE_ID)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($scopeMock)); + $this->designExceptionsMock = $this->getMockBuilder('Magento\Framework\View\DesignExceptions') + ->disableOriginalConstructor() + ->getMock(); + $this->areaCode = Area::AREA_FRONTEND; + + $this->object = $this->objectManager->getObject( + 'Magento\Framework\App\Area', + [ + 'logger' => $this->loggerMock, + 'objectManager' => $this->objectManagerMock, + 'eventManager' => $this->eventManagerMock, + 'translator' => $this->translatorMock, + 'diConfigLoader' => $this->diConfigLoaderMock, + 'design' => $this->designMock, + 'scopeResolver' => $this->scopeResolverMock, + 'designExceptions' => $this->designExceptionsMock, + 'areaCode' => $this->areaCode, + ] + ); + } + + public function tearDown() + { + \Magento\Framework\Phrase::setRenderer($this->defaultRenderer); + } + + public function testLoadConfig() + { + $this->verifyLoadConfig(); + $this->object->load(Area::PART_CONFIG); + } + + public function testLoadTranslate() + { + $this->translatorMock->expects($this->once()) + ->method('loadData'); + $renderMock = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\Phrase\RendererInterface') + ->will($this->returnValue($renderMock)); + $this->object->load(Area::PART_TRANSLATE); + } + + public function testLoadDesign() + { + $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\View\DesignInterface') + ->will($this->returnValue($designMock)); + $designMock->expects($this->once()) + ->method('setArea') + ->with($this->areaCode) + ->willReturnSelf(); + $designMock->expects($this->once()) + ->method('setDefaultDesignTheme'); + $this->object->load(Area::PART_DESIGN); + } + + public function testLoadUnknownPart() + { + $this->objectManagerMock->expects($this->never()) + ->method('configure'); + $this->objectManagerMock->expects($this->never()) + ->method('get'); + $this->object->load('unknown part'); + } + + public function testLoad() + { + $this->verifyLoadConfig(); + $this->translatorMock->expects($this->once()) + ->method('loadData'); + $renderMock = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface') + ->disableOriginalConstructor() + ->getMock(); + $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + ->disableOriginalConstructor() + ->getMock(); + $designMock->expects($this->once()) + ->method('setArea') + ->with($this->areaCode) + ->willReturnSelf(); + $designMock->expects($this->once()) + ->method('setDefaultDesignTheme'); + $this->objectManagerMock->expects($this->exactly(2)) + ->method('get') + ->will($this->returnValueMap( + [ + ['Magento\Framework\Phrase\RendererInterface', $renderMock], + ['Magento\Framework\View\DesignInterface', $designMock], + ] + )); + $this->object->load(); + } + + private function verifyLoadConfig() + { + $configs = ['dummy configs']; + $this->diConfigLoaderMock->expects($this->once()) + ->method('load') + ->with($this->areaCode) + ->will($this->returnValue($configs)); + $this->objectManagerMock->expects($this->once()) + ->method('configure') + ->with($configs); + } + + public function testDetectDesign() + { + $this->designExceptionsMock->expects($this->never()) + ->method('getThemeByRequest'); + $this->designMock->expects($this->once()) + ->method('loadChange') + ->with(self::SCOPE_ID) + ->willReturnSelf(); + $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\View\DesignInterface') + ->will($this->returnValue($designMock)); + $this->designMock->expects($this->once()) + ->method('changeDesign') + ->with($designMock) + ->willReturnSelf(); + $this->object->detectDesign(); + } + + /** + * @param string|bool $value + * @param int $callNum + * @param int $callNum2 + * @dataProvider detectDesignByRequestDataProvider + */ + public function testDetectDesignByRequest($value, $callNum, $callNum2) + { + $this->designExceptionsMock->expects($this->once()) + ->method('getThemeByRequest') + ->will($this->returnValue($value)); + $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + ->disableOriginalConstructor() + ->getMock(); + $designMock->expects($this->exactly($callNum)) + ->method('setDesignTheme'); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\View\DesignInterface') + ->will($this->returnValue($designMock)); + $this->designMock->expects($this->exactly($callNum2)) + ->method('loadChange') + ->with(self::SCOPE_ID) + ->willReturnSelf(); + $this->designMock->expects($this->exactly($callNum2)) + ->method('changeDesign') + ->with($designMock) + ->willReturnSelf(); + $requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + $this->object->detectDesign($requestMock); + } + + public function detectDesignByRequestDataProvider() + { + return [ + [false, 0, 1], + ['theme', 1, 0], + ]; + } + + public function testDetectDesignByRequestWithException() + { + $exception = new \Exception('exception'); + $this->designExceptionsMock->expects($this->once()) + ->method('getThemeByRequest') + ->will($this->throwException($exception)); + $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + ->disableOriginalConstructor() + ->getMock(); + $designMock->expects($this->never()) + ->method('setDesignTheme'); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\View\DesignInterface') + ->will($this->returnValue($designMock)); + $this->designMock->expects($this->once()) + ->method('loadChange') + ->with(self::SCOPE_ID) + ->willReturnSelf(); + $this->designMock->expects($this->once()) + ->method('changeDesign') + ->with($designMock) + ->willReturnSelf(); + $requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + $this->loggerMock->expects($this->once()) + ->method('critical') + ->with($exception); + $this->object->detectDesign($requestMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Config/BaseFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Config/BaseFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f6448f3f96ddd45a7a7b7f26a779cb04d04f73ab --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Config/BaseFactoryTest.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Config; + +class BaseFactoryTest extends \Magento\Test\AbstractFactoryTestCase +{ + protected function setUp() + { + $this->instanceClassName = 'Magento\Framework\App\Config\Base'; + $this->factoryClassName = 'Magento\Framework\App\Config\BaseFactory'; + parent::setUp(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Config/Data/BackendModelPoolTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Data/ProcessorFactoryTest.php similarity index 93% rename from dev/tests/unit/testsuite/Magento/Framework/App/Config/Data/BackendModelPoolTest.php rename to dev/tests/unit/testsuite/Magento/Framework/App/Config/Data/ProcessorFactoryTest.php index 07933f8e00ba7e157ecc565341980d45633ffb47..807f2cf9e59ca758ffa323576e1fb97f1e94b10c 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Config/Data/BackendModelPoolTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Data/ProcessorFactoryTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\App\Config\Data; -class BackendModelPoolTest extends \PHPUnit_Framework_TestCase +class ProcessorFactoryTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Framework\App\Config\Data\ProcessorFactory @@ -27,7 +27,6 @@ class BackendModelPoolTest extends \PHPUnit_Framework_TestCase $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); $this->_model = new \Magento\Framework\App\Config\Data\ProcessorFactory($this->_objectManager); $this->_processorMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\Data\ProcessorInterface'); - $this->_processorMock->expects($this->any())->method('processValue')->will($this->returnArgument(0)); } /** @@ -54,6 +53,7 @@ class BackendModelPoolTest extends \PHPUnit_Framework_TestCase /** * @covers \Magento\Framework\App\Config\Data\ProcessorFactory::get * @expectedException \InvalidArgumentException + * @expectedExceptionMessageRegExp /\w+\\WrongBackendModel is not instance of \w+\\ProcessorInterface/ */ public function testGetModelWithWrongInterface() { diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Config/DataFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Config/DataFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3f578938d546fb7e5426ff968ed96ded17e80785 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Config/DataFactoryTest.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Config; + +class DataFactoryTest extends \Magento\Test\AbstractFactoryTestCase +{ + protected function setUp() + { + $this->instanceClassName = 'Magento\Framework\App\Config\Data'; + $this->factoryClassName = 'Magento\Framework\App\Config\DataFactory'; + parent::setUp(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/ReaderTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/ReaderTest.php index 5193cf725cb9d23f227773cd440fe9c8842f04b5..7fcf4042a15d6c38735c1c7c250551766d6818f6 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/ReaderTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/ReaderTest.php @@ -9,60 +9,60 @@ use Magento\Framework\Filesystem; class ReaderTest extends \PHPUnit_Framework_TestCase { + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + /** * @var \Magento\Framework\App\Config\Initial\Reader */ - protected $_model; + protected $model; /** - * @var \Magento\Framework\Config\FileResolverInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Config\FileResolverInterface | \PHPUnit_Framework_MockObject_MockObject */ - protected $_fileResolverMock; + protected $fileResolverMock; /** - * @var \Magento\Framework\App\Config\Initial\Converter|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Config\Initial\Converter | \PHPUnit_Framework_MockObject_MockObject */ - protected $_converterMock; + protected $converterMock; /** * @var string */ - protected $_filePath; + protected $filePath; + + /** + * @var \Magento\Framework\Config\ValidationStateInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $validationStateMock; /** - * @var \Magento\Framework\Filesystem\Directory\Read|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Config\Initial\SchemaLocator | \PHPUnit_Framework_MockObject_MockObject */ - protected $rootDirectory; + protected $schemaLocatorMock; protected function setUp() { - $this->_filePath = __DIR__ . '/_files/'; - $this->_fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); - $this->_converterMock = $this->getMock('Magento\Framework\App\Config\Initial\Converter'); - $schemaLocatorMock = $this->getMock( + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->filePath = __DIR__ . '/_files/'; + $this->fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); + $this->converterMock = $this->getMock('Magento\Framework\App\Config\Initial\Converter'); + $this->schemaLocatorMock = $this->getMock( 'Magento\Framework\App\Config\Initial\SchemaLocator', [], [], '', false ); - $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->once())->method('isValidated')->will($this->returnValue(true)); - $schemaFile = $this->_filePath . 'config.xsd'; - $schemaLocatorMock->expects($this->once())->method('getSchema')->will($this->returnValue($schemaFile)); - $this->rootDirectory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Read', - ['readFile', 'getRelativePath'], - [], - '', - false - ); - $this->_model = new \Magento\Framework\App\Config\Initial\Reader( - $this->_fileResolverMock, - $this->_converterMock, - $schemaLocatorMock, - $validationStateMock - ); + $this->validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + } + + public function testConstructor() + { + $this->createModelAndVerifyConstructor(); } /** @@ -70,18 +70,13 @@ class ReaderTest extends \PHPUnit_Framework_TestCase */ public function testReadNoFiles() { - $this->_fileResolverMock->expects( - $this->at(0) - )->method( - 'get' - )->with( - 'config.xml', - 'global' - )->will( - $this->returnValue([]) - ); + $this->createModelAndVerifyConstructor(); + $this->fileResolverMock->expects($this->at(0)) + ->method('get') + ->with('config.xml', 'global') + ->will($this->returnValue([])); - $this->assertEquals([], $this->_model->read()); + $this->assertEquals([], $this->model->read()); } /** @@ -89,37 +84,67 @@ class ReaderTest extends \PHPUnit_Framework_TestCase */ public function testReadValidConfig() { + $this->createModelAndVerifyConstructor(); $testXmlFilesList = [ - file_get_contents($this->_filePath . 'initial_config1.xml'), - file_get_contents($this->_filePath . 'initial_config2.xml'), + file_get_contents($this->filePath . 'initial_config1.xml'), + file_get_contents($this->filePath . 'initial_config2.xml'), ]; $expectedConfig = ['data' => [], 'metadata' => []]; - $this->_fileResolverMock->expects( - $this->at(0) - )->method( - 'get' - )->with( - 'config.xml', - 'global' - )->will( - $this->returnValue($testXmlFilesList) - ); + $this->fileResolverMock->expects($this->at(0)) + ->method('get') + ->with('config.xml', 'global') + ->will($this->returnValue($testXmlFilesList)); - $this->_converterMock->expects( - $this->once() - )->method( - 'convert' - )->with( - $this->anything() - )->will( - $this->returnValue($expectedConfig) - ); + $this->converterMock->expects($this->once()) + ->method('convert') + ->with($this->anything()) + ->will($this->returnValue($expectedConfig)); + + $this->assertEquals($expectedConfig, $this->model->read()); + } + + /** + * @covers \Magento\Framework\App\Config\Initial\Reader::read + * @expectedException \Magento\Framework\Exception + * @expectedExceptionMessageRegExp /Invalid XML in file \w+/ + */ + public function testReadInvalidConfig() + { + $this->createModelAndVerifyConstructor(); + $testXmlFilesList = [ + file_get_contents($this->filePath . 'invalid_config.xml'), + file_get_contents($this->filePath . 'initial_config2.xml'), + ]; + $expectedConfig = ['data' => [], 'metadata' => []]; + + $this->fileResolverMock->expects($this->at(0)) + ->method('get') + ->with('config.xml', 'global') + ->will($this->returnValue($testXmlFilesList)); - $this->rootDirectory->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); + $this->converterMock->expects($this->never()) + ->method('convert') + ->with($this->anything()) + ->will($this->returnValue($expectedConfig)); - $this->rootDirectory->expects($this->any())->method('readFile')->will($this->returnValue('<config></config>')); + $this->model->read(); + } + + private function createModelAndVerifyConstructor() + { + $this->validationStateMock->expects($this->once())->method('isValidated')->will($this->returnValue(true)); + $schemaFile = $this->filePath . 'config.xsd'; + $this->schemaLocatorMock->expects($this->once())->method('getSchema')->will($this->returnValue($schemaFile)); - $this->assertEquals($expectedConfig, $this->_model->read()); + $this->model = $this->objectManager->getObject( + 'Magento\Framework\App\Config\Initial\Reader', + [ + 'fileResolver' => $this->fileResolverMock, + 'converter' => $this->converterMock, + 'schemaLocator' => $this->schemaLocatorMock, + 'validationState' => $this->validationStateMock + ] + ); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/SchemaLocatorTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/SchemaLocatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..36ed85447054c40c0e7c3723669f3c5d6533f90f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/SchemaLocatorTest.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Config\Initial; + +class SchemaLocatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_moduleReaderMock; + + /** + * @var \Magento\Framework\App\Config\Initial\SchemaLocator + */ + protected $_model; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->_moduleReaderMock = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->_moduleReaderMock->expects($this->once()) + ->method('getModuleDir') + ->with('etc', 'moduleName') + ->will($this->returnValue('schema_dir')); + $this->_model = $this->objectManager->getObject( + 'Magento\Framework\App\Config\Initial\SchemaLocator', + [ + 'moduleReader' => $this->_moduleReaderMock, + 'moduleName' => 'moduleName', + ] + ); + } + + public function testGetSchema() + { + $this->assertEquals('schema_dir/config.xsd', $this->_model->getSchema()); + } + + public function testGetPerFileSchema() + { + $this->assertEquals('schema_dir/config.xsd', $this->_model->getPerFileSchema()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/_files/invalid_config.xml b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/_files/invalid_config.xml new file mode 100644 index 0000000000000000000000000000000000000000..07a89760bb4c4ef7a66d1fae4281121d2c34df91 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Initial/_files/invalid_config.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> + <invalid></invalid> +</config> diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Config/Storage/WriterTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Storage/WriterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..21a24fcfafafde4e8606a9c92c578eb01b858c80 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Config/Storage/WriterTest.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Config\Storage; + +use Magento\Framework\App\ScopeInterface; + +class WriterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Framework\App\Config\Storage\Writer + */ + protected $model; + + /** + * @var \Magento\Framework\App\Config\Resource\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->resource = $this->getMockBuilder('Magento\Framework\App\Config\Resource\ConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->model = $this->objectManager->getObject( + 'Magento\Framework\App\Config\Storage\Writer', + ['resource' => $this->resource] + ); + } + + public function testDelete() + { + $this->resource->expects($this->once()) + ->method('deleteConfig') + ->with('path', ScopeInterface::SCOPE_DEFAULT, 0); + $this->model->delete('path'); + } + + public function testDeleteOptions() + { + $scope = 'scope'; + $scopeId = '1'; + $this->resource->expects($this->once()) + ->method('deleteConfig') + ->with('path', $scope, $scopeId); + $this->model->delete('path', $scope, $scopeId); + } + + public function testSave() + { + $this->resource->expects($this->once()) + ->method('saveConfig') + ->with('path', 'value', ScopeInterface::SCOPE_DEFAULT, 0); + $this->model->save('path', 'value'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Config/ValueFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Config/ValueFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8ccad2ea3d6b6c1b234019b9fac0b02eb783faa9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Config/ValueFactoryTest.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Config; + +class ValueFactoryTest extends \Magento\Test\AbstractFactoryTestCase +{ + protected function setUp() + { + $this->instanceClassName = 'Magento\Framework\App\Config\ValueInterface'; + $this->factoryClassName = 'Magento\Framework\App\Config\ValueFactory'; + parent::setUp(); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testCreateWithException() + { + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('somethingElse')); + $this->factory->create(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Http/ContextTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Http/ContextTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6cf82d0261205abeee96a37ed3c620cd0129b9b0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Http/ContextTest.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\App\Http; + +class ContextTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var Context + */ + protected $object; + + public function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->object = $this->objectManager->getObject('Magento\Framework\App\Http\Context'); + } + + public function testGetValue() + { + $this->assertNull($this->object->getValue('key')); + } + + public function testSetGetValue() + { + $this->object->setValue('key', 'value', 'default'); + $this->assertEquals('value', $this->object->getValue('key')); + } + + public function testSetUnsetGetValue() + { + $this->object->setValue('key', 'value', 'default'); + $this->object->unsValue('key'); + $this->assertEquals('default', $this->object->getValue('key')); + } + + public function testGetData() + { + $this->object->setValue('key1', 'value1', 'default1'); + $this->object->setValue('key2', 'value2', 'default2'); + $this->object->setValue('key3', 'value3', 'value3'); + $this->object->unsValue('key1'); + $this->assertEquals(['key2' => 'value2'], $this->object->getData()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Resource/ConnectionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Resource/ConnectionFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..74105e5c2d30350344ccee3992b6025c588b3543 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Resource/ConnectionFactoryTest.php @@ -0,0 +1,91 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Resource; + +use Magento\Framework\DB\Adapter\DdlCache; + +class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Framework\App\Resource\ConnectionFactory + */ + protected $model; + + /** + * @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->model = $this->objectManager->getObject( + 'Magento\Framework\App\Resource\ConnectionFactory', + ['objectManager' => $this->objectManagerMock] + ); + } + + public function testCreateNull() + { + $this->objectManagerMock->expects($this->never()) + ->method('get'); + $this->assertNull($this->model->create([])); + $this->assertNull($this->model->create(['something'])); + $this->assertNull($this->model->create(['active' => null])); + } + + public function testCreate() + { + $cacheAdapterMock = $this->getMockBuilder('Magento\Framework\Cache\FrontendInterface') + ->disableOriginalConstructor() + ->getMock(); + $loggerMock = $this->getMockBuilder('Magento\Framework\DB\LoggerInterface') + ->disableOriginalConstructor() + ->getMock(); + $connectionAdapterMock = $this->getMockBuilder('Magento\Framework\App\Resource\ConnectionAdapterInterface') + ->disableOriginalConstructor() + ->getMock(); + $adapterInstanceMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->disableOriginalConstructor() + ->getMock(); + $adapterInstanceMock->expects($this->once()) + ->method('setCacheAdapter') + ->with($cacheAdapterMock) + ->willReturnSelf(); + $connectionAdapterMock->expects($this->once()) + ->method('getConnection') + ->with($loggerMock) + ->will($this->returnValue($adapterInstanceMock)); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Framework\App\Resource\ConnectionAdapterInterface') + ->will($this->returnValue($connectionAdapterMock)); + $poolMock = $this->getMockBuilder('Magento\Framework\App\Cache\Type\FrontendPool') + ->disableOriginalConstructor() + ->getMock(); + $poolMock->expects($this->once()) + ->method('get') + ->with(DdlCache::TYPE_IDENTIFIER) + ->will($this->returnValue($cacheAdapterMock)); + $this->objectManagerMock->expects($this->any()) + ->method('get') + ->will($this->returnValueMap( + [ + ['Magento\Framework\DB\LoggerInterface', $loggerMock], + ['Magento\Framework\App\Cache\Type\FrontendPool', $poolMock], + ] + )); + $this->assertSame($adapterInstanceMock, $this->model->create(['active' => true])); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Response/Http/FileFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Response/Http/FileFactoryTest.php index b6989570318e3ee4cfce0b55b685f327c907eed3..d037063ed3a7b616db699510a06fb8c0a15aeb32 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Response/Http/FileFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Response/Http/FileFactoryTest.php @@ -8,71 +8,61 @@ namespace Magento\Framework\App\Response\Http; class FileFactoryTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\App\Response\Http\FileFactory + * @var \Magento\TestFramework\Helper\ObjectManager */ - protected $_model; + protected $objectManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Filesystem */ - protected $_fileSystemMock; + protected $fileSystemMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\Response\Http */ - protected $_responseMock; + protected $responseMock; /** - * @var \Magento\Framework\Filesystem\Directory\WriteInterface + * @var \Magento\Framework\Filesystem\Directory\WriteInterface | \PHPUnit_Framework_MockObject_MockObject */ - protected $_dirMock; + protected $dirMock; protected function setUp() { - $this->_fileSystemMock = $this->getMock( + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->fileSystemMock = $this->getMock( 'Magento\Framework\Filesystem', ['getDirectoryWrite'], [], '', false ); - $this->_dirMock = $this->getMockBuilder( + $this->dirMock = $this->getMockBuilder( '\Magento\Framework\Filesystem\Directory\Write' )->disableOriginalConstructor()->getMock(); - $this->_fileSystemMock->expects( + $this->fileSystemMock->expects( $this->any() )->method( 'getDirectoryWrite' )->withAnyParameters()->will( - $this->returnValue($this->_dirMock) + $this->returnValue($this->dirMock) ); - $this->_fileSystemMock->expects( + $this->fileSystemMock->expects( $this->any() )->method( 'isFile' )->withAnyParameters()->will( $this->returnValue(0) ); - $this->_responseMock = $this->getMock( + $this->responseMock = $this->getMock( 'Magento\Framework\App\Response\Http', - ['setHeader', 'sendHeaders', '__wakeup'], + ['setHeader', 'sendHeaders', 'setHttpResponseCode', 'clearBody', 'setBody', '__wakeup'], [], '', false ); - $this->_responseMock->expects( - $this->any() - )->method( - 'setHeader' - )->will( - $this->returnValue($this->_responseMock) - ); - $this->_model = new \Magento\Framework\App\Response\Http\FileFactory( - $this->_responseMock, - $this->_fileSystemMock - ); } /** @@ -80,7 +70,7 @@ class FileFactoryTest extends \PHPUnit_Framework_TestCase */ public function testCreateIfContentDoesntHaveRequiredKeys() { - $this->_model->create('fileName', []); + $this->getModel()->create('fileName', []); } /** @@ -92,6 +82,183 @@ class FileFactoryTest extends \PHPUnit_Framework_TestCase $file = 'some_file'; $content = ['type' => 'filename', 'value' => $file]; - $this->_model->create('fileName', $content); + $this->responseMock->expects( + $this->never() + )->method( + 'setHeader' + )->will( + $this->returnSelf() + ); + $this->responseMock->expects( + $this->never() + )->method( + 'setHttpResponseCode' + )->will( + $this->returnSelf() + ); + $this->getModel()->create('fileName', $content); + } + + public function testCreateArrayContent() + { + $file = 'some_file'; + $content = ['type' => 'filename', 'value' => $file]; + + $this->dirMock->expects($this->once()) + ->method('isFile') + ->will($this->returnValue(true)); + $this->dirMock->expects($this->once()) + ->method('stat') + ->will($this->returnValue(['size' => 100])); + $this->responseMock->expects($this->exactly(6)) + ->method('setHeader') + ->will($this->returnSelf()); + $this->responseMock->expects($this->once()) + ->method('setHttpResponseCode') + ->with(200) + ->will($this->returnSelf()); + $this->responseMock->expects($this->once()) + ->method('sendHeaders') + ->will($this->returnSelf()); + + $streamMock = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + ->disableOriginalConstructor()->getMock(); + $this->dirMock->expects($this->once()) + ->method('openFile') + ->will($this->returnValue($streamMock)); + $this->dirMock->expects($this->never()) + ->method('delete') + ->will($this->returnValue($streamMock)); + $streamMock->expects($this->at(1)) + ->method('eof') + ->will($this->returnValue(false)); + $streamMock->expects($this->at(2)) + ->method('eof') + ->will($this->returnValue(true)); + $streamMock->expects($this->once()) + ->method('read'); + $streamMock->expects($this->once()) + ->method('close'); + $this->getModelMock()->create('fileName', $content); + } + + public function testCreateArrayContentRm() + { + $file = 'some_file'; + $content = ['type' => 'filename', 'value' => $file, 'rm' => 1]; + + $this->dirMock->expects($this->once()) + ->method('isFile') + ->will($this->returnValue(true)); + $this->dirMock->expects($this->once()) + ->method('stat') + ->will($this->returnValue(['size' => 100])); + $this->responseMock->expects($this->exactly(6)) + ->method('setHeader') + ->will($this->returnSelf()); + $this->responseMock->expects($this->once()) + ->method('setHttpResponseCode') + ->with(200) + ->will($this->returnSelf()); + $this->responseMock->expects($this->once()) + ->method('sendHeaders') + ->will($this->returnSelf()); + + $streamMock = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + ->disableOriginalConstructor()->getMock(); + $this->dirMock->expects($this->once()) + ->method('openFile') + ->will($this->returnValue($streamMock)); + $this->dirMock->expects($this->once()) + ->method('delete') + ->will($this->returnValue($streamMock)); + $streamMock->expects($this->at(1)) + ->method('eof') + ->will($this->returnValue(false)); + $streamMock->expects($this->at(2)) + ->method('eof') + ->will($this->returnValue(true)); + $streamMock->expects($this->once()) + ->method('read'); + $streamMock->expects($this->once()) + ->method('close'); + $this->getModelMock()->create('fileName', $content); + } + + public function testCreateStringContent() + { + $this->dirMock->expects($this->never()) + ->method('isFile') + ->will($this->returnValue(true)); + $this->dirMock->expects($this->never()) + ->method('stat') + ->will($this->returnValue(['size' => 100])); + $this->responseMock->expects($this->exactly(6)) + ->method('setHeader') + ->will($this->returnSelf()); + $this->responseMock->expects($this->once()) + ->method('setHttpResponseCode') + ->with(200) + ->will($this->returnSelf()); + $this->responseMock->expects($this->once()) + ->method('clearBody') + ->will($this->returnSelf()); + $this->responseMock->expects($this->once()) + ->method('setBody') + ->will($this->returnSelf()); + $this->responseMock->expects($this->never()) + ->method('sendHeaders') + ->will($this->returnSelf()); + + $streamMock = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + ->disableOriginalConstructor()->getMock(); + $this->dirMock->expects($this->never()) + ->method('openFile') + ->will($this->returnValue($streamMock)); + $this->dirMock->expects($this->never()) + ->method('delete') + ->will($this->returnValue($streamMock)); + $streamMock->expects($this->never()) + ->method('eof') + ->will($this->returnValue(false)); + $streamMock->expects($this->never()) + ->method('read'); + $streamMock->expects($this->never()) + ->method('close'); + $this->assertSame($this->responseMock, $this->getModel()->create('fileName', 'content')); + } + + /** + * Get model + * + * @return \Magento\Framework\App\Response\Http\FileFactory + */ + private function getModel() + { + return $this->objectManager->getObject( + 'Magento\Framework\App\Response\Http\FileFactory', + [ + 'response' => $this->responseMock, + 'filesystem' => $this->fileSystemMock, + ] + ); + } + + /** + * Get model mock + * + * @return \Magento\Framework\App\Response\Http\FileFactory | \PHPUnit_Framework_MockObject_MockBuilder + */ + private function getModelMock() + { + $modelMock = $this->getMock( + 'Magento\Framework\App\Response\Http\FileFactory', + ['callExit'], + [ + 'response' => $this->responseMock, + 'filesystem' => $this->fileSystemMock, + ] + ); + return $modelMock; } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Router/ActionList/ReaderTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Router/ActionList/ReaderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..917ddc23414d14b955e458df63f651d1adff087f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Router/ActionList/ReaderTest.php @@ -0,0 +1,69 @@ +<?php +/** + * RouterList model test class + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Router\ActionList; + +class ReaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Framework\Module\Dir\Reader| \PHPUnit_Framework_MockObject_MockObject + */ + protected $moduleReaderMock; + + /** + * @var \Magento\Framework\App\Router\ActionList\Reader + */ + protected $actionListReader; + + public function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->moduleReaderMock = $this->getMockBuilder('Magento\Framework\Module\Dir\Reader') + ->disableOriginalConstructor() + ->getMock(); + $this->actionListReader = $this->objectManager->getObject( + 'Magento\Framework\App\Router\ActionList\Reader', + ['moduleReader' => $this->moduleReaderMock] + ); + } + + /** + * @param array $actionFiles + * @param array $expected + * @dataProvider readDataProvider + */ + public function testRead($actionFiles, $expected) + { + $this->moduleReaderMock->expects($this->once()) + ->method('getActionFiles') + ->willReturn($actionFiles); + $this->assertEquals($expected, $this->actionListReader->read()); + } + + public function readDataProvider() + { + return [ + [[], []], + [ + [ + 'Magento/Backend/Controller/Adminhtml/Cache.php', + 'Magento/Backend/Controller/Adminhtml/Index.php' + ], + [ + 'magento\backend\controller\adminhtml\cache' => 'Magento\Backend\Controller\Adminhtml\Cache', + 'magento\backend\controller\adminhtml\index' => 'Magento\Backend\Controller\Adminhtml\Index' + + ] + ] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Router/ActionListTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Router/ActionListTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c31e5e2ac680a08d8fd3130d30536516326d5d22 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Router/ActionListTest.php @@ -0,0 +1,163 @@ +<?php +/** + * RouterList model test class + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Router; + +class ActionListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Framework\Config\CacheInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $cacheMock; + + /** + * @var \Magento\Framework\App\Router\ActionList\Reader | \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionReaderMock; + + /** + * @var \Magento\Framework\App\Router\ActionList + */ + protected $actionList; + + public function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->cacheMock = $this->getMockBuilder('Magento\Framework\Config\CacheInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->actionReaderMock = $this->getMockBuilder('Magento\Framework\App\Router\ActionList\Reader') + ->disableOriginalConstructor() + ->getMock(); + } + + public function testConstructorCachedData() + { + $this->cacheMock->expects($this->once()) + ->method('load') + ->will($this->returnValue(serialize('data'))); + $this->cacheMock->expects($this->never()) + ->method('save'); + $this->actionReaderMock->expects($this->never()) + ->method('read'); + $this->actionList = $this->objectManager->getObject( + 'Magento\Framework\App\Router\ActionList', + [ + 'cache' => $this->cacheMock, + 'actionReader' => $this->actionReaderMock, + ] + ); + } + + public function testConstructorNoCachedData() + { + $this->cacheMock->expects($this->once()) + ->method('load') + ->will($this->returnValue(false)); + $this->cacheMock->expects($this->once()) + ->method('save'); + $this->actionReaderMock->expects($this->once()) + ->method('read') + ->will($this->returnValue('data')); + $this->actionList = $this->objectManager->getObject( + 'Magento\Framework\App\Router\ActionList', + [ + 'cache' => $this->cacheMock, + 'actionReader' => $this->actionReaderMock, + ] + ); + } + + /** + * @param string $module + * @param string $area + * @param string $namespace + * @param string $action + * @param array $data + * @param string|null $expected + * @dataProvider getDataProvider + */ + public function testGet($module, $area, $namespace, $action, $data, $expected) + { + + $this->cacheMock->expects($this->once()) + ->method('load') + ->will($this->returnValue(false)); + $this->cacheMock->expects($this->once()) + ->method('save'); + $this->actionReaderMock->expects($this->once()) + ->method('read') + ->will($this->returnValue($data)); + $this->actionList = $this->objectManager->getObject( + 'Magento\Framework\App\Router\ActionList', + [ + 'cache' => $this->cacheMock, + 'actionReader' => $this->actionReaderMock, + ] + ); + $this->assertEquals($expected, $this->actionList->get($module, $area, $namespace, $action)); + } + + public function getDataProvider() + { + $mockClassName = 'Mock_Action_Class'; + $actionClass = $this->getMockClass( + 'Magento\Framework\App\ActionInterface', + ['dispatch', 'getResponse'], + [], + $mockClassName + ); + + return [ + [ + 'Magento_Module', + 'Area', + 'Namespace', + 'Index', + ['magento\module\controller\area\namespace\index' => $mockClassName], + $actionClass + ], + [ + 'Magento_Module', + '', + 'Namespace', + 'Index', + ['magento\module\controller\namespace\index' => $mockClassName], + $actionClass + ], + [ + 'Magento_Module', + 'Area', + 'Namespace', + 'Catch', + ['magento\module\controller\area\namespace\catchaction' => $mockClassName], + $actionClass + ], + [ + 'Magento_Module', + 'Area', + 'Namespace', + 'Index', + ['magento\module\controller\area\namespace\index' => 'Not_Exist_Class'], + null + ], + [ + 'Magento_Module', + 'Area', + 'Namespace', + 'Index', + [], + null + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleFactory.txt b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleFactory.txt index dc00737ddd353447c1768de2ce333462dfcb4fb9..26a55f7af986fbccd10212a7101d0df406cd8584 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleFactory.txt +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleFactory.txt @@ -1,7 +1,7 @@ namespace \Magento\Framework\ObjectManager\Code\Generator; /** - * Factory class for \Magento\Framework\ObjectManager\Code\Generator\Sample + * Factory class for @see \Magento\Framework\ObjectManager\Code\Generator\Sample */ class SampleFactory { diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleProxy.txt b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleProxy.txt index 927e954a58f3577095af675ba3fac581d52e9d0e..525394b0c8e18fe3e6635b19cd10fa6d727c2797 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleProxy.txt +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleProxy.txt @@ -1,7 +1,7 @@ namespace \Magento\Framework\ObjectManager\Code\Generator; /** - * Proxy class for \Magento\Framework\ObjectManager\Code\Generator\Sample + * Proxy class for @see \Magento\Framework\ObjectManager\Code\Generator\Sample */ class Sample_Proxy extends \Magento\Framework\ObjectManager\Code\Generator\Sample { diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Model/CartRepositoryTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Model/CartRepositoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c2712492bba77c1d6250553f368de9b7c4d43a3d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GiftMessage/Model/CartRepositoryTest.php @@ -0,0 +1,184 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\GiftMessage\Model; + +class CartRepositoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CartRepository + */ + protected $cartRepository; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteRepositoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteItemMock; + + /** + * @var string + */ + protected $cartId = 13; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $giftMessageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected function setUp() + { + $this->quoteRepositoryMock = $this->getMock('Magento\Quote\Model\QuoteRepository', [], [], '', false); + $this->messageFactoryMock = $this->getMock( + 'Magento\GiftMessage\Model\MessageFactory', + [ + 'create', + '__wakeup' + ], + [], + '', + false + ); + $this->messageMock = $this->getMock('Magento\GiftMessage\Model\Message', [], [], '', false); + $this->quoteItemMock = $this->getMock( + '\Magento\Quote\Model\Quote\Item', + [ + 'getGiftMessageId', + '__wakeup' + ], + [], + '', + false + ); + $this->quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + [ + 'getGiftMessageId', + 'getItemById', + 'getItemsCount', + 'isVirtual', + '__wakeup', + ], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->giftMessageManagerMock = + $this->getMock('Magento\GiftMessage\Model\GiftMessageManager', [], [], '', false); + $this->helperMock = $this->getMock('Magento\GiftMessage\Helper\Message', [], [], '', false); + $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->cartRepository = new CartRepository( + $this->quoteRepositoryMock, + $this->storeManagerMock, + $this->giftMessageManagerMock, + $this->helperMock, + $this->messageFactoryMock + ); + + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($this->cartId) + ->will($this->returnValue($this->quoteMock)); + } + + public function testGetWithOutMessageId() + { + $messageId = 0; + + $this->quoteMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue($messageId)); + + $this->assertNull($this->cartRepository->get($this->cartId)); + } + + public function testGet() + { + $messageId = 156; + + $this->quoteMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue($messageId)); + $this->messageFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->messageMock)); + $this->messageMock->expects($this->once())->method('load')->will($this->returnValue($this->messageMock)); + + $this->assertEquals($this->messageMock, $this->cartRepository->get($this->cartId)); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Gift Messages is not applicable for empty cart + */ + public function testSaveWithInputException() + { + $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(0)); + + $this->cartRepository->save($this->cartId, $this->messageMock); + } + + /** + * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException + * @expectedExceptionMessage Gift Messages is not applicable for virtual products + */ + public function testSaveWithInvalidTransitionException() + { + $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); + $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(true)); + + $this->cartRepository->save($this->cartId, $this->messageMock); + } + + public function testSave() + { + $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); + $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->helperMock->expects($this->once()) + ->method('getIsMessagesAvailable') + ->with('quote', $this->quoteMock, $this->storeMock) + ->will($this->returnValue(true)); + $this->giftMessageManagerMock->expects($this->once()) + ->method('setMessage') + ->with($this->quoteMock, 'quote', $this->messageMock) + ->will($this->returnValue($this->giftMessageManagerMock)); + + $this->assertTrue($this->cartRepository->save($this->cartId, $this->messageMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Model/GiftMessageManagerTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Model/GiftMessageManagerTest.php index 0ad00b485f0fc293423874b01525299c875d446b..b264a94ede81ca169897ab91cd1e6352efcf965b 100644 --- a/dev/tests/unit/testsuite/Magento/GiftMessage/Model/GiftMessageManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/GiftMessage/Model/GiftMessageManagerTest.php @@ -46,6 +46,16 @@ class GiftMessageManagerTest extends \PHPUnit_Framework_TestCase */ protected $giftMessageMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $billingAddressMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $shippingAddressMock; + protected function setUp() { $this->messageFactoryMock = @@ -58,6 +68,8 @@ class GiftMessageManagerTest extends \PHPUnit_Framework_TestCase 'save', 'getItemById', 'getAddressById', + 'getBillingAddress', + 'getShippingAddress', '__wakeup'], [], '', @@ -102,6 +114,9 @@ class GiftMessageManagerTest extends \PHPUnit_Framework_TestCase 'setSender', 'setRecipient', 'setMessage', + 'getSender', + 'getRecipient', + 'getMessage', 'getId', 'delete', 'save', @@ -111,6 +126,10 @@ class GiftMessageManagerTest extends \PHPUnit_Framework_TestCase '', false); + $this->billingAddressMock = + $this->getMock('\Magento\Sales\Model\Quote\Address', ['getCountryId', '__wakeup'], [], '', false); + $this->shippingAddressMock = + $this->getMock('\Magento\Sales\Model\Quote\Address', ['getCountryId', '__wakeup'], [], '', false); $this->model = new GiftMessageManager($this->messageFactoryMock); } @@ -289,4 +308,62 @@ class GiftMessageManagerTest extends \PHPUnit_Framework_TestCase $this->model->add($giftMessages, $this->quoteMock); } + + /** + * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException + * @expectedExceptionMessage Billing address is not set + */ + public function testSetMessageEmptyBillingAddressException() + { + $this->quoteMock->expects($this->once()) + ->method('getBillingAddress') + ->will($this->returnValue($this->billingAddressMock)); + $this->billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); + + $this->model->setMessage($this->quoteMock, 'item', $this->giftMessageMock); + } + + /** + * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException + * @expectedExceptionMessage Shipping address is not set + */ + public function testSetMessageEmptyShippingAddressException() + { + $this->quoteMock->expects($this->once()) + ->method('getBillingAddress') + ->will($this->returnValue($this->billingAddressMock)); + $this->billingAddressMock->expects($this->any())->method('getCountryId')->will($this->returnValue(12)); + $this->quoteMock->expects($this->once()) + ->method('getShippingAddress') + ->will($this->returnValue($this->shippingAddressMock)); + $this->shippingAddressMock->expects($this->any())->method('getCountryId')->will($this->returnValue(null)); + + $this->model->setMessage($this->quoteMock, 'item', $this->giftMessageMock); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + * @expectedExceptionMessage Could not add gift message to shopping cart + */ + public function testSetMessageCouldNotAddGiftMessageException() + { + $this->quoteMock->expects($this->once()) + ->method('getBillingAddress') + ->will($this->returnValue($this->billingAddressMock)); + $this->billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(12)); + $this->quoteMock->expects($this->once()) + ->method('getShippingAddress') + ->will($this->returnValue($this->shippingAddressMock)); + $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(13)); + $this->giftMessageMock->expects($this->once())->method('getSender')->will($this->returnValue('sender')); + $this->giftMessageMock->expects($this->once())->method('getRecipient')->will($this->returnValue('recipient')); + $this->giftMessageMock->expects($this->once())->method('getMessage')->will($this->returnValue('Message')); + + $this->messageFactoryMock->expects($this->once()) + ->method('create') + ->willThrowException(new \Exception()); + + $this->model->setMessage($this->quoteMock, 'item', $this->giftMessageMock); + } + } diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Model/ItemRepositoryTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Model/ItemRepositoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..18fb89322ce346894f8746baa0650c205634bb02 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GiftMessage/Model/ItemRepositoryTest.php @@ -0,0 +1,223 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\GiftMessage\Model; + + +class ItemRepositoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ItemRepository + */ + protected $itemRepository; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteRepositoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteItemMock; + + /** + * @var string + */ + protected $cartId = 13; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $giftMessageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected function setUp() + { + $this->quoteRepositoryMock = $this->getMock('Magento\Quote\Model\QuoteRepository', [], [], '', false); + $this->messageFactoryMock = $this->getMock( + 'Magento\GiftMessage\Model\MessageFactory', + [ + 'create', + '__wakeup' + ], + [], + '', + false + ); + $this->messageMock = $this->getMock('Magento\GiftMessage\Model\Message', [], [], '', false); + $this->quoteItemMock = $this->getMock( + '\Magento\Qote\Model\Quote\Item', + [ + 'getGiftMessageId', + '__wakeup' + ], + [], + '', + false + ); + $this->quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + [ + 'getGiftMessageId', + 'getItemById', + '__wakeup', + ], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->giftMessageManagerMock = + $this->getMock('Magento\GiftMessage\Model\GiftMessageManager', [], [], '', false); + $this->helperMock = $this->getMock('Magento\GiftMessage\Helper\Message', [], [], '', false); + $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->itemRepository = new ItemRepository( + $this->quoteRepositoryMock, + $this->storeManagerMock, + $this->giftMessageManagerMock, + $this->helperMock, + $this->messageFactoryMock + ); + + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($this->cartId) + ->will($this->returnValue($this->quoteMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage There is no item with provided id in the cart + */ + public function testGetWithNoSuchEntityException() + { + $itemId = 2; + + $this->quoteMock->expects($this->once())->method('getItemById')->with($itemId)->will($this->returnValue(null)); + + $this->itemRepository->get($this->cartId, $itemId); + } + + public function testGetWithoutMessageId() + { + $messageId = 0; + $itemId = 2; + + $this->quoteMock->expects($this->once()) + ->method('getItemById') + ->with($itemId) + ->will($this->returnValue($this->quoteItemMock)); + $this->quoteItemMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue($messageId)); + + $this->assertNull($this->itemRepository->get($this->cartId, $itemId)); + } + + public function testGet() + { + $messageId = 123; + $itemId = 2; + + $this->quoteMock->expects($this->once()) + ->method('getItemById') + ->with($itemId) + ->will($this->returnValue($this->quoteItemMock)); + $this->quoteItemMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue($messageId)); + $this->messageFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->messageMock)); + $this->messageMock->expects($this->once()) + ->method('load') + ->with($messageId) + ->will($this->returnValue($this->messageMock)); + + $this->assertEquals($this->messageMock, $this->itemRepository->get($this->cartId, $itemId)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage There is no product with provided itemId: 1 in the cart + */ + public function testSaveWithNoSuchEntityException() + { + $itemId = 1; + + $this->quoteMock->expects($this->once())->method('getItemById')->with($itemId)->will($this->returnValue(null)); + + $this->itemRepository->save($this->cartId, $this->messageMock, $itemId); + } + + /** + * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException + * @expectedExceptionMessage Gift Messages is not applicable for virtual products + */ + public function testSaveWithInvalidTransitionException() + { + $itemId = 1; + + $quoteItem = $this->getMock('\Magento\Sales\Model\Quote\Item', ['getIsVirtual', '__wakeup'], [], '', false); + $this->quoteMock->expects($this->once()) + ->method('getItemById') + ->with($itemId) + ->will($this->returnValue($quoteItem)); + $quoteItem->expects($this->once())->method('getIsVirtual')->will($this->returnValue(1)); + + $this->itemRepository->save($this->cartId, $this->messageMock, $itemId); + } + + public function testSave() + { + $itemId = 1; + + $quoteItem = $this->getMock('\Magento\Sales\Model\Quote\Item', ['getIsVirtual', '__wakeup'], [], '', false); + $this->quoteMock->expects($this->once()) + ->method('getItemById') + ->with($itemId) + ->will($this->returnValue($quoteItem)); + $quoteItem->expects($this->once())->method('getIsVirtual')->will($this->returnValue(0)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->helperMock->expects($this->once()) + ->method('getIsMessagesAvailable') + ->with('items', $this->quoteMock, $this->storeMock) + ->will($this->returnValue(true)); + $this->giftMessageManagerMock->expects($this->once()) + ->method('setMessage') + ->with($this->quoteMock, 'quote_item', $this->messageMock, $itemId) + ->will($this->returnValue($this->giftMessageManagerMock)); + + $this->assertTrue($this->itemRepository->save($this->cartId, $this->messageMock, $itemId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php deleted file mode 100644 index 5a2d3f90ea095d3e4660d388e0bea277f9879605..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php +++ /dev/null @@ -1,188 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\GiftMessage\Service\V1; - -class ReadServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ReadService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $messageFactoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $messageMapperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $messageMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteItemMock; - - /** - * @var string - */ - protected $cardId; - - protected function setUp() - { - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->cardId = 13; - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->messageFactoryMock = $this->getMock( - '\Magento\GiftMessage\Model\MessageFactory', - [ - 'create', - '__wakeup' - ], - [], - '', - false); - $this->messageMapperMock = $this->getMock( - '\Magento\GiftMessage\Service\V1\Data\MessageMapper', - [ - 'extractDto', - '__wakeup' - ], - [], - '', - false); - $this->messageMock = $this->getMock('\Magento\GiftMessage\Model\Message', [], [], '', false); - $this->quoteItemMock = $this->getMock( - '\Magento\Quote\Model\Quote\Item', - [ - 'getGiftMessageId', - '__wakeup' - ], - [], - '', - false); - $this->quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', - [ - 'getGiftMessageId', - 'getItemById', - '__wakeup', - ], - [], - '', - false); - - $this->service = $objectManager->getObject( - 'Magento\GiftMessage\Service\V1\ReadService', - [ - 'quoteRepository' => $this->quoteRepositoryMock, - 'messageFactory' => $this->messageFactoryMock, - 'messageMapper' => $this->messageMapperMock, - ] - ); - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($this->cardId) - ->will($this->returnValue($this->quoteMock)); - } - - public function testGetWithOutMessageId() - { - $messageId = 0; - - $this->quoteMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue($messageId)); - - $this->assertNull($this->service->get($this->cardId)); - } - - public function testGet() - { - $messageId = 156; - - $this->quoteMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue($messageId)); - $this->messageFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($this->messageMock)); - $this->messageMock->expects($this->once())->method('load')->will($this->returnValue($this->messageMock)); - $this->messageMapperMock->expects($this->once()) - ->method('extractDto')->with($this->messageMock)->will($this->returnValue(['Expected value'])); - - $this->assertEquals(['Expected value'], $this->service->get($this->cardId)); - } - - /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage There is no item with provided id in the cart - */ - public function testGetItemMessageWithNoSuchEntityException() - { - $itemId = 2; - - $this->quoteMock->expects($this->once())->method('getItemById')->with($itemId)->will($this->returnValue(null)); - - $this->service->getItemMessage($this->cardId, $itemId); - } - - public function testGetItemMessageWithoutMessageId() - { - $messageId = 0; - $itemId = 2; - - $this->quoteMock->expects($this->once()) - ->method('getItemById') - ->with($itemId) - ->will($this->returnValue($this->quoteItemMock)); - $this->quoteItemMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue($messageId)); - - $this->assertNull($this->service->getItemMessage($this->cardId, $itemId)); - } - - public function testGetItemMessage() - { - $messageId = 123; - $itemId = 2; - - $this->quoteMock->expects($this->once()) - ->method('getItemById') - ->with($itemId) - ->will($this->returnValue($this->quoteItemMock)); - $this->quoteItemMock->expects($this->once())->method('getGiftMessageId')->will($this->returnValue($messageId)); - $this->messageFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($this->messageMock)); - $this->messageMock->expects($this->once()) - ->method('load') - ->with($messageId) - ->will($this->returnValue($this->messageMock)); - $this->messageMapperMock->expects($this->once()) - ->method('extractDto') - ->with($this->messageMock) - ->will($this->returnValue(['Expected value'])); - - $this->assertEquals(['Expected value'], $this->service->getItemMessage($this->cardId, $itemId)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php deleted file mode 100644 index 08a34847fdde6c3f4519bfafdf9574d4a14e151d..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php +++ /dev/null @@ -1,388 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\GiftMessage\Service\V1; - -class WriteServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var WriteService - */ - protected $service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteRepositoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $giftMessageManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $helperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $giftMessageMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $billingAddressMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $shippingAddressMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeMock; - - protected function setUp() - { - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->giftMessageManagerMock = - $this->getMock('\Magento\GiftMessage\Model\GiftMessageManager', [], [], '', false); - $this->helperMock = $this->getMock('\Magento\GiftMessage\Helper\Message', [], [], '', false); - $this->giftMessageMock = $this->getMock('\Magento\GiftMessage\Service\V1\Data\Message', [], [], '', false); - $this->quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', - [ - 'getItemsCount', - 'isVirtual', - 'getBillingAddress', - 'getShippingAddress', - 'getItemById', - '__wakeup' - ], - [], - '', - false - ); - $this->billingAddressMock = - $this->getMock('\Magento\Quote\Model\Quote\Address', ['getCountryId', '__wakeup'], [], '', false); - $this->shippingAddressMock = - $this->getMock('\Magento\Quote\Model\Quote\Address', ['getCountryId', '__wakeup'], [], '', false); - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - - $this->service = $objectManager->getObject( - 'Magento\GiftMessage\Service\V1\WriteService', - [ - 'quoteRepository' => $this->quoteRepositoryMock, - 'storeManager' => $this->storeManagerMock, - 'giftMessageManager' => $this->giftMessageManagerMock, - 'helper' => $this->helperMock - ] - ); - } - - /** - * @expectedException \Magento\Framework\Exception\InputException - * @expectedExceptionMessage Gift Messages is not applicable for empty cart - */ - public function testSetForQuoteWithInputException() - { - $cartId = 665; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(0)); - - $this->service->setForQuote($cartId, $this->giftMessageMock); - } - - /** - * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException - * @expectedExceptionMessage Gift Messages is not applicable for virtual products - */ - public function testSetForQuoteWithInvalidTransitionException() - { - $cartId = 665; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); - $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(true)); - - $this->service->setForQuote($cartId, $this->giftMessageMock); - } - - public function testSetForQuote() - { - $cartId = 665; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); - $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('getBillingAddress') - ->will($this->returnValue($this->billingAddressMock)); - $this->billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(12)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress') - ->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(13)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->helperMock->expects($this->once()) - ->method('getIsMessagesAvailable') - ->with('', $this->quoteMock, $this->storeMock) - ->will($this->returnValue(true)); - $this->giftMessageMock->expects($this->once())->method('getSender')->will($this->returnValue('sender')); - $this->giftMessageMock->expects($this->once())->method('getRecipient')->will($this->returnValue('recipient')); - $this->giftMessageMock->expects($this->once())->method('getMessage')->will($this->returnValue('Message')); - $message['quote'][null] = - [ - 'from' => 'sender', - 'to' => 'recipient', - 'message' => 'Message', - ]; - $this->giftMessageManagerMock->expects($this->once()) - ->method('add') - ->with($message, $this->quoteMock) - ->will($this->returnValue($this->giftMessageManagerMock)); - - $this->assertTrue($this->service->setForQuote($cartId, $this->giftMessageMock)); - } - - /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage There is no product with provided itemId: 1 in the cart - */ - public function testSetForItemWithNoSuchEntityException() - { - $cartId = 665; - $itemId = 1; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getItemById')->with($itemId)->will($this->returnValue(null)); - - $this->service->setForItem($cartId, $this->giftMessageMock, $itemId); - } - - /** - * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException - * @expectedExceptionMessage Gift Messages is not applicable for virtual products - */ - public function testSetForItemWithInvalidTransitionException() - { - $cartId = 665; - $itemId = 1; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $quoteItem = $this->getMock('\Magento\Quote\Model\Quote\Item', ['getIsVirtual', '__wakeup'], [], '', false); - $this->quoteMock->expects($this->once()) - ->method('getItemById') - ->with($itemId) - ->will($this->returnValue($quoteItem)); - $quoteItem->expects($this->once())->method('getIsVirtual')->will($this->returnValue(1)); - - $this->service->setForItem($cartId, $this->giftMessageMock, $itemId); - } - - public function testSetForItem() - { - $cartId = 665; - $itemId = 1; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $quoteItem = $this->getMock('\Magento\Quote\Model\Quote\Item', ['getIsVirtual', '__wakeup'], [], '', false); - $this->quoteMock->expects($this->once()) - ->method('getItemById') - ->with($itemId) - ->will($this->returnValue($quoteItem)); - $quoteItem->expects($this->once())->method('getIsVirtual')->will($this->returnValue(0)); - $this->quoteMock->expects($this->once()) - ->method('getBillingAddress') - ->will($this->returnValue($this->billingAddressMock)); - $this->billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(12)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress') - ->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(13)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->helperMock->expects($this->once()) - ->method('getIsMessagesAvailable') - ->with('items', $this->quoteMock, $this->storeMock) - ->will($this->returnValue(true)); - $this->giftMessageMock->expects($this->once())->method('getSender')->will($this->returnValue('sender')); - $this->giftMessageMock->expects($this->once())->method('getRecipient')->will($this->returnValue('recipient')); - $this->giftMessageMock->expects($this->once())->method('getMessage')->will($this->returnValue('Message')); - $message['quote_item'][1] = - [ - 'from' => 'sender', - 'to' => 'recipient', - 'message' => 'Message', - ]; - $this->giftMessageManagerMock->expects($this->once()) - ->method('add') - ->with($message, $this->quoteMock) - ->will($this->returnValue($this->giftMessageManagerMock)); - - $this->assertTrue($this->service->setForItem($cartId, $this->giftMessageMock, $itemId)); - } - - /** - * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException - * @expectedExceptionMessage Billing address is not set - */ - public function testSetMessageEmptyBillingAddressException() - { - $cartId = 665; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); - $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('getBillingAddress') - ->will($this->returnValue($this->billingAddressMock)); - $this->billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); - - $this->service->setForQuote($cartId, $this->giftMessageMock); - } - - /** - * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException - * @expectedExceptionMessage Shipping address is not set - */ - public function testSetMessageEmptyShippingAddressException() - { - $cartId = 665; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); - $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('getBillingAddress') - ->will($this->returnValue($this->billingAddressMock)); - $this->billingAddressMock->expects($this->any())->method('getCountryId')->will($this->returnValue(12)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress') - ->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->any())->method('getCountryId')->will($this->returnValue(null)); - - $this->service->setForQuote($cartId, $this->giftMessageMock); - } - - /** - * @expectedException \Magento\Framework\Exception\CouldNotSaveException - * @expectedExceptionMessage Gift Message is not available - */ - public function testSetMessageGiftMessageIsNotAvailableException() - { - $cartId = 665; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); - $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('getBillingAddress') - ->will($this->returnValue($this->billingAddressMock)); - $this->billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(12)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress') - ->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(13)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->helperMock->expects($this->once()) - ->method('getIsMessagesAvailable') - ->with('', $this->quoteMock, $this->storeMock) - ->will($this->returnValue(false)); - - $this->service->setForQuote($cartId, $this->giftMessageMock); - } - - /** - * @expectedException \Magento\Framework\Exception\CouldNotSaveException - * @expectedExceptionMessage Could not add gift message to shopping cart - */ - public function testSetMessageCouldNotAddGiftMessageException() - { - $cartId = 665; - - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); - $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); - $this->quoteMock->expects($this->once()) - ->method('getBillingAddress') - ->will($this->returnValue($this->billingAddressMock)); - $this->billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(12)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress') - ->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(13)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->helperMock->expects($this->once()) - ->method('getIsMessagesAvailable') - ->with('', $this->quoteMock, $this->storeMock) - ->will($this->returnValue(true)); - $this->giftMessageMock->expects($this->once())->method('getSender')->will($this->returnValue('sender')); - $this->giftMessageMock->expects($this->once())->method('getRecipient')->will($this->returnValue('recipient')); - $this->giftMessageMock->expects($this->once())->method('getMessage')->will($this->returnValue('Message')); - $message['quote'][null] = - [ - 'from' => 'sender', - 'to' => 'recipient', - 'message' => 'Message', - ]; - $exception = - new \Magento\Framework\Exception\CouldNotSaveException('Could not add gift message to shopping cart'); - $this->giftMessageManagerMock->expects($this->once()) - ->method('add') - ->with($message, $this->quoteMock) - ->will($this->throwException($exception)); - - $this->service->setForQuote($cartId, $this->giftMessageMock); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php index f3d5527baad36d2fe1f2056f5427123e1ec01e99..327b4721cada578857424f16efcf564bc73336f7 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php @@ -18,17 +18,25 @@ class FreeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); $paymentData = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); - $logger = $this->getMock('Psr\Log\LoggerInterface'); $this->currencyPrice = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $context = $this->getMock('\Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); + $eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface'); + $context->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock); + + $registry = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $metadataService = $this->getMock('\Magento\Framework\Api\MetadataServiceInterface'); + $customAttributeBuilder = $this->getMock('\Magento\Framework\Api\AttributeDataBuilder', [], [], '', false); + $this->methodFree = new \Magento\Payment\Model\Method\Free( - $eventManager, + $context, + $registry, + $metadataService, + $customAttributeBuilder, $paymentData, $this->scopeConfig, - $logger, $this->currencyPrice ); } diff --git a/dev/tests/unit/testsuite/Magento/Quote/Model/BillingAddressManagementTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/BillingAddressManagementTest.php new file mode 100644 index 0000000000000000000000000000000000000000..309cd33a4a344163587d458a234656941ea3f808 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/BillingAddressManagementTest.php @@ -0,0 +1,121 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Quote\Model; + +class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var BillingAddressManagement + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteRepositoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + protected function setUp() + { + $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); + $this->validatorMock = $this->getMock('\Magento\Quote\Model\QuoteAddressValidator', [], [], '', false); + $logger = $this->getMock('\Psr\Log\LoggerInterface'); + $this->model = new BillingAddressManagement($this->quoteRepositoryMock, $this->validatorMock, $logger); + } + + public function testGetAddress() + { + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once())->method('getActive') + ->with('cartId')->will($this->returnValue($quoteMock)); + + $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock)); + + $this->assertEquals($addressMock, $this->model->get('cartId')); + } + + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage error123 + */ + public function testSetAddressValidationFailed() + { + $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with('cartId') + ->will($this->returnValue($quoteMock)); + + $this->validatorMock->expects($this->once())->method('validate') + ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error123'))); + + $this->model->assign('cartId', $address); + } + + public function testSetAddress() + { + $address = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with('cartId') + ->will($this->returnValue($quoteMock)); + + $this->validatorMock->expects($this->once())->method('validate') + ->with($address) + ->will($this->returnValue(true)); + + $quoteMock->expects($this->once())->method('setBillingAddress')->with($address); + $quoteMock->expects($this->once())->method('setDataChanges')->with(true); + $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); + $addressId = 1; + $billingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $billingAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); + $quoteMock->expects($this->once())->method('getBillingAddress') + ->will($this->returnValue($billingAddressMock)); + + $this->assertEquals($addressId, $this->model->assign('cartId', $address)); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Unable to save address. Please, check input data. + */ + public function testSetAddressWithInabilityToSaveQuote() + { + $address = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with('cartId') + ->will($this->returnValue($quoteMock)); + + $this->validatorMock->expects($this->once())->method('validate') + ->with($address) + ->will($this->returnValue(true)); + + $quoteMock->expects($this->once())->method('setBillingAddress')->with($address); + $quoteMock->expects($this->once())->method('setDataChanges')->with(true); + $this->quoteRepositoryMock->expects($this->once()) + ->method('save') + ->with($quoteMock) + ->willThrowException( + new \Exception('Some DB Error') + ); + $this->model->assign('cartId', $address); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/WritePluginTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/Access/CartManagementPluginTest.php similarity index 81% rename from dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/WritePluginTest.php rename to dev/tests/unit/testsuite/Magento/Quote/Model/Cart/Access/CartManagementPluginTest.php index 903cd6e15d433c6ca7f8507a9799a8f8d1ae1adc..bad7fdd3829213d01361017b1ab7a6b7e079ffcf 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/WritePluginTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/Access/CartManagementPluginTest.php @@ -4,12 +4,12 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Model\Cart\Access; +namespace Magento\Quote\Model\Cart\Access; -class WritePluginTest extends \PHPUnit_Framework_TestCase +class CartManagementPluginTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Checkout\Model\Cart\Access\WritePlugin + * @var \Magento\Quote\Model\Cart\Access\CartManagementPlugin */ protected $model; @@ -26,8 +26,8 @@ class WritePluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->userContextMock = $this->getMock('Magento\Authorization\Model\UserContextInterface'); - $this->subjectMock = $this->getMock('\Magento\Checkout\Service\V1\Cart\WriteServiceInterface'); - $this->model = new WritePlugin($this->userContextMock); + $this->subjectMock = $this->getMock('\Magento\Quote\Api\CartManagementInterface'); + $this->model = new CartManagementPlugin($this->userContextMock); } /** @@ -37,7 +37,7 @@ class WritePluginTest extends \PHPUnit_Framework_TestCase public function testBeforeCreateSuccess($userType) { $this->userContextMock->expects($this->once())->method('getUserType')->will($this->returnValue($userType)); - $this->model->beforeAssignCustomer($this->subjectMock, 1, 1); + $this->model->beforeAssignCustomer($this->subjectMock, 1, 1, 1); } public function successTypeDataProvider() @@ -56,6 +56,6 @@ class WritePluginTest extends \PHPUnit_Framework_TestCase { $this->userContextMock->expects($this->once())->method('getUserType') ->will($this->returnValue(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER)); - $this->model->beforeAssignCustomer($this->subjectMock, 1, 1); + $this->model->beforeAssignCustomer($this->subjectMock, 1, 1, 1); } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/ReadPluginTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/Access/CartRepositoryPluginTest.php similarity index 77% rename from dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/ReadPluginTest.php rename to dev/tests/unit/testsuite/Magento/Quote/Model/Cart/Access/CartRepositoryPluginTest.php index 30f9984145a353181804cc71b4cee921dade10c2..1e171673ef5d05e8de3e855a455a78a99a6ad3ed 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/ReadPluginTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/Access/CartRepositoryPluginTest.php @@ -4,12 +4,12 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Model\Cart\Access; +namespace Magento\Quote\Model\Cart\Access; -class ReadPluginTest extends \PHPUnit_Framework_TestCase +class CartRepositoryPluginTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Checkout\Model\Cart\Access\ReadPlugin + * @var \Magento\Quote\Model\Cart\Access\CartRepositoryPlugin */ protected $model; @@ -26,18 +26,18 @@ class ReadPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->userContextMock = $this->getMock('Magento\Authorization\Model\UserContextInterface'); - $this->subjectMock = $this->getMock('\Magento\Checkout\Service\V1\Cart\ReadServiceInterface'); - $this->model = new ReadPlugin($this->userContextMock); + $this->subjectMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); + $this->model = new CartRepositoryPlugin($this->userContextMock); } /** * @param int $userType * @dataProvider successTypeDataProvider */ - public function testBeforeGetCartSuccess($userType) + public function testBeforeGetSuccess($userType) { $this->userContextMock->expects($this->once())->method('getUserType')->will($this->returnValue($userType)); - $this->model->beforeGetCart($this->subjectMock, 1); + $this->model->beforeGet($this->subjectMock, 1); } /** @@ -48,7 +48,7 @@ class ReadPluginTest extends \PHPUnit_Framework_TestCase { $this->userContextMock->expects($this->once())->method('getUserType') ->will($this->returnValue(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER)); - $this->model->beforeGetCart($this->subjectMock, 1); + $this->model->beforeGet($this->subjectMock, 1); } public function successTypeDataProvider() @@ -63,10 +63,10 @@ class ReadPluginTest extends \PHPUnit_Framework_TestCase * @param int $userType * @dataProvider successTypeDataProvider */ - public function testBeforeGetCartListSuccess($userType) + public function testBeforeGetCartSuccess($userType) { $this->userContextMock->expects($this->once())->method('getUserType')->will($this->returnValue($userType)); - $this->model->beforeGetCartList( + $this->model->beforeGetList( $this->subjectMock, $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false) ); @@ -76,11 +76,11 @@ class ReadPluginTest extends \PHPUnit_Framework_TestCase * @expectedException \Magento\Framework\Exception\AuthorizationException * @expectedExceptionMessage Access denied */ - public function testBeforeGetCartListDenied() + public function testBeforeGetListDenied() { $this->userContextMock->expects($this->once())->method('getUserType') ->will($this->returnValue(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER)); - $this->model->beforeGetCartList( + $this->model->beforeGetList( $this->subjectMock, $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false) ); diff --git a/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/CartTotalRepositoryTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/CartTotalRepositoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a7fb88418d9794a9c4bc13a15f10b8191070d436 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/CartTotalRepositoryTest.php @@ -0,0 +1,68 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model\Cart; + +class CartTotalRepositoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Quote\Model\Cart\CartTotalRepository + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $quoteRepositoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $totalsBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $addressMock; + + public function setUp() + { + $this->totalsBuilderMock = $this->getMock( + 'Magento\Quote\Api\Data\TotalsDataBuilder', + ['populateWithArray', 'setItems', 'create'], + [], + '', + false + ); + $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock = $this->getMock('Magento\Quote\Model\QuoteRepository', [], [], '', false); + $this->addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + + $this->model = new CartTotalRepository( + $this->totalsBuilderMock, + $this->quoteRepositoryMock + ); + } + + public function testGetTotals() + { + $cartId = 12; + $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId) + ->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($this->addressMock); + $this->addressMock->expects($this->once())->method('getData')->willReturn(['addressData']); + $this->quoteMock->expects($this->once())->method('getData')->willReturn(['quoteData']); + + $item = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); + $this->quoteMock->expects($this->once())->method('getAllItems')->will($this->returnValue([$item])); + $this->model->get($cartId); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/ShippingMethodConverterTest.php similarity index 92% rename from dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php rename to dev/tests/unit/testsuite/Magento/Quote/Model/Cart/ShippingMethodConverterTest.php index 129fecea0aa042da157ed2a745d3abef24b15a47..6bd008cd8e640a757c020c690f8ffca666feb4f5 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/Cart/ShippingMethodConverterTest.php @@ -7,7 +7,7 @@ // @codingStandardsIgnoreFile -namespace Magento\Checkout\Service\V1\Data\Cart; +namespace Magento\Quote\Model\Cart; class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase { @@ -50,7 +50,7 @@ class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->builderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', + '\Magento\Quote\Api\Data\ShippingMethodDataBuilder', ['populateWithArray', 'create'], [], '', @@ -59,7 +59,7 @@ class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); $this->currencyMock = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $this->shippingMethodMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethod', [], [], '', false); + $this->getMock('\Magento\Quote\Api\Data\ShippingMethodInterface'); $this->rateModelMock = $this->getMock('\Magento\Quote\Model\Quote\Address\Rate', [ 'getPrice', @@ -75,7 +75,7 @@ class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $this->converter = $objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter', + 'Magento\Quote\Model\Cart\ShippingMethodConverter', [ 'builder' => $this->builderMock, 'storeManager' => $this->storeManagerMock, diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/CouponManagementTest.php similarity index 84% rename from dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php rename to dev/tests/unit/testsuite/Magento/Quote/Model/CouponManagementTest.php index 005ae2f751719b25cee035e1aa72e12ef9e0825c..57435806a4f2514df20f4a1d389df128e247275f 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/CouponManagementTest.php @@ -7,14 +7,14 @@ // @codingStandardsIgnoreFile -namespace Magento\Checkout\Service\V1\Coupon; +namespace Magento\Quote\Model; -class WriteServiceTest extends \PHPUnit_Framework_TestCase +class CouponManagementTest extends \PHPUnit_Framework_TestCase { /** - * @var WriteService + * @var CouponManagement */ - protected $service; + protected $couponManagement; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -26,21 +26,11 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ protected $quoteMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $couponBuilderMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $storeMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $couponCodeDataMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -48,10 +38,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->couponBuilderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CouponBuilder', [], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $this->quoteMock = $this->getMock( '\Magento\Quote\Model\Quote', @@ -68,7 +55,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->couponCodeDataMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\Coupon', [], [], '', false); $this->quoteAddressMock = $this->getMock( '\Magento\Quote\Model\Quote\Address', [ @@ -78,15 +64,28 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase [], '', false); - $this->service = $objectManager->getObject( - 'Magento\Checkout\Service\V1\Coupon\WriteService', - [ - 'quoteRepository' => $this->quoteRepositoryMock, - 'couponBuilder' => $this->couponBuilderMock, - ] + $this->couponManagement = new CouponManagement( + $this->quoteRepositoryMock ); } + public function testGetCoupon() + { + $cartId = 11; + $couponCode = 'test_coupon_code'; + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', ['getCouponCode', '__wakeup'], [], '', false); + $quoteMock->expects($this->any())->method('getCouponCode')->will($this->returnValue($couponCode)); + + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->will($this->returnValue($quoteMock)); + + + $this->assertEquals($couponCode, $this->couponManagement->get($cartId)); + } + /** * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage Cart 33 doesn't contain products @@ -99,7 +98,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(0)); - $this->service->set($cartId, $this->couponCodeDataMock); + $this->couponManagement->set($cartId, 'coupon_code'); } /** @@ -117,8 +116,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); $this->quoteAddressMock->expects($this->once())->method('setCollectShippingRates')->with(true); - $this->couponCodeDataMock->expects($this->once()) - ->method('getCouponCode')->will($this->returnValue($couponCode)); $this->quoteMock->expects($this->once())->method('setCouponCode')->with($couponCode); $exceptionMessage = 'Could not apply coupon code'; $exception = new \Magento\Framework\Exception\CouldNotDeleteException($exceptionMessage); @@ -128,7 +125,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->with($this->quoteMock) ->willThrowException($exception); - $this->service->set($cartId, $this->couponCodeDataMock); + $this->couponManagement->set($cartId, $couponCode); } /** @@ -146,14 +143,12 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); $this->quoteAddressMock->expects($this->once())->method('setCollectShippingRates')->with(true); - $this->couponCodeDataMock->expects($this->once()) - ->method('getCouponCode')->will($this->returnValue($couponCode)); $this->quoteMock->expects($this->once())->method('setCouponCode')->with($couponCode); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); $this->quoteMock->expects($this->once())->method('getCouponCode')->will($this->returnValue('invalidCoupon')); - $this->service->set($cartId, $this->couponCodeDataMock); + $this->couponManagement->set($cartId, $couponCode); } public function testSet() @@ -167,14 +162,12 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); $this->quoteAddressMock->expects($this->once())->method('setCollectShippingRates')->with(true); - $this->couponCodeDataMock->expects($this->once()) - ->method('getCouponCode')->will($this->returnValue($couponCode)); $this->quoteMock->expects($this->once())->method('setCouponCode')->with($couponCode); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); $this->quoteMock->expects($this->once())->method('getCouponCode')->will($this->returnValue($couponCode)); - $this->assertTrue($this->service->set($cartId, $this->couponCodeDataMock)); + $this->assertTrue($this->couponManagement->set($cartId, $couponCode)); } /** @@ -190,7 +183,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(0)); $this->quoteMock->expects($this->never())->method('getShippingAddress'); - $this->service->delete($cartId); + $this->couponManagement->remove($cartId); } /** @@ -217,7 +210,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->with($this->quoteMock) ->willThrowException($exception); - $this->service->delete($cartId); + $this->couponManagement->remove($cartId); } /** @@ -240,7 +233,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); $this->quoteMock->expects($this->once())->method('getCouponCode')->will($this->returnValue('123_ABC')); - $this->service->delete($cartId); + $this->couponManagement->remove($cartId); } public function testDelete() @@ -259,6 +252,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); $this->quoteMock->expects($this->once())->method('getCouponCode')->will($this->returnValue('')); - $this->assertTrue($this->service->delete($cartId)); + $this->assertTrue($this->couponManagement->remove($cartId)); } } diff --git a/dev/tests/unit/testsuite/Magento/Quote/Model/PaymentMethodManagementTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/PaymentMethodManagementTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3d6402af1149b5b98f8fd2bb98f13ffe35a5d8e4 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/PaymentMethodManagementTest.php @@ -0,0 +1,409 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model; + +class PaymentMethodManagementTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Quote\Model\PaymentMethodManagement + */ + protected $model; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteRepositoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $methodListMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $zeroTotalMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $paymentMethodBuilder; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); + $this->methodListMock = $this->getMock('\Magento\Payment\Model\MethodList', [], [], '', false); + $this->zeroTotalMock = $this->getMock('\Magento\Payment\Model\Checks\ZeroTotal', [], [], '', false); + $this->paymentMethodBuilder = $this->getMock( + '\Magento\Quote\Api\Data\PaymentMethodDataBuilder', + [], + [], + '', + false + ); + + $this->model = $this->objectManager->getObject( + '\Magento\Quote\Model\PaymentMethodManagement', + [ + 'quoteRepository' => $this->quoteRepositoryMock, + 'methodList' => $this->methodListMock, + 'zeroTotalValidator' => $this->zeroTotalMock, + 'paymentMethodBuilder' => $this->paymentMethodBuilder, + ] + ); + } + + public function testGetPaymentIfPaymentMethodNotSet() + { + $cartId = 11; + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false); + $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); + $paymentMock->expects($this->once())->method('getId')->will($this->returnValue(null)); + + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->will($this->returnValue($quoteMock)); + + $this->assertNull($this->model->get($cartId)); + } + + public function testGetPaymentSuccess() + { + $cartId = 11; + + $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false); + $paymentMock->expects($this->once())->method('getId')->will($this->returnValue(1)); + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); + + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->will($this->returnValue($quoteMock)); + $this->assertEquals($paymentMock, $this->model->get($cartId)); + } + + public function testGetList() + { + $cartId = 10; + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->will($this->returnValue($quoteMock)); + + $paymentMethod = $this->getMock('\Magento\Quote\Api\Data\PaymentMethodInterface'); + $this->methodListMock->expects($this->once()) + ->method('getAvailableMethods') + ->with($quoteMock) + ->will($this->returnValue([$paymentMethod])); + $this->assertEquals([$paymentMethod], $this->model->getList($cartId)); + } + + public function testSetVirtualProduct() + { + $cartId = 100; + $paymentId = 200; + $methodData = ['method' => 'data']; + $paymentMethod = 'checkmo'; + + $quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + ['setTotalsCollectedFlag', 'getPayment', 'isVirtual', 'getBillingAddress', 'collectTotals', 'save'], + [], + '', + false + ); + $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->willReturn($quoteMock); + + $methodMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock->expects($this->once()) + ->method('setChecks') + ->with([ + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, + ]) + ->willReturnSelf(); + $methodMock->expects($this->once())->method('getData')->willReturn($methodData); + + $paymentMock = $this->getMock( + '\Magento\Quote\Model\Quote\Payment', + ['importData', 'getMethod', 'getMethodInstance', 'getId'], + [], + '', + false + ); + $paymentMock->expects($this->once())->method('importData')->with($methodData)->willReturnSelf(); + $paymentMock->expects($this->once())->method('getMethod')->willReturn($paymentMethod); + + $billingAddressMock = $this->getMock( + '\Magento\Quote\Model\Quote\Address', + ['getCountryId', 'setPaymentMethod'], + [], + '', + false + ); + $billingAddressMock->expects($this->once())->method('getCountryId')->willReturn(100); + $billingAddressMock->expects($this->once()) + ->method('setPaymentMethod') + ->with($paymentMethod) + ->willReturnSelf(); + + $quoteMock->expects($this->exactly(2))->method('getPayment')->willReturn($paymentMock); + $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(true); + $quoteMock->expects($this->exactly(2))->method('getBillingAddress')->willReturn($billingAddressMock); + + $methodInstance = $this->getMock('\Magento\Payment\Model\Checks\PaymentMethodChecksInterface'); + $paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInstance); + + $this->zeroTotalMock->expects($this->once()) + ->method('isApplicable') + ->with($methodInstance, $quoteMock) + ->willReturn(true); + + $quoteMock->expects($this->once())->method('setTotalsCollectedFlag')->with(false)->willReturnSelf(); + $quoteMock->expects($this->once())->method('collectTotals')->willReturnSelf(); + $quoteMock->expects($this->once())->method('save')->willReturnSelf(); + + $paymentMock->expects($this->once())->method('getId')->willReturn($paymentId); + $this->assertEquals($paymentId, $this->model->set($cartId, $methodMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException + * @expectedExceptionMessage Billing address is not set + */ + public function testSetVirtualProductThrowsExceptionIfBillingAddressNotSet() + { + $cartId = 100; + $methodData = ['method' => 'data']; + + $quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + ['getPayment', 'isVirtual', 'getBillingAddress'], + [], + '', + false + ); + $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->willReturn($quoteMock); + + $methodMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock->expects($this->once()) + ->method('setChecks') + ->with([ + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, + ]) + ->willReturnSelf(); + $methodMock->expects($this->once())->method('getData')->willReturn($methodData); + + $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', ['importData', 'getMethod'], [], '', false); + $paymentMock->expects($this->once())->method('importData')->with($methodData)->willReturnSelf(); + + $billingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', ['getCountryId'], [], '', false); + $billingAddressMock->expects($this->once())->method('getCountryId')->willReturn(null); + + $quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentMock); + $quoteMock->expects($this->once())->method('isVirtual')->willReturn(true); + $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock); + + $this->model->set($cartId, $methodMock); + } + + /** + * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException + * @expectedExceptionMessage The requested Payment Method is not available. + */ + public function testSetVirtualProductThrowsExceptionIfPaymentMethodNotAvailable() + { + $cartId = 100; + $methodData = ['method' => 'data']; + $paymentMethod = 'checkmo'; + + $quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + ['getPayment', 'isVirtual', 'getBillingAddress'], + [], + '', + false + ); + $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->willReturn($quoteMock); + + $methodMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock->expects($this->once()) + ->method('setChecks') + ->with([ + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, + ]) + ->willReturnSelf(); + $methodMock->expects($this->once())->method('getData')->willReturn($methodData); + + $paymentMock = $this->getMock( + '\Magento\Quote\Model\Quote\Payment', + ['importData', 'getMethod', 'getMethodInstance'], + [], + '', + false + ); + $paymentMock->expects($this->once())->method('importData')->with($methodData)->willReturnSelf(); + $paymentMock->expects($this->once())->method('getMethod')->willReturn($paymentMethod); + + $billingAddressMock = $this->getMock( + '\Magento\Quote\Model\Quote\Address', + ['getCountryId', 'setPaymentMethod'], + [], + '', + false + ); + $billingAddressMock->expects($this->once())->method('getCountryId')->willReturn(100); + $billingAddressMock->expects($this->once()) + ->method('setPaymentMethod') + ->with($paymentMethod) + ->willReturnSelf(); + + $quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentMock); + $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(true); + $quoteMock->expects($this->exactly(2))->method('getBillingAddress')->willReturn($billingAddressMock); + + $methodInstance = $this->getMock('\Magento\Payment\Model\Checks\PaymentMethodChecksInterface'); + $paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInstance); + + $this->zeroTotalMock->expects($this->once()) + ->method('isApplicable') + ->with($methodInstance, $quoteMock) + ->willReturn(false); + $this->model->set($cartId, $methodMock); + } + + public function testSetSimpleProduct() + { + $cartId = 100; + $paymentId = 20; + $methodData = ['method' => 'data']; + $paymentMethod = 'checkmo'; + + $quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + ['getPayment', 'isVirtual', 'getShippingAddress', 'setTotalsCollectedFlag', 'collectTotals', 'save'], + [], + '', + false + ); + $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->willReturn($quoteMock); + + $methodMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock->expects($this->once()) + ->method('setChecks') + ->with([ + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, + ]) + ->willReturnSelf(); + $methodMock->expects($this->once())->method('getData')->willReturn($methodData); + + $paymentMock = $this->getMock( + '\Magento\Quote\Model\Quote\Payment', + ['importData', 'getMethod', 'getMethodInstance', 'getId'], + [], + '', + false + ); + $paymentMock->expects($this->once())->method('importData')->with($methodData)->willReturnSelf(); + $paymentMock->expects($this->once())->method('getMethod')->willReturn($paymentMethod); + + $shippingAddressMock = $this->getMock( + '\Magento\Quote\Model\Quote\Address', + ['getCountryId', 'setPaymentMethod'], + [], + '', + false + ); + $shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn(100); + $shippingAddressMock->expects($this->once()) + ->method('setPaymentMethod') + ->with($paymentMethod) + ->willReturnSelf(); + + $quoteMock->expects($this->exactly(2))->method('getPayment')->willReturn($paymentMock); + $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(false); + $quoteMock->expects($this->exactly(4))->method('getShippingAddress')->willReturn($shippingAddressMock); + + $methodInstance = $this->getMock('\Magento\Payment\Model\Checks\PaymentMethodChecksInterface'); + $paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInstance); + + $this->zeroTotalMock->expects($this->once()) + ->method('isApplicable') + ->with($methodInstance, $quoteMock) + ->willReturn(true); + + $quoteMock->expects($this->once())->method('setTotalsCollectedFlag')->with(false)->willReturnSelf(); + $quoteMock->expects($this->once())->method('collectTotals')->willReturnSelf(); + $quoteMock->expects($this->once())->method('save')->willReturnSelf(); + + $paymentMock->expects($this->once())->method('getId')->willReturn($paymentId); + $this->assertEquals($paymentId, $this->model->set($cartId, $methodMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException + * @expectedExceptionMessage Shipping address is not set + */ + public function testSetSimpleProductTrowsExceptionIfShippingAddressNotSet() + { + $cartId = 100; + $methodData = ['method' => 'data']; + + $quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + ['getPayment', 'isVirtual', 'getShippingAddress'], + [], + '', + false + ); + $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->willReturn($quoteMock); + + $methodMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock->expects($this->once()) + ->method('setChecks') + ->with([ + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, + ]) + ->willReturnSelf(); + $methodMock->expects($this->once())->method('getData')->willReturn($methodData); + + $paymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment', ['importData'], [], '', false); + $paymentMock->expects($this->once())->method('importData')->with($methodData)->willReturnSelf(); + + $shippingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', ['getCountryId'], [], '', false); + $shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn(null); + + $quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentMock); + $quoteMock->expects($this->once())->method('isVirtual')->willReturn(false); + $quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($shippingAddressMock); + + $this->model->set($cartId, $methodMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/Quote/Item/RepositoryTest.php similarity index 59% rename from dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php rename to dev/tests/unit/testsuite/Magento/Quote/Model/Quote/Item/RepositoryTest.php index ee0069f41359e8d5f15c443096f0fc12df2e3fc4..8d814d30d59e7de3c33de27ce5cf031c1f15552e 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/Quote/Item/RepositoryTest.php @@ -5,14 +5,14 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\Item; +namespace Magento\Quote\Model\Quote\Item; -class WriteServiceTest extends \PHPUnit_Framework_TestCase +class RepositoryTest extends \PHPUnit_Framework_TestCase { /** - * @var WriteService + * @var Repository */ - protected $service; + protected $repository; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -44,19 +44,30 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ protected $quoteItemMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $itemBuilderMock; + protected function setUp() { $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); $this->productRepositoryMock = $this->getMock('Magento\Catalog\Api\ProductRepositoryInterface', [], [], '', false); - $this->dataMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\Item', [], [], '', false); + $methods = ['setQuoteId', 'setItemId', 'create']; + $this->itemBuilderMock = $this->getMock('Magento\Quote\Api\Data\CartItemDataBuilder', $methods, [], '', false); + $this->dataMock = $this->getMock('Magento\Quote\Api\Data\CartItemInterface'); $this->quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); $this->quoteItemMock = - $this->getMock('\Magento\Quote\Model\Quote\Item', ['getId', 'setData', '__wakeUp'], [], '', false); + $this->getMock('Magento\Quote\Model\Quote\Item', ['getId', 'getSku', 'setData', '__wakeUp'], [], '', false); - $this->service = new WriteService($this->quoteRepositoryMock, $this->productRepositoryMock); + $this->repository = new Repository( + $this->quoteRepositoryMock, + $this->productRepositoryMock, + $this->itemBuilderMock + ); } /** @@ -65,12 +76,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase * @expectedExceptionMessage Invalid value of * @dataProvider addItemWithInvalidQtyDataProvider */ - public function testAddItemWithInvalidQty($value) + public function testSaveItemWithInvalidQty($value) { - $cartId = 12; $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue($value)); - - $this->service->addItem($cartId, $this->dataMock); + $this->repository->save($this->dataMock); } public function addItemWithInvalidQtyDataProvider() @@ -88,33 +97,37 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Magento\Framework\Exception\CouldNotSaveException - * @expectedExceptionMessage Could not add item to quote + * @expectedExceptionMessage Could not save quote */ - public function testAddItemCouldNotSaveException() + public function testSaveCouldNotSaveException() { $cartId = 13; $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); $this->quoteRepositoryMock->expects($this->once())->method('getActive') ->with($cartId)->will($this->returnValue($this->quoteMock)); $this->dataMock->expects($this->once())->method('getSku')->will($this->returnValue('product_sku')); + $this->dataMock->expects($this->once())->method('getItemId')->will($this->returnValue(null)); + $this->quoteMock->expects($this->never())->method('getItemById'); $this->productRepositoryMock->expects($this->once()) ->method('get')->with('product_sku')->will($this->returnValue($this->productMock)); $this->quoteMock->expects($this->once())->method('addProduct')->with($this->productMock, 12); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); - $exceptionMessage = 'Could not add item to quote'; + $exceptionMessage = 'Could not save quote'; $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); $this->quoteRepositoryMock->expects($this->once()) ->method('save') ->with($this->quoteMock) ->willThrowException($exception); - $this->service->addItem($cartId, $this->dataMock); + $this->repository->save($this->dataMock); } - public function testAddItem() + public function testSave() { $cartId = 13; $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->productRepositoryMock->expects($this->once()) @@ -122,6 +135,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->productMock)); $this->dataMock->expects($this->once())->method('getSku'); $this->quoteMock->expects($this->once())->method('addProduct')->with($this->productMock, 12); + $this->quoteMock->expects($this->never())->method('getItemById'); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); $this->quoteMock @@ -129,35 +143,8 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->method('getItemByProduct') ->with($this->productMock) ->will($this->returnValue($this->quoteItemMock)); - $this->quoteItemMock->expects($this->once())->method('getId')->will($this->returnValue(5)); - $this->assertEquals(5, $this->service->addItem($cartId, $this->dataMock)); - } - - /** - * @param null|string|bool|int|float $value - * @expectedException \Magento\Framework\Exception\InputException - * @expectedExceptionMessage Invalid value of - * @dataProvider updateItemWithInvalidQtyDataProvider - */ - public function testUpdateItemWithInvalidQty($value) - { - $cartId = 11; - $itemID = 'item_sku'; - $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue($value)); - $this->service->updateItem($cartId, $itemID, $this->dataMock); - } - - public function updateItemWithInvalidQtyDataProvider() - { - return [ - ['string'], - [0], - [''], - [null], - [-12], - [false], - [-13.1], - ]; + $this->dataMock->expects($this->once())->method('getItemId')->will($this->returnValue(null)); + $this->assertEquals($this->quoteItemMock, $this->repository->save($this->dataMock)); } /** @@ -169,81 +156,112 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 11; $itemId = 5; $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); + $this->dataMock->expects($this->once())->method('getItemId')->will($this->returnValue($itemId)); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('getItemById')->with($itemId)->will($this->returnValue(false)); $this->quoteItemMock->expects($this->never())->method('setData'); + $this->quoteItemMock->expects($this->never())->method('addProduct'); - $this->service->updateItem($cartId, $itemId, $this->dataMock); + $this->repository->save($this->dataMock); } /** * @expectedException \Magento\Framework\Exception\CouldNotSaveException - * @expectedExceptionMessage Could not update quote item + * @expectedExceptionMessage Could not save quote */ public function testUpdateItemWithCouldNotSaveException() { $cartId = 11; $itemId = 5; + $productSku = 'product_sku'; $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->dataMock->expects($this->once())->method('getItemId')->will($this->returnValue($itemId)); + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('getItemById')->with($itemId)->will($this->returnValue($this->quoteItemMock)); $this->quoteItemMock->expects($this->once())->method('setData')->with('qty', 12); + $this->quoteItemMock->expects($this->once())->method('getSku')->willReturn($productSku); + $this->productRepositoryMock + ->expects($this->once()) + ->method('get') + ->with($productSku) + ->willReturn($this->productMock); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); - $exceptionMessage = 'Could not update quote item'; + $this->quoteItemMock->expects($this->never())->method('addProduct'); + $exceptionMessage = 'Could not save quote'; $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); $this->quoteRepositoryMock->expects($this->once()) ->method('save') ->with($this->quoteMock) ->willThrowException($exception); - $this->service->updateItem($cartId, $itemId, $this->dataMock); + $this->repository->save($this->dataMock); } public function testUpdateItem() { $cartId = 11; $itemId = 5; + $productSku = 'product_sku'; $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->dataMock->expects($this->once())->method('getItemId')->will($this->returnValue($itemId)); + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('getItemById')->with($itemId)->will($this->returnValue($this->quoteItemMock)); $this->quoteItemMock->expects($this->once())->method('setData')->with('qty', 12); + $this->quoteItemMock->expects($this->once())->method('getSku')->willReturn($productSku); + $this->productRepositoryMock + ->expects($this->once()) + ->method('get') + ->with($productSku) + ->willReturn($this->productMock); + $this->quoteItemMock->expects($this->never())->method('addProduct'); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); - - $this->assertTrue($this->service->updateItem($cartId, $itemId, $this->dataMock)); + $this->quoteMock + ->expects($this->once()) + ->method('getItemByProduct') + ->with($this->productMock) + ->willReturn($this->quoteItemMock); + $this->assertEquals($this->quoteItemMock, $this->repository->save($this->dataMock)); } /** * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage Cart 11 doesn't contain item 5 */ - public function testRemoveItemWithInvalidQuoteItem() + public function testDeleteWithInvalidQuoteItem() { $cartId = 11; $itemId = 5; + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); + $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('getItemById')->with($itemId)->will($this->returnValue(false)); $this->quoteMock->expects($this->never())->method('removeItem'); - $this->service->removeItem($cartId, $itemId, $this->dataMock); + $this->repository->delete($this->dataMock); } /** * @expectedException \Magento\Framework\Exception\CouldNotSaveException * @expectedExceptionMessage Could not remove item from quote */ - public function testRemoveItemWithCouldNotSaveException() + public function testDeleteWithCouldNotSaveException() { $cartId = 11; $itemId = 5; + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); + $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) @@ -258,13 +276,47 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->with($this->quoteMock) ->willThrowException($exception); - $this->service->removeItem($cartId, $itemId, $this->dataMock); + $this->repository->delete($this->dataMock); + } + + public function testDelete() + { + $cartId = 11; + $itemId = 5; + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); + $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('getItemById')->with($itemId)->will($this->returnValue($this->quoteItemMock)); + $this->quoteMock->expects($this->once())->method('removeItem'); + $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); + + $this->repository->delete($this->dataMock); + } + + public function testGetList() + { + $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once())->method('getActive') + ->with(33) + ->will($this->returnValue($quoteMock)); + $itemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', [], [], '', false); + $quoteMock->expects($this->any())->method('getAllItems')->will($this->returnValue([$itemMock])); + + $this->assertEquals([$itemMock], $this->repository->getList(33)); } - public function testRemoveItem() + public function testDeleteById() { $cartId = 11; $itemId = 5; + $this->itemBuilderMock->expects($this->once())->method('setQuoteId')->with($cartId)->willReturnSelf(); + $this->itemBuilderMock->expects($this->once())->method('setItemId')->with($itemId)->willReturnSelf(); + $this->itemBuilderMock->expects($this->once())->method('create')->willReturn($this->dataMock); + $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); + $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) @@ -273,6 +325,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); - $this->assertTrue($this->service->removeItem($cartId, $itemId, $this->dataMock)); + $this->assertTrue($this->repository->deleteById($cartId, $itemId)); } } diff --git a/dev/tests/unit/testsuite/Magento/Quote/Model/Quote/PaymentTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/Quote/PaymentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b09fe0b26b47d5432828ff32dbe50f1c38abdecf --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/Quote/PaymentTest.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model\Quote; + +use Magento\TestFramework\Helper\ObjectManager; + +class PaymentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Payment + */ + private $model; + + protected function setUp() + { + $objectManager = new ObjectManager($this); + $this->model = $objectManager->getObject( + '\Magento\Quote\Model\Quote\Payment' + ); + } + + /** + * @param int|string|null $databaseValue + * @param int|string|null $expectedValue + * @dataProvider yearValueDataProvider + */ + public function testGetCcExpYearReturnsValidValue($databaseValue, $expectedValue) + { + $this->model->setData('cc_exp_year', $databaseValue); + $this->assertEquals($expectedValue, $this->model->getCcExpYear()); + } + + /** + * @return array + */ + public function yearValueDataProvider() + { + return [ + [null, null], + [0, null], + ['0', null], + [1939, 1939], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteAddressValidatorTest.php similarity index 71% rename from dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php rename to dev/tests/unit/testsuite/Magento/Quote/Model/QuoteAddressValidatorTest.php index 2ba21342fb7c80d51ce612702e64233fb4695444..32c0b6b32c5c53b0d85fe936b9624f7134438c89 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteAddressValidatorTest.php @@ -7,14 +7,12 @@ // @codingStandardsIgnoreFile -namespace Magento\Checkout\Service\V1\Address; +namespace Magento\Quote\Model; -use Magento\Checkout\Service\V1\Data\Cart\Address; - -class ValidatorTest extends \PHPUnit_Framework_TestCase +class QuoteAddressValidatorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Checkout\Service\V1\Address\Validator + * @var QuoteAddressValidator */ protected $model; @@ -38,11 +36,6 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase */ protected $quoteAddressMock; - /** - * @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder - */ - protected $addressDataBuilder; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -66,22 +59,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase '\Magento\Customer\Model\CustomerFactory', ['create', '__wakeup'], [], '', false); $this->customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); - $builder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder', ['create'], [], '', false - ); - - $this->addressDataBuilder = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', - ['regionBuilder' => $builder] - ); - - $this->model = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Address\Validator', - [ - 'quoteAddressFactory' => $this->addressFactoryMock, - 'customerFactory' => $this->customerFactoryMock, - ] - ); + $this->model = new QuoteAddressValidator($this->addressFactoryMock, $this->customerFactoryMock); } /** @@ -99,11 +77,9 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $this->customerMock->expects($this->once())->method('load')->with($customerId); $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue(null)); - $addressData = $this->addressDataBuilder - ->setCustomerId($customerId) - ->setCompany('eBay Inc') - ->create(); - $this->model->validate($addressData); + $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $address->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($customerId); + $this->model->validate($address); } /** @@ -118,11 +94,9 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $this->addressFactoryMock->expects($this->once())->method('create') ->will($this->returnValue($this->quoteAddressMock)); - $addressData = $this->addressDataBuilder - ->setId(101) - ->setCompany('eBay Inc') - ->create(); - $this->model->validate($addressData); + $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $address->expects($this->atLeastOnce())->method('getId')->willReturn(101); + $this->model->validate($address); } /** @@ -133,8 +107,8 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $this->customerFactoryMock->expects($this->never())->method('create'); $this->addressFactoryMock->expects($this->never())->method('create'); - $addressData = $this->addressDataBuilder->setCompany('eBay Inc')->create(); - $this->assertTrue($this->model->validate($addressData)); + $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $this->assertTrue($this->model->validate($address)); } /** @@ -146,12 +120,9 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $addressCustomer = 100; $addressId = 100; - /** Address data object */ - $addressData = $this->addressDataBuilder - ->setId($addressId) - ->setCompany('eBay Inc') - ->setCustomerId($addressCustomer) - ->create(); + $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $address->expects($this->atLeastOnce())->method('getId')->willReturn($addressId); + $address->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($addressCustomer); /** Customer mock */ $this->customerFactoryMock->expects($this->once()) @@ -171,7 +142,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(10)); /** Validate */ - $this->model->validate($addressData); + $this->model->validate($address); } public function testValidateWithValidAddress() @@ -179,12 +150,9 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $addressCustomer = 100; $addressId = 100; - /** Address data object */ - $addressData = $this->addressDataBuilder - ->setId($addressId) - ->setCompany('eBay Inc') - ->setCustomerId($addressCustomer) - ->create(); + $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $address->expects($this->atLeastOnce())->method('getId')->willReturn($addressId); + $address->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($addressCustomer); /** Customer mock */ $this->customerFactoryMock->expects($this->once()) @@ -204,6 +172,6 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($addressCustomer)); /** Validate */ - $this->model->validate($addressData); + $this->model->validate($address); } } diff --git a/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteManagementTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteManagementTest.php index bcb93755ebf3e6adfaa3c990a0e0fb71d618fd35..56e96636e95f65499191460d28001c78aeb07b73 100644 --- a/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteManagementTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteManagementTest.php @@ -6,6 +6,11 @@ namespace Magento\Quote\Model; +use \Magento\Framework\Exception\NoSuchEntityException; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class QuoteManagementTest extends \PHPUnit_Framework_TestCase { /** @@ -53,11 +58,31 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase */ protected $orderManagement; + /** + * @var \Magento\Quote\Model\QuoteRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteRepositoryMock; + /** * @var CustomerManagement */ protected $customerManagement; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $userContextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerRepositoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerFactoryMock; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -99,6 +124,23 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase $this->quoteItemToOrderItem = $this->getMock('Magento\Quote\Model\Quote\Item\ToOrderItem', [], [], '', false); $this->orderManagement = $this->getMock('Magento\Sales\Api\OrderManagementInterface', [], [], '', false); $this->customerManagement = $this->getMock('Magento\Quote\Model\CustomerManagement', [], [], '', false); + $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); + + $this->userContextMock = $this->getMock('\Magento\Authorization\Model\UserContextInterface', [], [], '', false); + $this->customerRepositoryMock = $this->getMock( + '\Magento\Customer\Api\CustomerRepositoryInterface', + ['create', 'save', 'get', 'getById', 'getList', 'delete', 'deleteById'], + [], + '', + false + ); + $this->customerFactoryMock = $this->getMock( + '\Magento\Customer\Model\CustomerFactory', + ['create'], + [], + '', + false + ); $this->model = $objectManager->getObject( 'Magento\Quote\Model\QuoteManagement', @@ -111,11 +153,331 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase 'quoteAddressToOrder' => $this->quoteAddressToOrder, 'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress, 'quoteItemToOrderItem' => $this->quoteItemToOrderItem, - 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment + 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment, + 'quoteRepository' => $this->quoteRepositoryMock, + 'userContext' => $this->userContextMock, + 'customerRepository' => $this->customerRepositoryMock, + 'customerModelFactory' => $this->customerFactoryMock, ] ); } + public function testCreateEmptyCartAnonymous() + { + $storeId = 345; + $quoteId = 2311; + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + + $this->userContextMock->expects($this->once())->method('getUserType') + ->willReturn(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_GUEST); + + $this->quoteRepositoryMock->expects($this->once())->method('create')->willReturn($quoteMock); + $quoteMock->expects($this->any())->method('setStoreId')->with($storeId); + + + $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); + $quoteMock->expects($this->once())->method('getId')->willReturn($quoteId); + + $this->assertEquals($quoteId, $this->model->createEmptyCart($storeId)); + } + + public function testCreateEmptyCartLoggedInUser() + { + $storeId = 345; + $quoteId = 2311; + $userId = 567; + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + + $this->userContextMock->expects($this->once())->method('getUserType') + ->willReturn(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER); + + $this->userContextMock->expects($this->atLeastOnce())->method('getUserId')->willReturn($userId); + + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $this->customerRepositoryMock + ->expects($this->once()) + ->method('getById') + ->with($userId) + ->willReturn($customerMock); + + $this->quoteRepositoryMock + ->expects($this->once()) + ->method('getActiveForCustomer') + ->with($userId) + ->willThrowException(new NoSuchEntityException()); + + $this->quoteRepositoryMock->expects($this->once())->method('create')->willReturn($quoteMock); + $quoteMock->expects($this->any())->method('setStoreId')->with($storeId); + $quoteMock->expects($this->any())->method('setCustomer')->with($customerMock); + $quoteMock->expects($this->any())->method('setCustomerIsGuest')->with(0); + + + $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); + $quoteMock->expects($this->once())->method('getId')->willReturn($quoteId); + + $this->assertEquals($quoteId, $this->model->createEmptyCart($storeId)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testCreateEmptyCartLoggedInUserException() + { + $storeId = 345; + $userId = 567; + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + + $this->userContextMock->expects($this->once())->method('getUserType') + ->willReturn(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER); + + $this->userContextMock->expects($this->atLeastOnce())->method('getUserId')->willReturn($userId); + + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $this->customerRepositoryMock + ->expects($this->once()) + ->method('getById') + ->with($userId) + ->willReturn($customerMock); + + $this->quoteRepositoryMock + ->expects($this->once()) + ->method('getActiveForCustomer') + ->with($userId); + + $this->quoteRepositoryMock->expects($this->never())->method('create')->willReturn($quoteMock); + + $this->quoteRepositoryMock->expects($this->never())->method('save')->with($quoteMock); + + $this->model->createEmptyCart($storeId); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Cannot assign customer to the given cart. The cart belongs to different store + */ + public function testAssignCustomerFromAnotherStore() + { + $cartId = 220; + $customerId = 455; + $storeId = 5; + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + + $this->quoteRepositoryMock + ->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->willReturn($quoteMock); + + $this->customerRepositoryMock + ->expects($this->once()) + ->method('getById') + ->with($customerId) + ->willReturn($customerMock); + + $customerModelMock = $this->getMock( + '\Magento\Customer\Model\Customer', + ['load', 'getSharedStoreIds'], + [], + '', + false + ); + $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock); + $customerModelMock + ->expects($this->once()) + ->method('load') + ->with($customerId) + ->willReturnSelf(); + + $customerModelMock + ->expects($this->once()) + ->method('getSharedStoreIds') + ->willReturn([]); + + $this->model->assignCustomer($cartId, $customerId, $storeId); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Cannot assign customer to the given cart. The cart is not anonymous. + */ + public function testAssignCustomerToNonanonymousCart() + { + $cartId = 220; + $customerId = 455; + $storeId = 5; + + $quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + ['getCustomerId', 'setCustomer', 'setCustomerIsGuest'], + [], + '', + false + ); + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + + $this->quoteRepositoryMock + ->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->willReturn($quoteMock); + + $this->customerRepositoryMock + ->expects($this->once()) + ->method('getById') + ->with($customerId) + ->willReturn($customerMock); + + $customerModelMock = $this->getMock( + '\Magento\Customer\Model\Customer', + ['load', 'getSharedStoreIds'], + [], + '', + false + ); + $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock); + $customerModelMock + ->expects($this->once()) + ->method('load') + ->with($customerId) + ->willReturnSelf(); + + $customerModelMock + ->expects($this->once()) + ->method('getSharedStoreIds') + ->willReturn([$storeId, 'some store value']); + + $quoteMock->expects($this->once())->method('getCustomerId')->willReturn(753); + + $this->model->assignCustomer($cartId, $customerId, $storeId); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Cannot assign customer to the given cart. Customer already has active cart. + */ + public function testAssignCustomerNoSuchCustomer() + { + $cartId = 220; + $customerId = 455; + $storeId = 5; + + $quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + ['getCustomerId', 'setCustomer', 'setCustomerIsGuest'], + [], + '', + false + ); + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + + $this->quoteRepositoryMock + ->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->willReturn($quoteMock); + + $this->customerRepositoryMock + ->expects($this->once()) + ->method('getById') + ->with($customerId) + ->willReturn($customerMock); + + $customerModelMock = $this->getMock( + '\Magento\Customer\Model\Customer', + ['load', 'getSharedStoreIds'], + [], + '', + false + ); + $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock); + $customerModelMock + ->expects($this->once()) + ->method('load') + ->with($customerId) + ->willReturnSelf(); + + $customerModelMock + ->expects($this->once()) + ->method('getSharedStoreIds') + ->willReturn([$storeId, 'some store value']); + + $quoteMock->expects($this->once())->method('getCustomerId')->willReturn(null); + + $this->quoteRepositoryMock + ->expects($this->once()) + ->method('getForCustomer') + ->with($customerId); + + $this->model->assignCustomer($cartId, $customerId, $storeId); + } + + public function testAssignCustomer() + { + $cartId = 220; + $customerId = 455; + $storeId = 5; + + $quoteMock = $this->getMock( + '\Magento\Quote\Model\Quote', + ['getCustomerId', 'setCustomer', 'setCustomerIsGuest'], + [], + '', + false + ); + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + + $this->quoteRepositoryMock + ->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->willReturn($quoteMock); + + $this->customerRepositoryMock + ->expects($this->once()) + ->method('getById') + ->with($customerId) + ->willReturn($customerMock); + + $customerModelMock = $this->getMock( + '\Magento\Customer\Model\Customer', + ['load', 'getSharedStoreIds'], + [], + '', + false + ); + $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock); + $customerModelMock + ->expects($this->once()) + ->method('load') + ->with($customerId) + ->willReturnSelf(); + + $customerModelMock + ->expects($this->once()) + ->method('getSharedStoreIds') + ->willReturn([$storeId, 'some store value']); + + $quoteMock->expects($this->once())->method('getCustomerId')->willReturn(null); + + $this->quoteRepositoryMock + ->expects($this->once()) + ->method('getForCustomer') + ->with($customerId) + ->willThrowException(new NoSuchEntityException()); + + $quoteMock->expects($this->once())->method('setCustomer')->with($customerMock); + $quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0); + + $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); + + $this->model->assignCustomer($cartId, $customerId, $storeId); + } + public function testSubmit() { $orderData = []; @@ -161,7 +523,8 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase ->willReturn($baseOrder); $this->quoteAddressToOrderAddress->expects($this->at(0)) ->method('convert') - ->with($shippingAddress, + ->with( + $shippingAddress, [ 'address_type' => 'shipping', 'email' => 'customer@example.com' @@ -170,7 +533,8 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase ->willReturn($convertedShippingAddress); $this->quoteAddressToOrderAddress->expects($this->at(1)) ->method('convert') - ->with($billingAddress, + ->with( + $billingAddress, [ 'address_type' => 'billing', 'email' => 'customer@example.com' @@ -208,6 +572,8 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase ->method('dispatch') ->with('sales_model_service_quote_submit_success', ['order' => $order, 'quote' => $quote]); + $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quote); + $this->assertEquals($order, $this->model->submit($quote, $orderData)); } @@ -331,4 +697,15 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase return $order; } + + public function testGetCartForCustomer() + { + $customerId = 100; + $cartMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActiveForCustomer') + ->with($customerId) + ->willReturn($cartMock); + $this->assertEquals($cartMock, $this->model->getCartForCustomer($customerId)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php index 0f1d190d36381995d9407c3f0b9757e70d34044b..451d2281e49646a03b5bd2c690e62f79686f59b4 100644 --- a/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php @@ -7,7 +7,7 @@ namespace Magento\Quote\Model; -use Magento\Quote\Model\QuoteRepository; +use Magento\Framework\Api\SearchCriteria; class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -36,6 +36,16 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase */ protected $quoteMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteCollectionMock; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -51,11 +61,23 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase false ); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->searchResultsBuilderMock = $this->getMock( + '\Magento\Quote\Api\Data\CartSearchResultsDataBuilder', + ['setSearchCriteria', 'setTotalCount', 'setItems', 'create'], + [], + '', + false + ); + + $this->quoteCollectionMock = $this->getMock('Magento\Quote\Model\Resource\Quote\Collection', [], [], '', false); + $this->model = $objectManager->getObject( 'Magento\Quote\Model\QuoteRepository', [ 'quoteFactory' => $this->quoteFactoryMock, 'storeManager' => $this->storeManagerMock, + 'searchResultsBuilder' => $this->searchResultsBuilderMock, + 'quoteCollection' => $this->quoteCollectionMock, ] ); } @@ -280,4 +302,77 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->model->delete($this->quoteMock); } + + /** + * @param int $direction + * @param string $expectedDirection + * @dataProvider getListSuccessDataProvider + */ + public function testGetListSuccess($direction, $expectedDirection) + { + $searchResult = $this->getMock('\Magento\Quote\Api\Data\CartSearchResultsInterface', [], [], '', false); + $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false); + $cartMock = $this->getMock('Magento\Payment\Model\Cart', [], [], '', false); + $filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false); + $pageSize = 10; + + $this->searchResultsBuilderMock + ->expects($this->once()) + ->method('setSearchCriteria'); + + $filterGroupMock = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false); + $searchCriteriaMock + ->expects($this->any()) + ->method('getFilterGroups') + ->will($this->returnValue([$filterGroupMock])); + + //addFilterGroupToCollection() checks + $filterGroupMock->expects($this->any())->method('getFilters')->will($this->returnValue([$filterMock])); + $filterMock->expects($this->once())->method('getField')->will($this->returnValue('store_id')); + $filterMock->expects($this->any())->method('getConditionType')->will($this->returnValue('eq')); + $filterMock->expects($this->once())->method('getValue')->will($this->returnValue('filter_value')); + + //back in getList() + $this->quoteCollectionMock->expects($this->once())->method('getSize')->willReturn($pageSize); + $this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with($pageSize); + $sortOrderMock = $this->getMockBuilder('Magento\Framework\Api\SortOrder') + ->setMethods(['getField', 'getDirection']) + ->disableOriginalConstructor() + ->getMock(); + + //foreach cycle + $searchCriteriaMock + ->expects($this->once()) + ->method('getSortOrders') + ->will($this->returnValue([$sortOrderMock])); + $sortOrderMock->expects($this->once())->method('getField')->will($this->returnValue('id')); + $sortOrderMock->expects($this->once())->method('getDirection')->will($this->returnValue($direction)); + $this->quoteCollectionMock->expects($this->once())->method('addOrder')->with('id', $expectedDirection); + + + $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->will($this->returnValue(1)); + $searchCriteriaMock->expects($this->once())->method('getPageSize')->will($this->returnValue(10)); + $this->quoteCollectionMock->expects($this->once())->method('setCurPage')->with(1); + $this->quoteCollectionMock->expects($this->once())->method('setPageSize')->with(10); + + + $this->quoteCollectionMock->expects($this->once())->method('getItems')->willReturn([$cartMock]); + $this->searchResultsBuilderMock->expects($this->once())->method('setItems')->with([$cartMock]); + $this->searchResultsBuilderMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($searchResult)); + $this->assertEquals($searchResult, $this->model->getList($searchCriteriaMock)); + } + + /** + * @return array + */ + public function getListSuccessDataProvider() + { + return [ + 'asc' => [SearchCriteria::SORT_ASC, 'ASC'], + 'desc' => [SearchCriteria::SORT_DESC, 'DESC'] + ]; + } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/ShippingAddressManagementTest.php similarity index 55% rename from dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php rename to dev/tests/unit/testsuite/Magento/Quote/Model/ShippingAddressManagementTest.php index bd1cc59450f48748eb4bd2319461dd3e328328a6..b328b4b5ad5d0960f157f9d1129a3d43982ba409 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/ShippingAddressManagementTest.php @@ -7,12 +7,12 @@ // @codingStandardsIgnoreFile -namespace Magento\Checkout\Service\V1\Address\Shipping; +namespace Magento\Quote\Model; -class WriteServiceTest extends \PHPUnit_Framework_TestCase +class ShippingAddressManagementTest extends \PHPUnit_Framework_TestCase { /** - * @var WriteService + * @var ShippingAddressManagement */ protected $service; @@ -21,11 +21,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ protected $quoteRepositoryMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $addressFactoryMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -36,11 +31,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ protected $validatorMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $converterMock; - /** * @var \Magento\TestFramework\Helper\ObjectManager */ @@ -49,38 +39,21 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); - $this->addressFactoryMock = $this->getMock( - '\Magento\Quote\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false - ); - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteAddressMock = $this->getMock( '\Magento\Quote\Model\Quote\Address', - ['getCustomerId', 'load', 'getData', 'setData', 'setStreet', 'setRegionId', 'setRegion', '__wakeup'], + ['setSameAsBilling', 'setCollectShippingRates', '__wakeup'], [], '', false ); - $this->addressFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->quoteAddressMock)); - $this->validatorMock = $this->getMock( - '\Magento\Checkout\Service\V1\Address\Validator', [], [], '', false + 'Magento\Quote\Model\QuoteAddressValidator', [], [], '', false ); - - $this->converterMock = $this->getMock( - '\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false - ); - - $this->service = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Address\Shipping\WriteService', - [ - 'quoteRepository' => $this->quoteRepositoryMock, - 'quoteAddressFactory' => $this->addressFactoryMock, - 'addressValidator' => $this->validatorMock, - 'addressConverter' => $this->converterMock, - ] + $this->service = new ShippingAddressManagement( + $this->quoteRepositoryMock, + $this->validatorMock, + $this->getMock('\Psr\Log\LoggerInterface') ); } @@ -99,7 +72,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->validatorMock->expects($this->once())->method('validate') ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error345'))); - $this->service->setAddress('cart654', null); + $this->service->assign('cart654', $this->quoteAddressMock); } public function testSetAddress() @@ -111,27 +84,11 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); - $builder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder', ['create'], [], '', false - ); - - /** @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder $addressDataBuilder */ - $addressDataBuilder = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', - ['regionBuilder' => $builder] - ); - - /** @var \Magento\Checkout\Service\V1\Data\Cart\Address $addressData */ - $addressData = $addressDataBuilder->setId(356)->create(); $this->validatorMock->expects($this->once())->method('validate') - ->with($addressData) + ->with($this->quoteAddressMock) ->will($this->returnValue(true)); - $this->converterMock->expects($this->once())->method('convertDataObjectToModel') - ->with($addressData, $this->quoteAddressMock) - ->will($this->returnValue($this->quoteAddressMock)); - $quoteMock->expects($this->once())->method('setShippingAddress')->with($this->quoteAddressMock); $quoteMock->expects($this->once())->method('setDataChanges')->with(true); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); @@ -142,7 +99,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $quoteMock->expects($this->once())->method('getShippingAddress') ->will($this->returnValue($shippingAddressMock)); - $this->assertEquals($addressId, $this->service->setAddress('cart867', $addressData)); + $this->assertEquals($addressId, $this->service->assign('cart867', $this->quoteAddressMock)); } /** @@ -158,25 +115,12 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(true)); - $builder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder', ['create'], [], '', false - ); - - /** @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder $addressDataBuilder */ - $addressDataBuilder = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', - ['regionBuilder' => $builder] - ); - - /** @var \Magento\Checkout\Service\V1\Data\Cart\Address $addressData */ - $addressData = $addressDataBuilder->setId(356)->create(); - $this->validatorMock->expects($this->never())->method('validate'); $quoteMock->expects($this->never())->method('setShippingAddress'); $quoteMock->expects($this->never())->method('save'); - $this->service->setAddress('cart867', $addressData); + $this->service->assign('cart867', $this->quoteAddressMock); } /** @@ -192,27 +136,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); - $builder = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder', ['create'], [], '', false - ); - - /** @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder $addressDataBuilder */ - $addressDataBuilder = $this->objectManager->getObject( - 'Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', - ['regionBuilder' => $builder] - ); - - /** @var \Magento\Checkout\Service\V1\Data\Cart\Address $addressData */ - $addressData = $addressDataBuilder->setId(356)->create(); - $this->validatorMock->expects($this->once())->method('validate') - ->with($addressData) + ->with($this->quoteAddressMock) ->will($this->returnValue(true)); - $this->converterMock->expects($this->once())->method('convertDataObjectToModel') - ->with($addressData, $this->quoteAddressMock) - ->will($this->returnValue($this->quoteAddressMock)); - $quoteMock->expects($this->once())->method('setShippingAddress')->with($this->quoteAddressMock); $quoteMock->expects($this->once())->method('setDataChanges')->with(true); $this->quoteRepositoryMock->expects($this->once()) @@ -221,6 +148,36 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->willThrowException( new \Exception('Some DB Error') ); - $this->service->setAddress('cart867', $addressData); + $this->service->assign('cart867', $this->quoteAddressMock); + } + + public function testGetAddress() + { + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with('cartId')->will( + $this->returnValue($quoteMock) + ); + + $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($addressMock)); + $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(false)); + $this->assertEquals($addressMock, $this->service->get('cartId')); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable + */ + public function testGetAddressOfQuoteWithVirtualProducts() + { + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with('cartId')->will( + $this->returnValue($quoteMock) + ); + + $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(true)); + $quoteMock->expects($this->never())->method('getShippingAddress'); + + $this->service->get('cartId'); } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php similarity index 53% rename from dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php rename to dev/tests/unit/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php index 5d2de490851aab61f9546e27e10ea08114877eb9..e9e69c90ea8a502c972917ad580ca8f7e4adebf2 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php @@ -5,79 +5,272 @@ * See COPYING.txt for license details. */ -namespace Magento\Checkout\Service\V1\ShippingMethod; +namespace Magento\Quote\Model; -class WriteServiceTest extends \PHPUnit_Framework_TestCase +use Magento\Quote\Api\Data\ShippingMethodInterface; +use Magento\TestFramework\Helper\ObjectManager; + +class ShippingMethodManagementTest extends \PHPUnit_Framework_TestCase { /** - * @var WriteService + * @var ShippingMethodManagement */ - protected $service; + protected $model; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $addressFactoryMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteRepositoryMock; + protected $quoteMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteMock; + protected $shippingAddressMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $shippingAddressMock; + protected $methodBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $converterMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; protected function setUp() { - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->addressFactoryMock = $this->getMock('\Magento\Quote\Model\Quote\AddressFactory', [], [], '', false); + $this->objectManager = new ObjectManager($this); $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); + $this->methodBuilderMock = $this->getMock( + '\Magento\Quote\Api\Data\ShippingMethodDataBuilder', + ['populateWithArray', 'create'], + [], + '', + false + ); + $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $this->quoteMock = $this->getMock( '\Magento\Quote\Model\Quote', [ - 'getItemsCount', - 'isVirtual', 'getShippingAddress', + 'isVirtual', + 'getItemsCount', + 'getQuoteCurrencyCode', 'getBillingAddress', 'collectTotals', 'save', - '__wakeup' + '__wakeup', ], [], '', false ); - $this->shippingAddressMock = $this->getMock( '\Magento\Quote\Model\Quote\Address', [ - 'setShippingMethod', - 'requestShippingRates', - 'save', 'getCountryId', - '__wakeup' + 'getShippingMethod', + 'getShippingDescription', + 'getShippingAmount', + 'getBaseShippingAmount', + 'getGroupedAllShippingRates', + 'collectShippingRates', + 'requestShippingRates', + 'setShippingMethod', + '__wakeup', ], [], '', false ); + $this->converterMock = $this->getMock( + '\Magento\Quote\Model\Cart\ShippingMethodConverter', + [], + [], + '', + false + ); - $this->service = $objectManager->getObject( - 'Magento\Checkout\Service\V1\ShippingMethod\WriteService', + $this->model = $this->objectManager->getObject( + 'Magento\Quote\Model\ShippingMethodManagement', [ - 'addressFactory' => $this->addressFactoryMock, - 'quoteRepository' => $this->quoteRepositoryMock + 'quoteRepository' => $this->quoteRepositoryMock, + 'methodBuilder' => $this->methodBuilderMock, + 'converter' => $this->converterMock, ] ); } + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Shipping address not set. + */ + public function testGetMethodWhenShippingAddressIsNotSet() + { + $cartId = 666; + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); + $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); + + $this->assertNull($this->model->get($cartId)); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Line "WrongShippingMethod" doesn't contain delimiter _ + */ + public function testGetMethodWhenShippingMethodIsInvalid() + { + $cartId = 884; + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); + $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(34)); + $this->shippingAddressMock->expects($this->exactly(2)) + ->method('getShippingMethod') + ->will($this->returnValue('WrongShippingMethod')); + + $this->assertNull($this->model->get($cartId)); + } + + public function testGetMethod() + { + $cartId = 666; + $countryId = 1; + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); + $this->shippingAddressMock->expects($this->any()) + ->method('getCountryId')->will($this->returnValue($countryId)); + $this->shippingAddressMock->expects($this->any()) + ->method('getShippingMethod')->will($this->returnValue('one_two')); + $this->shippingAddressMock->expects($this->once()) + ->method('getShippingDescription')->will($this->returnValue('carrier - method')); + $this->shippingAddressMock->expects($this->once()) + ->method('getShippingAmount')->will($this->returnValue(123.56)); + $this->shippingAddressMock->expects($this->once()) + ->method('getBaseShippingAmount')->will($this->returnValue(100.06)); + $output = [ + ShippingMethodInterface::CARRIER_CODE => 'one', + ShippingMethodInterface::METHOD_CODE => 'two', + ShippingMethodInterface::CARRIER_TITLE => 'carrier', + ShippingMethodInterface::METHOD_TITLE => 'method', + ShippingMethodInterface::SHIPPING_AMOUNT => 123.56, + ShippingMethodInterface::BASE_SHIPPING_AMOUNT => 100.06, + ShippingMethodInterface::AVAILABLE => true, + ]; + $this->methodBuilderMock->expects($this->once()) + ->method('populateWithArray')->with($output)->will($this->returnValue($this->methodBuilderMock)); + $this->methodBuilderMock->expects($this->once())->method('create'); + + $this->model->get($cartId); + } + + public function testGetMethodIfMethodIsNotSet() + { + $cartId = 666; + $countryId = 1; + + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); + $this->shippingAddressMock->expects($this->any()) + ->method('getCountryId')->will($this->returnValue($countryId)); + $this->shippingAddressMock->expects($this->any()) + ->method('getShippingMethod')->will($this->returnValue(null)); + + $this->assertNull($this->model->get($cartId)); + } + + public function testGetListForVirtualCart() + { + $cartId = 834; + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('isVirtual')->will($this->returnValue(true)); + + $this->assertEquals([], $this->model->getList($cartId)); + } + + public function testGetListForEmptyCart() + { + $cartId = 834; + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('isVirtual')->will($this->returnValue(false)); + $this->quoteMock->expects($this->once()) + ->method('getItemsCount')->will($this->returnValue(0)); + + $this->assertEquals([], $this->model->getList($cartId)); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Shipping address not set. + */ + public function testGetListWhenShippingAddressIsNotSet() + { + $cartId = 834; + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('isVirtual')->will($this->returnValue(false)); + $this->quoteMock->expects($this->once()) + ->method('getItemsCount')->will($this->returnValue(3)); + $this->quoteMock->expects($this->once()) + ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); + $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); + + $this->model->getList($cartId); + } + + public function testGetList() + { + $cartId = 834; + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('isVirtual')->will($this->returnValue(false)); + $this->quoteMock->expects($this->once()) + ->method('getItemsCount')->will($this->returnValue(3)); + $this->quoteMock->expects($this->once()) + ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); + $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(345)); + $this->shippingAddressMock->expects($this->once())->method('collectShippingRates'); + $shippingRateMock = $this->getMock('\Magento\Quote\Model\Quote\Address\Rate', [], [], '', false); + $this->shippingAddressMock->expects($this->once()) + ->method('getGroupedAllShippingRates') + ->will($this->returnValue([[$shippingRateMock]])); + + $currencyCode = 'EUR'; + $this->quoteMock->expects($this->once()) + ->method('getQuoteCurrencyCode') + ->will($this->returnValue($currencyCode)); + + $this->converterMock->expects($this->once()) + ->method('modelToDataObject') + ->with($shippingRateMock, $currencyCode) + ->will($this->returnValue('RateValue')); + $this->assertEquals(['RateValue'], $this->model->getList($cartId)); + } + /** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Shipping method is not applicable for empty cart @@ -92,7 +285,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(0)); $this->quoteMock->expects($this->never())->method('isVirtual'); - $this->service->setMethod($cartId, $carrierCode, $methodCode); + $this->model->set($cartId, $carrierCode, $methodCode); } /** @@ -110,7 +303,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(1)); $this->quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(true)); - $this->service->setMethod($cartId, $carrierCode, $methodCode); + $this->model->set($cartId, $carrierCode, $methodCode); } /** @@ -130,7 +323,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); - $this->service->setMethod($cartId, $carrierCode, $methodCode); + $this->model->set($cartId, $carrierCode, $methodCode); } /** @@ -163,7 +356,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); $billingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); - $this->service->setMethod($cartId, $carrierCode, $methodCode); + $this->model->set($cartId, $carrierCode, $methodCode); } /** @@ -200,7 +393,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->method('requestShippingRates')->will($this->returnValue(false)); $this->shippingAddressMock->expects($this->never())->method('save'); - $this->service->setMethod($cartId, $carrierCode, $methodCode); + $this->model->set($cartId, $carrierCode, $methodCode); } /** @@ -246,7 +439,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->with($this->quoteMock) ->willThrowException($exception); - $this->service->setMethod($cartId, $carrierCode, $methodCode); + $this->model->set($cartId, $carrierCode, $methodCode); } /** @@ -266,7 +459,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); $this->shippingAddressMock->expects($this->once())->method('getCountryId'); - $this->service->setMethod($cartId, $carrierCode, $methodCode); + $this->model->set($cartId, $carrierCode, $methodCode); } public function testSetMethod() @@ -303,6 +496,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnSelf()); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); - $this->assertTrue($this->service->setMethod($cartId, $carrierCode, $methodCode)); + $this->assertTrue($this->model->set($cartId, $carrierCode, $methodCode)); } } diff --git a/lib/internal/Magento/Framework/App/Config/Data/ProcessorFactory.php b/lib/internal/Magento/Framework/App/Config/Data/ProcessorFactory.php index e34ec4519cd3b14427430ea17bbcab51c851eb2b..8f473e2a37b2ba3c9cf3a0e707dd43f9bbe70902 100644 --- a/lib/internal/Magento/Framework/App/Config/Data/ProcessorFactory.php +++ b/lib/internal/Magento/Framework/App/Config/Data/ProcessorFactory.php @@ -40,7 +40,7 @@ class ProcessorFactory $instance = $this->_objectManager->create($model); if (!$instance instanceof ProcessorInterface) { throw new \InvalidArgumentException( - $model . ' does not instance of \Magento\Framework\App\Config\Data\ProcessorInterface' + $model . ' is not instance of \Magento\Framework\App\Config\Data\ProcessorInterface' ); } $this->_pool[$model] = $instance; diff --git a/lib/internal/Magento/Framework/App/Resource/ConnectionFactory.php b/lib/internal/Magento/Framework/App/Resource/ConnectionFactory.php index 5c370d6cd5a30e0d51af75a5716f8b5d9f90acb8..655ae1f45d8a44acc0fe30f026c82d7abb9a5870 100644 --- a/lib/internal/Magento/Framework/App/Resource/ConnectionFactory.php +++ b/lib/internal/Magento/Framework/App/Resource/ConnectionFactory.php @@ -22,9 +22,11 @@ class ConnectionFactory extends ModelConnectionFactory public function create(array $connectionConfig) { $connection = parent::create($connectionConfig); - /** @var \Magento\Framework\App\Cache\Type\FrontendPool $pool */ - $pool = $this->objectManager->get('Magento\Framework\App\Cache\Type\FrontendPool'); - $connection->setCacheAdapter($pool->get(DdlCache::TYPE_IDENTIFIER)); + if ($connection) { + /** @var \Magento\Framework\App\Cache\Type\FrontendPool $pool */ + $pool = $this->objectManager->get('Magento\Framework\App\Cache\Type\FrontendPool'); + $connection->setCacheAdapter($pool->get(DdlCache::TYPE_IDENTIFIER)); + } return $connection; } } diff --git a/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php b/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php index 7d69fce3f9ec4f1b7833db814dbcc6a758a44922..bfe5cf299d5c3b3c2e7d076c61e0b543f46d3760 100644 --- a/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php +++ b/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php @@ -66,6 +66,9 @@ class FileFactory if ($content['type'] == 'filename') { $isFile = true; $file = $content['value']; + if (!$dir->isFile($file)) { + throw new \Exception(__('File not found')); + } $contentLength = $dir->stat($file)['size']; } } @@ -80,9 +83,6 @@ class FileFactory if (!is_null($content)) { if ($isFile) { - if (!$dir->isFile($file)) { - throw new \Exception(__('File not found')); - } $this->_response->sendHeaders(); $stream = $dir->openFile($file, 'r'); while (!$stream->eof()) { @@ -93,7 +93,7 @@ class FileFactory if (!empty($content['rm'])) { $dir->delete($file); } - exit(0); + $this->callExit(); } else { $this->_response->clearBody(); $this->_response->setBody($content); @@ -101,4 +101,15 @@ class FileFactory } return $this->_response; } + + /** + * Call exit + * + * @return void + * @SuppressWarnings(PHPMD.ExitExpression) + */ + protected function callExit() + { + exit(0); + } } diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index 4e7bbb51df6b148986e3578fa2264199a77d65ff..c3edf0713d748ecf7376cc657d146be95ea04d4c 100644 --- a/lib/internal/Magento/Framework/AppInterface.php +++ b/lib/internal/Magento/Framework/AppInterface.php @@ -17,7 +17,7 @@ interface AppInterface /** * Magento version */ - const VERSION = '0.42.0-beta4'; + const VERSION = '0.42.0-beta5'; /** * Launch application diff --git a/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php b/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php index 793323f4d143882b36a7a4c5c13a1e6cb58a3e6e..7ef142cc59d0e7f666429bd7b5785b1232682f85 100644 --- a/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php +++ b/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php @@ -291,7 +291,7 @@ abstract class EntityAbstract */ protected function _getClassDocBlock() { - $description = ucfirst(static::ENTITY_TYPE) . ' class for \\' . $this->_getSourceClassName(); + $description = ucfirst(static::ENTITY_TYPE) . ' class for @see \\' . $this->_getSourceClassName(); return ['shortDescription' => $description]; } diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index 23dc4052a9b3d230e11b7eb82abe6c83610aa63f..d551fbd64a24ba30ed1628b07b43a49dae0f395d 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.42.0-beta4", + "version": "0.42.0-beta5", "license": [ "OSL-3.0", "AFL-3.0"