diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c1ce2f9682e1cf00d460a3daaf03bf0e832a4f..f687b47a222504cd49848bbefd0aa43076b9c0e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,34 @@ +0.1.0-alpha96 +============= + * Framework improvements: + * Increased unit tests code coverage for Magento_Persistent, Magento_GiftMessage, Magento_Checkout modules + * Modularity: + * Removed module dependency on the Weee module + * Fixed Bugs: + * Fixed an issue in composer installation where Magento/Framework marshaling did not work + * Fixed an issue where shipping tax was included twice in tax details + * Renamed the getDistinct method in Tax Model + * Fixed an issue where it was impossible to reorder and create a new order in the Admin panel if some fields of the order were specified incorrectly and the page was reloaded + * Fixed an issue where the Configure link was not displayed in the Product Requiring Attention section + * Fixed an issue where Magento could only be installed in the host root directory + * Fixed an issue where no proper error message was displayed if vendor directory did not exist in the setup tool + * Fixed an issue where a fatal error was thrown during checkout with multiple addresses + * Fixed an issue where integration tests failed if prefixes for tables were used + * Checkout API: + * Created Customer Shopping Cart Service + * Price template refactoring + * Introduced a single interface for price and tax calculation logic + * Functional tests: + * Add products to shopping cart + * Bestseller products report + * Cancel created order + * Delete customer address + * Hold created order + * Ordered products report + * Sales coupon report + * GitHub requests: + * [#662] (https://github.com/magento/magento2/issues/662) -- Composer Installation + 0.1.0-alpha95 ============= * Modularity @@ -57,8 +88,8 @@ * Configuration scope of items' InStock status on order cancellation * Creating the new customer in admin * GitHub requests: - * #621 -- Parse error: syntax error, unexpected T_OBJECT_OPERATOR - * #651 -- Multishipping checkout add/edit address page issue + * [#621] (https://github.com/magento/magento2/issues/621) -- Parse error: syntax error, unexpected T_OBJECT_OPERATOR + * [#651] (https://github.com/magento/magento2/issues/651) -- Multishipping checkout add/edit address page issue 0.1.0-alpha94 ============= diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5672159c3d815a2ccafae84f976832b4f9ad6f60..f3e88912e5bc9d9b0171783fcfaa246d87a8dbec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ The Magento 2 development team will review all issues and contributions submitte If you are a new GitHub user, we recommend that you create your own [free github account](https://github.com/signup/free). By doing that, you will be able to collaborate with the Magento 2 development team, “fork†the Magento 2 project and be able to easily send “pull requestsâ€. 1. Search current [listed issues](https://github.com/magento/magento2/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution. -2. Review the [Contributor License Agreement](https://github.com/magento/magento2/wiki/Contributor-License-Agreement) if this is your first time contributing. +2. Review the [Contributor License Agreement](https://github.com/magento/magento2/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT.html) if this is your first time contributing. 3. Create and test your work. 4. Fork the Magento 2 repository according to [github's Fork A Repo instructions](https://help.github.com/articles/fork-a-repo) and when you are ready to send us a Pull Request – follow [github's Using Pull Requests instructions](https://help.github.com/articles/using-pull-requests). 5. Once your contribution is received, Magento 2 development team will review the contribution and collaborate with you as needed to improve the quality of the contribution. diff --git a/CONTRIBUTOR_LICENSE_AGREEMENT.html b/CONTRIBUTOR_LICENSE_AGREEMENT.html deleted file mode 100644 index 58281b8e8aeabeb14a23cf30b43cb78872812e94..0000000000000000000000000000000000000000 --- a/CONTRIBUTOR_LICENSE_AGREEMENT.html +++ /dev/null @@ -1,131 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>CONTRIBUTOR LICENSE AGREEMENT</title> - <style> - body { - font-size: 14px; - } - - ol { - counter-reset: list1; - font-family: Verdana, Arial, Helvetica, sans-serif; - padding-bottom: 12px; - } - li { - list-style-type: none; - padding-top: 12px; - } - ol li:before { - counter-increment: list1; - content: counter(list1) ". "; - } - ol ol { - counter-reset: list2; - } - ol ol li:before { - counter-increment: list2; - content: counter(list1) "." counter(list2) ". "; - } - h2 { - text-align: center; - font-family: Verdana, Arial, Helvetica, sans-serif; - } - p { - font-family: Verdana, Arial, Helvetica, sans-serif; - } - div { - width: 800px; - margin: 0 auto; - } - </style> -</head> -<body> -<div> -<h2> - CONTRIBUTOR LICENSE AGREEMENT -</h2> -<p> - This Contributor License Agreement ("Agreement") is made and entered into as of _______________, 20__ (the "Effective Date"), by and between X.commerce, Inc. dba Magento, Inc., a Delaware corporation with its principal place of business at 10441 Jefferson Blvd., Suite 200, Culver City, CA 90232 ("Magento", "we", "us", or "our"), and ______________________________, a _______________ with its principal place of business at _______________________________________ ("Contributor", "you" or "your", and collectively with Magento, the "Parties"). -</p> -<ol> - <li><strong><u>Definitions:</u></strong> - <ol> - <li> - <strong>"Contribution"</strong> means any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Magento for inclusion in, or documentation of, any of the products or services owned or managed by Magento (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication provided to Magento or its representatives, including, but not limited to, communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Magento for the purpose of discussing, modifying, revising, and improving the Work, including identification of errors and/or issues and the remedy thereof. - </li> - <li> - <strong>"Contributor"</strong>, <strong>"you"</strong>, or <strong>"your"</strong> means the copyright owner or legal entity authorized by the copyright owner that is entering into this Agreement. - </li> - <li> - <strong>"Contributor Affiliate"</strong> means any past, present or future subsidiary, parent company, sister company, or other corporation, firm, business, partnership, joint venture or entity that controls, is controlled by, or is under common control of Contributor or any of its subsidiaries. - </li> - <li> - <strong>"Control"</strong> means (i) the power, direct or indirect, to cause the direction or management of an entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares of an entity, or (iii) beneficial ownership of an entity. - </li> - <li> - <strong>"Magento Affiliate"</strong> means any past, present or future subsidiary, parent company, sister company, or other corporation, firm, business, partnership, joint venture or entity that controls, is controlled by, or is under common control of Magento or any of its subsidiaries. - </li> - </ol> - </li> - <li><strong><u>License Grants:</u></strong> - <ol> - <li><strong>Grant of Copyright License.</strong> Subject to the terms and conditions of this Agreement, Contributor and Contributor Affiliates hereby grant to Magento, Magento Affiliates and all third party recipients of software, services, and all other information distributed by Magento as part of any Magento project, product or service a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Contributions and such derivative works.</li> - <li><strong>Grant of Patent License.</strong> Subject to the terms and conditions of this Agreement, Contributor and Contributor Affiliates hereby grant to Magento, Magento Affiliates, and all third party recipients of software, services, and information distributed by Magento as part of any Magento project, product or service a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Contributions, where such license applies only to those patent claims licensable by Contributor that are necessarily infringed by Contributions alone or by combination with software and/or information related to any Magento project, product or service.</li> - <li><strong>Grant to Magento and Magento Affiliates.</strong> The rights conferred in this Agreement on Magento shall automatically and immediately extend to any entity that later becomes a Magento Affiliate or a part of Magento.</li> - <li><strong>Contributions.</strong> Contributor agrees to the terms and conditions of this Agreement for present and future Contributions, which Contributor submits to Magento. Except for the licenses granted herein, Contributor reserves all right, title, and interest in and to Contributor Contributions.</li> - </ol> - </li> - <li> - <strong><u>Representations:</u></strong> - <ol> - <li><strong>Original Work.</strong> Contributor represents that each Contribution is Contributor’s own original creation and that Contributor is the copyright owner or legal entity authorized by the copyright owner of all Contributions.</li> - <li><strong>Ownership and Authority.</strong> Contributor represents that it is legally entitled to grant the licenses above and that the Contributions do not include any third party copyrights, patents, trade secrets, licenses, or other restrictions ("Third Party IP"), and that Contributor will not declare any dependencies on any open source projects, proprietary software or Third Party IP, unless Contributor has made a Complete Disclosure prior to or at the time of the Contribution submission.</li> - <li><strong>Complete Disclosure.</strong> If applicable, Contributor represents that each and every Contribution submission includes complete details of any third-party license or other restrictions associated with any part of the Contribution.</li> - <li><strong>Support.</strong> Contributor is not expected to provide support for Contributions, except to the extent Contributor desires to provide support. Contributor may provide support for free, for a fee, or not at all.</li> - <li><strong>Notification of any Change.</strong> You agree to notify Magento if any of the facts, circumstances or representations made herein are or become inaccurate in any respect.</li> - </ol> - </li> - <li> - <strong><u>General:</u></strong> - <ol> - <li><strong>Waiver.</strong> Contributor waives all other claims of any nature, including express contract, implied-in-fact contract, or quasi-contract, arising out of any disclosure of the Contributions to Magento. As such, Magento is under no obligation to use or implement the Contributions in any respect.</li> - <li><strong>Competitive or Similar Materials.</strong> In no event shall Magento or Magento Affiliates be precluded from discussing, reviewing, developing for itself, having developed, or developing for third parties, materials which are competitive with those set forth in the Contributions irrespective of their similarity to the information in the Contributions, so long as Magento complies with the terms of this Agreement.</li> - <li><strong>Term.</strong> This Agreement shall remain in effect for a period of five (5) years from the Effective Date or until termination in writing by either party is delivered to the other party.</li> - <li><strong>Governing Law.</strong> This Agreement will be construed as if both parties jointly wrote it, governed by California law except for its conflicts of laws principles, and any cause of action arising under or relating to this Agreement must be brought exclusively in a court in Santa Clara County, California. </li> - <li><strong>Survival.</strong> Upon termination or expiration of this Agreement, all terms of the Agreement, including the license grants, shall remain in full force and effect, except that Contributor will no longer make submissions to Magento.</li> - </ol> - </li> -</ol> -<p><strong>IN WITNESS WHEREOF,</strong> the Parties have caused this Agreement to be executed by their duly authorized representatives as of the Effective Date.</p> -<table border="0" width="100%"> - <tr> - <td width="9%"><strong>Magento, Inc.</strong></td> - <td width="15%"></td> - <td width="6%"></td> - <td width="9%"></td> - <td width="15%"><strong>Contributor</strong><br> - </tr> - <tr> - <td>By:</td> - <td><hr></td> - <td></td> - <td>By:</td> - <td><hr></td> - </tr> - <td>Name:</td> - <td><hr></td> - <td></td> - <td>Name:</td> - <td><hr></td> - </tr> - <tr> - <td>Title:</td> - <td><hr></td> - <td></td> - <td>Title:</td> - <td><hr></td> -</table> -</div> -</body> -</html> \ No newline at end of file diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index 834fb0446dc02f1c8a6adbaa9d5cf48d33f4f560..ea51992822d724b98125ac738595e8e0eca5098f 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json index 7df60980708565a5d2eb00b4ee31491064ab9b73..9cf98d75bdd479b55b188252db54714e86d97f53 100644 --- a/app/code/Magento/Authorization/composer.json +++ b/app/code/Magento/Authorization/composer.json @@ -3,12 +3,12 @@ "description": "Authorization module provides access to Magento ACL functionality.", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorization/etc/di.xml b/app/code/Magento/Authorization/etc/di.xml index afd3f40acd4f9919f85b1abff8667d9d2110b568..9dcd8d86a59bbfa6c6d8a49ae2857e69d72ca743 100644 --- a/app/code/Magento/Authorization/etc/di.xml +++ b/app/code/Magento/Authorization/etc/di.xml @@ -44,4 +44,9 @@ <argument name="roleLoader" xsi:type="object">Magento\Authorization\Model\Acl\Loader\Role</argument> </arguments> </type> + <type name="Magento\Framework\Authorization\Policy\Acl"> + <arguments> + <argument name="aclBuilder" xsi:type="object">Magento\Framework\Acl\Builder\Proxy</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment.php index c622ef79399629f06c103824a65e7174a5bd3b74..507ebe70a832ac7457cb25af08a7dd0aeb4fcee2 100644 --- a/app/code/Magento/Authorizenet/Controller/Directpost/Payment.php +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment.php @@ -49,6 +49,13 @@ class Payment extends \Magento\Framework\App\Action\Action parent::__construct($context); } + /** + * @return \Magento\Checkout\Model\Session + */ + protected function _getCheckout() + { + return $this->_objectManager->get('Magento\Checkout\Model\Session'); + } /** * Get session model diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php index c84d04019b706a58d8d8a8363bff0b0e80e115b3..51b335f4c02a21fb1550a7eafcb91e3e0c19ef93 100644 --- a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php @@ -26,13 +26,6 @@ namespace Magento\Authorizenet\Controller\Directpost\Payment; class Place extends \Magento\Authorizenet\Controller\Directpost\Payment { - /** - * @return \Magento\Checkout\Model\Session - */ - protected function _getCheckout() - { - return $this->_objectManager->get('Magento\Checkout\Model\Session'); - } /** * Send request to authorize.net * diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json index d782df28e00dc1230a3c761a5fb31c3e320386c5..4c698ea9a021e440639c6849ba42cd557e8a2eef 100644 --- a/app/code/Magento/Authorizenet/composer.json +++ b/app/code/Magento/Authorizenet/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-centinel": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-centinel": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index aab0a3ebd5fb667ad4fc6d3f2923f723a333b70f..94aebf551dbd798f041bd201ab7e1e4ed68adf4d 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -3,31 +3,28 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-cron": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-weee": "0.1.0-alpha95", - "magento/module-reports": "0.1.0-alpha95", - "magento/module-catalog-search": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-user": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-backup": "0.1.0-alpha95", - "magento/module-email": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-url-rewrite": "0.1.0-alpha95", - "magento/module-translation": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-cron": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-reports": "0.1.0-alpha96", + "magento/module-catalog-search": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-user": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-backup": "0.1.0-alpha96", + "magento/module-email": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-url-rewrite": "0.1.0-alpha96", + "magento/module-translation": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index adff60676d1e66666528b6727fedfc75d5cf37a9..343b3075c39bb12daa614b5cd55e0c470a184f23 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -163,6 +163,7 @@ </virtualType> <type name="Magento\Backend\Model\Auth\Session"> <arguments> + <argument name="aclBuilder" xsi:type="object">Magento\Framework\Acl\Builder\Proxy</argument> <argument name="storage" xsi:type="object">Magento\Backend\Model\Auth\Session\Storage</argument> </arguments> </type> diff --git a/app/code/Magento/Backend/etc/module.xml b/app/code/Magento/Backend/etc/module.xml index a51a0195441ed9e9004344d1a8810f0927158560..b969c2fe61d9287dd8e03a2969424c89e871abda 100644 --- a/app/code/Magento/Backend/etc/module.xml +++ b/app/code/Magento/Backend/etc/module.xml @@ -35,7 +35,6 @@ <module name="Magento_Eav"/> <module name="Magento_Cron"/> <module name="Magento_Theme"/> - <module name="Magento_Weee"/> <module name="Magento_Reports"/> <module name="Magento_CatalogSearch"/> <module name="Magento_Sales"/> @@ -45,8 +44,6 @@ <module name="Magento_Backup"/> <module name="Magento_Email"/> <module name="Magento_Customer"/> - <module name="Magento_Tax"/> - <module name="Magento_Checkout"/> <module name="Magento_UrlRewrite"/> <module name="Magento_Translation"/> </depends> diff --git a/app/code/Magento/Backend/view/adminhtml/templates/email/order/items.phtml b/app/code/Magento/Backend/view/adminhtml/templates/email/order/items.phtml deleted file mode 100644 index 440c8cf52357c7f0bf2926bcae4b2983b2d9c7be..0000000000000000000000000000000000000000 --- a/app/code/Magento/Backend/view/adminhtml/templates/email/order/items.phtml +++ /dev/null @@ -1,148 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -?> -<?php $_order=$this->getOrder() ?> -<table cellspacing="0" cellpadding="0" border="0" width="100%" style="border:1px solid #bebcb7; background:#f8f7f5;"> - <thead> - <tr> - <th class="a-left" bgcolor="#d9e5ee" style="padding:3px 9px">Item</th> - <th class="a-center" bgcolor="#d9e5ee" style="padding:3px 9px">Qty</th> - <th class="a-right" bgcolor="#d9e5ee" style="padding:3px 9px">Subtotal</th> - </tr> - </thead> - - <tbody> -<?php $i=0; foreach ($_order->getAllItems() as $_item): $i++ ?> - <tr <?php echo $i%2?'bgcolor="#eeeded"':'' ?>> - <td align="left" valign="top" style="padding:3px 9px"><?php echo $_item->getName() ?></td> - <td align="center" valign="top" style="padding:3px 9px"><?php echo sprintf('%s', $_item->getQtyOrdered()) ?></td> - <td align="right" valign="top" style="padding:3px 9px"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - </td> - </tr> -<?php endforeach ?> - </tbody> - - <tfoot> - <tr> - <td colspan="2" align="right" style="padding:3px 9px"><?php echo __('Subtotal') ?></td> - <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getSubtotal()) ?></td> - </tr> - <?php if ($_order->getDiscountAmount()): ?> - <tr> - <td colspan="2" align="right" style="padding:3px 9px"><?php echo __('Discount') ?></td> - <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getDiscountAmount()) ?></td> - </tr> - <?php endif; ?> - <?php if ($_order->getShippingAmount()): ?> - <tr> - <td colspan="2" align="right" style="padding:3px 9px"><?php echo __('Shipping Amount') ?></td> - <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getShippingAmount()) ?></td> - </tr> - <?php endif; ?> - <?php if ($_order->getTaxAmount()): ?> - <tr> - <td colspan="2" align="right" style="padding:3px 9px"><?php echo __('Tax Amount') ?></td> - <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getTaxAmount()) ?></td> - </tr> - <?php endif; ?> - <tr bgcolor="#DEE5E8"> - <td colspan="2" align="right" style="padding:3px 9px"><strong><big><?php echo __('Grand Total') ?></big></strong></td> - <td align="right" style="padding:6px 9px"><strong><big><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></big></strong></td> - </tr> - </tfoot> - -</table> diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index fc9af6761dfd6c0559ace8844836fae73ea72f9c..4eed44f1c19a1a7b7a3badd250ba113040241620 100644 --- a/app/code/Magento/Backup/composer.json +++ b/app/code/Magento/Backup/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-cron": "0.1.0-alpha95", - "magento/module-index": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-cron": "0.1.0-alpha96", + "magento/module-index": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php b/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php index 9c00d568c8af39908bfcd32ab4e012543a5ea149..f37b1d3f06aa4da4701013fe3b2f697480823361 100644 --- a/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php +++ b/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php @@ -24,6 +24,7 @@ namespace Magento\Bundle\Block\Checkout\Cart\Item; use Magento\Bundle\Helper\Catalog\Product\Configuration; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Shopping cart item render block @@ -51,6 +52,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer * @param \Magento\Catalog\Helper\Image $imageHelper * @param \Magento\Core\Helper\Url $urlHelper * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param PriceCurrencyInterface $priceCurrency * @param Configuration $bundleProdConfigur * @param array $data */ @@ -61,6 +63,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer \Magento\Catalog\Helper\Image $imageHelper, \Magento\Core\Helper\Url $urlHelper, \Magento\Framework\Message\ManagerInterface $messageManager, + PriceCurrencyInterface $priceCurrency, Configuration $bundleProdConfigur, array $data = array() ) { @@ -72,6 +75,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer $imageHelper, $urlHelper, $messageManager, + $priceCurrency, $data ); $this->_isScopePrivate = true; diff --git a/app/code/Magento/Bundle/Model/Product/Price.php b/app/code/Magento/Bundle/Model/Product/Price.php index d0cb54b895343f298d78a4d499ebf465f30b9a25..fb2734bec89a7c51e634b9ba7c4a8c6a9b011f58 100644 --- a/app/code/Magento/Bundle/Model/Product/Price.php +++ b/app/code/Magento/Bundle/Model/Product/Price.php @@ -25,6 +25,7 @@ namespace Magento\Bundle\Model\Product; use Magento\Customer\Service\V1\CustomerGroupServiceInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Bundle Price Model @@ -56,13 +57,12 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price protected $_catalogData = null; /** - * Construct - * * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Catalog\Helper\Data $catalogData */ public function __construct( @@ -71,10 +71,11 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Event\ManagerInterface $eventManager, + PriceCurrencyInterface $priceCurrency, \Magento\Catalog\Helper\Data $catalogData ) { $this->_catalogData = $catalogData; - parent::__construct($ruleFactory, $storeManager, $localeDate, $customerSession, $eventManager); + parent::__construct($ruleFactory, $storeManager, $localeDate, $customerSession, $eventManager, $priceCurrency); } /** diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index 09d31b722ccedde183985740a770decdc5df5fbe..9b202cfc27d153dfd837e67d7a8374981bf8e898 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -23,6 +23,8 @@ */ namespace Magento\Bundle\Model\Product; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Bundle Type Model */ @@ -134,8 +136,11 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType protected $_bundleModelSelection; /** - * Construct - * + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Product\Option $catalogProductOption * @param \Magento\Eav\Model\Config $eavConfig @@ -155,6 +160,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType * @param \Magento\Bundle\Model\Resource\Selection $bundleSelection * @param \Magento\Bundle\Model\OptionFactory $bundleOption * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param PriceCurrencyInterface $priceCurrency * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -179,6 +185,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType \Magento\Bundle\Model\Resource\Selection $bundleSelection, \Magento\Bundle\Model\OptionFactory $bundleOption, \Magento\Framework\StoreManagerInterface $storeManager, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { $this->_catalogProduct = $catalogProduct; @@ -190,6 +197,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType $this->_bundleCollection = $bundleCollection; $this->_bundleFactory = $bundleFactory; $this->_bundleModelSelection = $bundleModelSelection; + $this->priceCurrency = $priceCurrency; parent::__construct( $productFactory, $catalogProductOption, @@ -771,7 +779,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType */ $price = $product->getPriceModel()->getSelectionFinalTotalPrice($product, $selection, 0, $qty); $attributes = array( - 'price' => $this->_storeManager->getStore()->convertPrice($price), + 'price' => $this->priceCurrency->convert($price), 'qty' => $qty, 'option_label' => $selection->getOption()->getTitle(), 'option_id' => $selection->getOption()->getId() @@ -930,7 +938,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType $bundleOptions[$option->getId()]['value'][] = array( 'title' => $selection->getName(), 'qty' => $selectionQty->getValue(), - 'price' => $this->_storeManager->getStore()->convertPrice($price) + 'price' => $this->priceCurrency->convert($price) ); } } diff --git a/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php b/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php index 5cd71e56ce9ac1f7e84c9a45615054a7c5e6b9c6..15650e0e388745c45e623686308ccb440fd4ed7c 100644 --- a/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php +++ b/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php @@ -31,6 +31,7 @@ use Magento\Bundle\Pricing\Price\BundleSelectionFactory; use Magento\Framework\Pricing\Adjustment\Calculator as CalculatorBase; use Magento\Bundle\Model\Product\Price; use Magento\Bundle\Pricing\Price\BundleOptionPrice; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Tax\Service\V1\TaxCalculationServiceInterface; use Magento\Store\Model\Store; use Magento\Tax\Helper\Data as TaxHelper; @@ -61,23 +62,31 @@ class Calculator implements BundleCalculatorInterface * @var TaxHelper */ protected $taxHelper; + + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param CalculatorBase $calculator * @param AmountFactory $amountFactory * @param BundleSelectionFactory $bundleSelectionFactory * @param TaxHelper $taxHelper - * @return Calculator + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( CalculatorBase $calculator, AmountFactory $amountFactory, BundleSelectionFactory $bundleSelectionFactory, - TaxHelper $taxHelper + TaxHelper $taxHelper, + PriceCurrencyInterface $priceCurrency ) { $this->calculator = $calculator; $this->amountFactory = $amountFactory; $this->selectionFactory = $bundleSelectionFactory; $this->taxHelper = $taxHelper; + $this->priceCurrency = $priceCurrency; } /** @@ -86,9 +95,10 @@ class Calculator implements BundleCalculatorInterface * @param float|string $amount * @param SaleableInterface $saleableItem * @param null|string $exclude + * @param null|array $context * @return \Magento\Framework\Pricing\Amount\AmountInterface */ - public function getAmount($amount, SaleableInterface $saleableItem, $exclude = null) + public function getAmount($amount, SaleableInterface $saleableItem, $exclude = null, $context = []) { return $this->getOptionsAmount($saleableItem, $exclude, true, $amount); } @@ -273,9 +283,9 @@ class Calculator implements BundleCalculatorInterface foreach ($amountList as $itemAmount) { if ($roundingMethod != TaxCalculationServiceInterface::CALC_TOTAL_BASE) { //We need to round the individual selection first - $fullAmount += $store->roundPrice($itemAmount->getValue()); + $fullAmount += $this->priceCurrency->round($itemAmount->getValue()); foreach ($itemAmount->getAdjustmentAmounts() as $code => $adjustment) { - $adjustment = $store->roundPrice($adjustment); + $adjustment = $this->priceCurrency->round($adjustment); $adjustments[$code] = isset($adjustments[$code]) ? $adjustments[$code] + $adjustment : $adjustment; } } else { diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index c2f9926dbc165837e84ba0b7bd7610f7ea9e1332..4f6e16b7f09c5c530833d6e1a3b3d30eb988bd4c 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-catalog-rule": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-gift-message": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", - "magento/module-webapi": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-catalog-rule": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-gift-message": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/module-webapi": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Bundle/etc/di.xml b/app/code/Magento/Bundle/etc/di.xml index 6275f1d413cdc2071999e6569c9af52168037a82..8b75bdd1c7588d53a7d973475b6c870d2c57d035 100644 --- a/app/code/Magento/Bundle/etc/di.xml +++ b/app/code/Magento/Bundle/etc/di.xml @@ -54,12 +54,6 @@ </arguments> </type> <virtualType name="Magento\Bundle\Pricing\Adjustment\Collection" type="Magento\Framework\Pricing\Adjustment\Collection"> - <arguments> - <argument name="adjustments" xsi:type="array"> - <item name="tax" xsi:type="const">Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE</item> - <item name="weee" xsi:type="const">Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE</item> - </argument> - </arguments> </virtualType> <preference for="Magento\Bundle\Pricing\Adjustment\BundleCalculatorInterface" type="Magento\Bundle\Pricing\Adjustment\Calculator" /> <virtualType name="Magento\Bundle\Pricing\PriceInfo" type="Magento\Framework\Pricing\PriceInfo\Base"> diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml index c7d8dc29e27aad7f9959fd3cde00917b5629d60d..2ad9953d90dadcd4d2c25c72184c8ed6ac21767b 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml @@ -117,12 +117,6 @@ <?php endif; ?> </td> - <?php /* if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <th class="a-right"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?></th> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <th class="a-right"><?php echo $this->getOrder()->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem())); ?></th> - <?php endif; */ ?> </tr> <?php endforeach; ?> <?php if ($_showlastRow): ?> diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index 88d0306418ca12a09e8357a56f970a9c631a5a47..86facba5ec5cd6624669311f85fead10734f781f 100644 --- a/app/code/Magento/Captcha/composer.json +++ b/app/code/Magento/Captcha/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/Block/Product.php b/app/code/Magento/Catalog/Block/Product.php deleted file mode 100644 index e74f71abb7f68e0c8a588cc3a97d598411f90cdd..0000000000000000000000000000000000000000 --- a/app/code/Magento/Catalog/Block/Product.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Catalog\Block; - -use Magento\Catalog\Model\Product as ModelProduct; - -class Product extends \Magento\Framework\View\Element\Template -{ - /** - * @var array - */ - protected $_finalPrice = array(); - - /** - * Product factory - * - * @var \Magento\Catalog\Model\ProductFactory - */ - protected $_productFactory; - - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Catalog\Model\ProductFactory $productFactory, - array $data = array() - ) { - $this->_productFactory = $productFactory; - parent::__construct($context, $data); - } - - /** - * @return ModelProduct - */ - public function getProduct() - { - if (!$this->getData('product') instanceof ModelProduct) { - if ($this->getData('product')->getProductId()) { - $productId = $this->getData('product')->getProductId(); - } - if ($productId) { - $product = $this->_productFactory->create()->load($productId); - if ($product) { - $this->setProduct($product); - } - } - } - return $this->getData('product'); - } - - /** - * @return float - */ - public function getPrice() - { - return $this->getProduct()->getPrice(); - } - - /** - * @return float - */ - public function getFinalPrice() - { - if (!isset($this->_finalPrice[$this->getProduct()->getId()])) { - $this->_finalPrice[$this->getProduct()->getId()] = $this->getProduct()->getFinalPrice(); - } - return $this->_finalPrice[$this->getProduct()->getId()]; - } - - /** - * @param ModelProduct $product - * @return string - */ - public function getPriceHtml($product) - { - $this->setTemplate('product/price.phtml'); - $this->setProduct($product); - return $this->toHtml(); - } -} diff --git a/app/code/Magento/Catalog/Block/Product/View/Attributes.php b/app/code/Magento/Catalog/Block/Product/View/Attributes.php index ced9eb0a98ddc7a126cd168bb5400b4876f546be..c4a77d187ba1bc7f75ab4fc897e74abd743bb802 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Attributes.php +++ b/app/code/Magento/Catalog/Block/Product/View/Attributes.php @@ -31,6 +31,7 @@ namespace Magento\Catalog\Block\Product\View; use Magento\Catalog\Model\Product; +use Magento\Framework\Pricing\PriceCurrencyInterface; class Attributes extends \Magento\Framework\View\Element\Template { @@ -46,16 +47,24 @@ class Attributes extends \Magento\Framework\View\Element\Template */ protected $_coreRegistry = null; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Registry $registry + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_coreRegistry = $registry; parent::__construct($context, $data); } @@ -92,7 +101,7 @@ class Attributes extends \Magento\Framework\View\Element\Template } elseif ((string)$value == '') { $value = __('No'); } elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) { - $value = $this->_storeManager->getStore()->convertPrice($value, true); + $value = $this->priceCurrency->convertAndFormat($value); } if (is_string($value) && strlen($value)) { diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php index 817eecc34a839838624136e09369570a7a9c3264..d67e78349fb5ee37c4d9c1bfee08d1edbe6f1132 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php @@ -30,6 +30,8 @@ */ namespace Magento\Catalog\Block\Product\View\Options; +use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface; + abstract class AbstractOptions extends \Magento\Framework\View\Element\Template { /** @@ -155,7 +157,8 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template $priceStr = $sign; $customOptionPrice = $this->getProduct()->getPriceInfo()->getPrice('custom_option_price'); - $optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value']); + $context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true]; + $optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context); $priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount( $optionAmount, $customOptionPrice, diff --git a/app/code/Magento/Catalog/Helper/Data.php b/app/code/Magento/Catalog/Helper/Data.php index 0faa685c3dcf68aa8eb5be8252121fdcb4caec88..1e21a3a8de9c0a6f71d904ae267a998d35e660ca 100644 --- a/app/code/Magento/Catalog/Helper/Data.php +++ b/app/code/Magento/Catalog/Helper/Data.php @@ -24,6 +24,7 @@ namespace Magento\Catalog\Helper; use Magento\Catalog\Model\Product\Attribute\Source\Msrp\Type; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Tax\Service\V1\Data\QuoteDetailsBuilder; use Magento\Tax\Service\V1\Data\QuoteDetails\ItemBuilder as QuoteDetailsItemBuilder; use Magento\Tax\Service\V1\Data\TaxClassKey; @@ -222,6 +223,13 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ protected $_taxCalculationService; + /** + * Price currency + * + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Catalog\Model\Resource\Eav\AttributeFactory $eavAttributeFactory @@ -237,13 +245,14 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Catalog\Model\Template\Filter\Factory $templateFilterFactory * @param \Magento\Framework\Escaper $escaper * @param string $templateFilterModel - * @param \Magento\Tax\Service\V1\Data\TaxClassKeyBuilder $taxClassKeyBuilder - * @param \Magento\Tax\Model\Config $taxConfig + * @param TaxClassKeyBuilder $taxClassKeyBuilder + * @param Config $taxConfig * @param QuoteDetailsBuilder $quoteDetailsBuilder * @param QuoteDetailsItemBuilder $quoteDetailsItemBuilder - * @param \Magento\Tax\Service\V1\TaxCalculationServiceInterface $taxCalculationService + * @param TaxCalculationServiceInterface $taxCalculationService * @param CustomerSession $customerSession * @param AddressConverter $addressConverter + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\Framework\App\Helper\Context $context, @@ -266,7 +275,8 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper QuoteDetailsItemBuilder $quoteDetailsItemBuilder, \Magento\Tax\Service\V1\TaxCalculationServiceInterface $taxCalculationService, CustomerSession $customerSession, - AddressConverter $addressConverter + AddressConverter $addressConverter, + PriceCurrencyInterface $priceCurrency ) { $this->_eavAttributeFactory = $eavAttributeFactory; $this->_categoryFactory = $categoryFactory; @@ -288,6 +298,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper $this->_taxCalculationService = $taxCalculationService; $this->_customerSession = $customerSession; $this->_addressConverter = $addressConverter; + $this->priceCurrency = $priceCurrency; parent::__construct($context); } @@ -806,7 +817,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper } if ($roundPrice) { - return $store->roundPrice($price); + return $this->priceCurrency->round($price); } else { return $price; } diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php b/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php index c14a9b5b64c3124c7c315d47b89135d0ce6a358d..9e2bc26c6c05fb9f72f9b35105b902d5b5b66585 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php @@ -42,12 +42,16 @@ class Decimal extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter protected $_resource; /** - * Construct - * - * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + + /** + * @param ItemFactory $filterItemFactory * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Resource\Layer\Filter\DecimalFactory $filterDecimalFactory + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( @@ -55,10 +59,12 @@ class Decimal extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\Resource\Layer\Filter\DecimalFactory $filterDecimalFactory, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, array $data = array() ) { $this->_resource = $filterDecimalFactory->create(); $this->_requestVar = 'decimal'; + $this->priceCurrency = $priceCurrency; parent::__construct($filterItemFactory, $storeManager, $layer, $data); } @@ -130,8 +136,8 @@ class Decimal extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ protected function _renderItemLabel($range, $value) { - $from = $this->_storeManager->getStore()->formatPrice(($value - 1) * $range, false); - $to = $this->_storeManager->getStore()->formatPrice($value * $range, false); + $from = $this->priceCurrency->format(($value - 1) * $range, false); + $to = $this->priceCurrency->format($value * $range, false); return __('%1 - %2', $from, $to); } diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/Layer/Filter/Price.php index f926f6f0b782483325a9822e494c779593c81bd0..cd4dd4894ec25f574dd627cce8ba748a0a3d5d26 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Price.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Price.php @@ -93,14 +93,20 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter protected $_scopeConfig; /** - * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + + /** + * @param ItemFactory $filterItemFactory * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Resource\Layer\Filter\PriceFactory $filterPriceFactory * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Catalog\Model\Layer\Filter\Price\Algorithm $priceAlgorithm + * @param Price\Algorithm $priceAlgorithm * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( @@ -112,8 +118,10 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter \Magento\Catalog\Model\Layer\Filter\Price\Algorithm $priceAlgorithm, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_resource = $filterPriceFactory->create(); $this->_customerSession = $customerSession; $this->_priceAlgorithm = $priceAlgorithm; @@ -238,9 +246,8 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ protected function _renderItemLabel($range, $value) { - $store = $this->_storeManager->getStore(); - $fromPrice = $store->formatPrice(($value - 1) * $range); - $toPrice = $store->formatPrice($value * $range); + $fromPrice = $this->priceCurrency->format(($value - 1) * $range); + $toPrice = $this->priceCurrency->format($value * $range); return __('%1 - %2', $fromPrice, $toPrice); } @@ -254,8 +261,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ protected function _renderRangeLabel($fromPrice, $toPrice) { - $store = $this->_storeManager->getStore(); - $formattedFromPrice = $store->formatPrice($fromPrice); + $formattedFromPrice = $this->priceCurrency->format($fromPrice); if ($toPrice === '') { return __('%1 and above', $formattedFromPrice); } elseif ($fromPrice == $toPrice && $this->_scopeConfig->getValue( @@ -268,7 +274,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter if ($fromPrice != $toPrice) { $toPrice -= .01; } - return __('%1 - %2', $formattedFromPrice, $store->formatPrice($toPrice)); + return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice)); } } diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price.php b/app/code/Magento/Catalog/Model/Product/Type/Price.php index 59ebb2e3fd7d04a2a26146b78f49bc8e695e74bb..a56056a33f535b54f3a2bd383e930227a1dc12b2 100755 --- a/app/code/Magento/Catalog/Model/Product/Type/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Price.php @@ -26,6 +26,7 @@ namespace Magento\Catalog\Model\Product\Type; use Magento\Catalog\Model\Product; use Magento\Store\Model\Store; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Product type price model @@ -76,26 +77,32 @@ class Price protected $_ruleFactory; /** - * Construct - * + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, - \Magento\Framework\Event\ManagerInterface $eventManager + \Magento\Framework\Event\ManagerInterface $eventManager, + PriceCurrencyInterface $priceCurrency ) { $this->_ruleFactory = $ruleFactory; $this->_storeManager = $storeManager; $this->_localeDate = $localeDate; $this->_customerSession = $customerSession; $this->_eventManager = $eventManager; + $this->priceCurrency = $priceCurrency; } /** @@ -383,13 +390,12 @@ class Price $price = $product->getTierPrice($qty); if (is_array($price)) { foreach (array_keys($price) as $index) { - $price[$index]['formated_price'] = $this->_storeManager->getStore()->convertPrice( - $price[$index]['website_price'], - true + $price[$index]['formated_price'] = $this->priceCurrency->convertAndFormat( + $price[$index]['website_price'] ); } } else { - $price = $this->_storeManager->getStore()->formatPrice($price); + $price = $this->priceCurrency->format($price); } return $price; @@ -403,7 +409,7 @@ class Price */ public function getFormatedPrice($product) { - return $this->_storeManager->getStore()->formatPrice($product->getFinalPrice()); + return $this->priceCurrency->format($product->getFinalPrice()); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php index 37d073c47f1f9fd69897065281fc348f3fd07556..a4a2f008a5611fc838495e2e958d6f89b07cc0cc 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php @@ -209,9 +209,9 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl /** * Catalog data * - * @var \Magento\Catalog\Helper\Data + * @var \Magento\Framework\Module\Manager */ - protected $_catalogData = null; + protected $moduleManager = null; /** * Core store config @@ -269,7 +269,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -292,7 +292,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -302,7 +302,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl \Magento\Framework\Stdlib\DateTime $dateTime, $connection = null ) { - $this->_catalogData = $catalogData; + $this->moduleManager = $moduleManager; $this->_catalogProductFlatState = $catalogProductFlatState; $this->_scopeConfig = $scopeConfig; $this->_productOptionFactory = $productOptionFactory; @@ -1346,7 +1346,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl return $this; } - if (!$this->_catalogData->isModuleEnabled('Magento_CatalogRule')) { + if (!$this->moduleManager->isEnabled('Magento_CatalogRule')) { return $this; } $wId = $this->_storeManager->getWebsite()->getId(); diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php index fc09bc0848d845209138fff668e5698c1fc34112..fbdee28a69e73219211d319a507cbccb432a1b50 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php @@ -77,7 +77,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -102,7 +102,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -127,7 +127,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/Catalog/Pricing/Price/CustomOptionPriceInterface.php b/app/code/Magento/Catalog/Pricing/Price/CustomOptionPriceInterface.php index 1619e8a2af9d8a9f9d4c0214e768b05aa8110a1d..e4dbe48e647e3882a5c947758801ce29c8b2f26f 100644 --- a/app/code/Magento/Catalog/Pricing/Price/CustomOptionPriceInterface.php +++ b/app/code/Magento/Catalog/Pricing/Price/CustomOptionPriceInterface.php @@ -28,6 +28,11 @@ namespace Magento\Catalog\Pricing\Price; */ interface CustomOptionPriceInterface { + /** + * Flag to indicate the price is for configuration option of a product + */ + const CONFIGURATION_OPTION_FLAG = 'configuration_option_flag'; + /** * Return calculated options * diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index f655a3900de92fbe4c114a3d811501d06a4083d8..fc9c4e764d0cbe8db50582e790a6eea0c8d35ab8 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -3,33 +3,33 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-index": "0.1.0-alpha95", - "magento/module-indexer": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-log": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-widget": "0.1.0-alpha95", - "magento/module-wishlist": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-bundle": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-catalog-rule": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-catalog-search": "0.1.0-alpha95", - "magento/module-product-alert": "0.1.0-alpha95", - "magento/module-url-rewrite": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-index": "0.1.0-alpha96", + "magento/module-indexer": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-log": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-widget": "0.1.0-alpha96", + "magento/module-wishlist": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-bundle": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-catalog-rule": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-catalog-search": "0.1.0-alpha96", + "magento/module-product-alert": "0.1.0-alpha96", + "magento/module-url-rewrite": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index a0f16e2eef3febc6880fde00936bbb2a5fb42fba..455ad2b273b08ed260cfb743b9a2532132ba3c1b 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -356,12 +356,6 @@ </arguments> </type> <type name="Magento\Framework\Pricing\Adjustment\Collection"> - <arguments> - <argument name="adjustments" xsi:type="array"> - <item name="tax" xsi:type="const">Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE</item> - <item name="weee" xsi:type="const">Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE</item> - </argument> - </arguments> </type> <type name="Magento\Catalog\Model\Product\ReservedAttributeList"> <arguments> @@ -487,6 +481,21 @@ <argument name="searchResultsBuilder" xsi:type="object" shared="false">Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder</argument> </arguments> </type> + <type name="Magento\Catalog\Model\ProductTypes\Config"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Catalog\Model\ProductTypes\Config\Reader\Proxy</argument> + </arguments> + </type> + <type name="Magento\Catalog\Model\Attribute\Config\Data"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Catalog\Model\Attribute\Config\Reader\Proxy</argument> + </arguments> + </type> + <type name="Magento\Catalog\Model\ProductOptions\Config"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Catalog\Model\ProductOptions\Config\Reader\Proxy</argument> + </arguments> + </type> <type name="Magento\CatalogInventory\Model\Config\Backend\ShowOutOfStock"> <plugin name="showOutOfStockValueChanged" type="\Magento\Catalog\Model\Plugin\ShowOutOfStockConfig"/> </type> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/view/items/renderer/downloadable.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/default.phtml similarity index 52% rename from app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/view/items/renderer/downloadable.phtml rename to app/code/Magento/Catalog/view/base/templates/product/price/default.phtml index 21e394e3e56ce8a10edc436524743462cc4b1326..73d3208fe2ac7edf0137f44579937113a028ad97 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/view/items/renderer/downloadable.phtml +++ b/app/code/Magento/Catalog/view/base/templates/product/price/default.phtml @@ -22,21 +22,17 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> -<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> -<?php $_item = $this->getItem() ?> -<?php $this->setPriceDataObject($_item) ?> -<tr class="border"> - <td class="col-product"><?php echo $this->getColumnHtml($_item, 'downloadable') ?></td> - <td class="col-price"> - <?php echo $this->getColumnHtml($_item, 'price')?> - </td> - <td class="col-qty"><?php echo $_item->getQty()*1 ?></td> - <td class="col-subtotal"> - <?php echo $this->getColumnHtml($_item, 'subtotal')?> - </td> - <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> - <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> - <td class="col-total last"> - <?php echo $this->getColumnHtml($_item, 'total')?> - </td> -</tr> + +<?php +/** @var \Magento\Catalog\Pricing\Render\FinalPriceBox $this */ + +$productId = $this->getSaleableItem()->getId(); + +/** @var \Magento\Catalog\Pricing\Price\RegularPrice $priceModel */ +$priceModel = $this->getPriceType('regular_price'); + +echo $this->renderAmount($priceModel->getAmount(), [ + 'price_id' => $this->getPriceId('product-price-'), + 'include_container' => true +]); +?> diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index 9715aa6300f3a13a10ce902857293197406777b0..225fc03887cf73acd91d5cae7a65a1d0c3a9e1f9 100644 --- a/app/code/Magento/CatalogImportExport/composer.json +++ b/app/code/Magento/CatalogImportExport/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-import-export": "0.1.0-alpha95", - "magento/module-indexer": "0.1.0-alpha95", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-import-export": "0.1.0-alpha96", + "magento/module-indexer": "0.1.0-alpha96", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index ad583e88628a2bee5c7d7edf5c2bdf2a9f13891e..47e034652f7ed79fd858424536812be8ec3b4342 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-indexer": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-indexer": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule.php b/app/code/Magento/CatalogRule/Model/Resource/Rule.php index 1b4315961fe35feb647e122b74558be5a18d46fb..4640667f039827811edfc857a4268c0368e2913e 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule.php @@ -33,7 +33,7 @@ namespace Magento\CatalogRule\Model\Resource; use Magento\Catalog\Model\Product; use Magento\CatalogRule\Model\Rule as ModelRule; use Magento\Framework\Model\AbstractModel; -use Magento\Framework\Model\Resource\Db\AbstractDb; +use Magento\Framework\Pricing\PriceCurrencyInterface; class Rule extends \Magento\Rule\Model\Resource\AbstractResource { @@ -104,16 +104,22 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource */ protected $dateTime; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Model\Product\ConditionFactory $conditionFactory + * @param Product\ConditionFactory $conditionFactory * @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\CatalogRule\Helper\Data $catalogRuleData * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\Framework\App\Resource $resource, @@ -124,7 +130,8 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\CatalogRule\Helper\Data $catalogRuleData, \Magento\Framework\Logger $logger, - \Magento\Framework\Stdlib\DateTime $dateTime + \Magento\Framework\Stdlib\DateTime $dateTime, + PriceCurrencyInterface $priceCurrency ) { $this->_storeManager = $storeManager; $this->_conditionFactory = $conditionFactory; @@ -134,6 +141,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource $this->_catalogRuleData = $catalogRuleData; $this->_logger = $logger; $this->dateTime = $dateTime; + $this->priceCurrency = $priceCurrency; parent::__construct($resource); } @@ -663,7 +671,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource $productPrice ); - return $this->_storeManager->getStore()->roundPrice($productPrice); + return $this->priceCurrency->round($productPrice); } /** diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index 0d81e595a2642fbaa385951dcf7e374b0f450c23..dae73d4f51700ec22a649d224c46a849e6f336b3 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-rule": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-index": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-rule": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-index": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php index 7ae849cf2a8b61047239495fb67548977bb0e0b8..87c59349195d03be6f272fb1d30cf51be146c7da 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php @@ -23,6 +23,8 @@ */ namespace Magento\CatalogSearch\Model\Indexer\Fulltext\Action; +use Magento\Framework\Pricing\PriceCurrencyInterface; + class Full { /** @@ -144,6 +146,11 @@ class Full */ protected $fulltextResource; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -159,6 +166,7 @@ class Full * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\Framework\App\Resource $resource, @@ -174,7 +182,8 @@ class Full \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, - \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource + \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource, + PriceCurrencyInterface $priceCurrency ) { $this->resource = $resource; $this->catalogProductType = $catalogProductType; @@ -190,6 +199,7 @@ class Full $this->localeResolver = $localeResolver; $this->localeDate = $localeDate; $this->fulltextResource = $fulltextResource; + $this->priceCurrency = $priceCurrency; } /** @@ -746,7 +756,7 @@ class Full } else { $inputType = $attribute->getFrontend()->getInputType(); if ($inputType == 'price') { - $value = $this->storeManager->getStore($storeId)->roundPrice($value); + $value = $this->priceCurrency->round($value); } } diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php index e587c54cb600c2dde934fcf3bac7fe4c8b85022b..15da583d8161c172de16f03ea5c55af170267ffb 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php @@ -50,7 +50,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager, * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -74,7 +74,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -97,7 +97,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php index d1d13e6386878f1fafc9e72df369bc68f7380345..c8856a0521babd88d7e089ae49d860c0c834f2c4 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php @@ -55,7 +55,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -80,7 +80,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -105,7 +105,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php index 3644db6635e673500862d41d49339b0545597b33..333f72508f40ecdeab52003f9c05b9b47a6cfd06 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php @@ -62,7 +62,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -86,7 +86,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -109,7 +109,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index 78c0be37f47fce993497e559c7c10106e01acdae..89ad0c2cc7195b7599f62d0da57effb0073d56fa 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-indexer": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-indexer": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index ddac15070653c4c57bac7b736156829113fb5aa0..5eecd5076d81063db23eb3dc096ab06e1aeae2b3 100644 --- a/app/code/Magento/CatalogUrlRewrite/composer.json +++ b/app/code/Magento/CatalogUrlRewrite/composer.json @@ -3,14 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-store": "0.1.0-alpha95", - "magento/module-url-redirect": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95" + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-store": "0.1.0-alpha96", + "magento/module-url-redirect": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/composer.json b/app/code/Magento/Centinel/composer.json index 36619e8fb2c0eb10c3170e524cfad819a12445c7..a8e60e9de4a3d49ce70bf5ffd42d5778fcb9d98a 100644 --- a/app/code/Magento/Centinel/composer.json +++ b/app/code/Magento/Centinel/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php b/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php index 1676d1510021e3d9c482c3a0a9afaeac4039f7fa..670dbcb63827c04d6f1303d7590097c6224cafd1 100644 --- a/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php +++ b/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php @@ -23,6 +23,7 @@ */ namespace Magento\Checkout\Block\Cart\Item; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Quote\Item; use Magento\Catalog\Pricing\Price\ConfiguredPriceInterface; @@ -87,6 +88,11 @@ class Renderer extends \Magento\Framework\View\Element\Template implements \Mage */ protected $_imageHelper; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Catalog\Helper\Product\Configuration $productConfig @@ -94,6 +100,7 @@ class Renderer extends \Magento\Framework\View\Element\Template implements \Mage * @param \Magento\Catalog\Helper\Image $imageHelper * @param \Magento\Core\Helper\Url $urlHelper * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( @@ -103,8 +110,10 @@ class Renderer extends \Magento\Framework\View\Element\Template implements \Mage \Magento\Catalog\Helper\Image $imageHelper, \Magento\Core\Helper\Url $urlHelper, \Magento\Framework\Message\ManagerInterface $messageManager, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_imageHelper = $imageHelper; $this->_urlHelper = $urlHelper; $this->_productConfig = $productConfig; @@ -515,9 +524,9 @@ class Renderer extends \Magento\Framework\View\Element\Template implements \Mage */ public function convertPrice($amount, $format = false) { - $store = $this->_storeManager->getStore(); - - return $store->convertPrice($amount, $format); + return $format + ? $this->priceCurrency->convertAndFormat($amount) + : $this->priceCurrency->convert($amount); } /** @@ -596,7 +605,7 @@ class Renderer extends \Magento\Framework\View\Element\Template implements \Mage * @param Item\AbstractItem $item * @return string */ - public function getRowtotalExclTaxHtml(\Magento\Sales\Model\Quote\Item\AbstractItem $item) + public function getRowTotalExclTaxHtml(\Magento\Sales\Model\Quote\Item\AbstractItem $item) { /** @var Renderer $block */ $block = $this->getLayout()->getBlock('checkout.onepage.review.item.price.rowtotal.excl'); @@ -610,7 +619,7 @@ class Renderer extends \Magento\Framework\View\Element\Template implements \Mage * @param Item\AbstractItem $item * @return string */ - public function getRowtotalInclTaxHtml(\Magento\Sales\Model\Quote\Item\AbstractItem $item) + public function getRowTotalInclTaxHtml(\Magento\Sales\Model\Quote\Item\AbstractItem $item) { /** @var Renderer $block */ $block = $this->getLayout()->getBlock('checkout.onepage.review.item.price.rowtotal.incl'); diff --git a/app/code/Magento/Checkout/Block/Cart/Shipping.php b/app/code/Magento/Checkout/Block/Cart/Shipping.php index 0a09072292aeac4209e6108d9ea7c73e004927f7..e28bcf056af1abb1be0af3d653d7f5f9321f21bd 100644 --- a/app/code/Magento/Checkout/Block/Cart/Shipping.php +++ b/app/code/Magento/Checkout/Block/Cart/Shipping.php @@ -23,6 +23,8 @@ */ namespace Magento\Checkout\Block\Cart; +use Magento\Framework\Pricing\PriceCurrencyInterface; + class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart { /** @@ -54,6 +56,11 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart */ protected $_carrierFactory; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Catalog\Helper\Data $catalogData @@ -61,6 +68,7 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Directory\Block\Data $directoryBlock * @param \Magento\Sales\Model\Quote\Address\CarrierFactoryInterface $carrierFactory + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( @@ -70,8 +78,10 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart \Magento\Checkout\Model\Session $checkoutSession, \Magento\Directory\Block\Data $directoryBlock, \Magento\Sales\Model\Quote\Address\CarrierFactoryInterface $carrierFactory, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_directoryBlock = $directoryBlock; $this->_carrierFactory = $carrierFactory; parent::__construct($context, $catalogData, $customerSession, $checkoutSession, $data); @@ -230,7 +240,12 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart */ public function formatPrice($price) { - return $this->getQuote()->getStore()->convertPrice($price, true); + return $this->priceCurrency->convertAndFormat( + $price, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $this->getQuote()->getStore() + ); } /** diff --git a/app/code/Magento/Checkout/Block/Shipping/Price.php b/app/code/Magento/Checkout/Block/Shipping/Price.php index 1e88af05e61980546a8f02b89e5f1fa0a6af6b92..aa28b3e97b6adf873a1d2667b5279186ec9bb328 100644 --- a/app/code/Magento/Checkout/Block/Shipping/Price.php +++ b/app/code/Magento/Checkout/Block/Shipping/Price.php @@ -23,6 +23,7 @@ */ namespace Magento\Checkout\Block\Shipping; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Quote\Address\Rate; use Magento\Checkout\Block\Cart\AbstractCart; @@ -33,6 +34,32 @@ class Price extends AbstractCart */ protected $shippingRate; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param PriceCurrencyInterface $priceCurrency + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Catalog\Helper\Data $catalogData, + \Magento\Customer\Model\Session $customerSession, + \Magento\Checkout\Model\Session $checkoutSession, + PriceCurrencyInterface $priceCurrency, + array $data = array() + ) { + $this->priceCurrency = $priceCurrency; + parent::__construct($context, $catalogData, $customerSession, $checkoutSession, $data); + } + + /** * Set the shipping rate * @@ -62,7 +89,6 @@ class Price extends AbstractCart */ public function getShippingPrice() { - $price = $this->shippingRate->getPrice(); - return $this->getQuote()->getStore()->convertPrice($price, true); + return $this->priceCurrency->convertAndFormat($this->shippingRate->getPrice()); } } diff --git a/app/code/Magento/Checkout/Block/Total/Nominal.php b/app/code/Magento/Checkout/Block/Total/Nominal.php index f717559b107a09c6784aecdbc8593767e82b9d15..8fa54996209629d51f0158e1f077eeeeab51a269 100644 --- a/app/code/Magento/Checkout/Block/Total/Nominal.php +++ b/app/code/Magento/Checkout/Block/Total/Nominal.php @@ -37,6 +37,33 @@ class Nominal extends \Magento\Checkout\Block\Total\DefaultTotal */ protected $_template = 'total/nominal.phtml'; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Sales\Model\Config $salesConfig + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Catalog\Helper\Data $catalogData, + \Magento\Customer\Model\Session $customerSession, + \Magento\Checkout\Model\Session $checkoutSession, + \Magento\Sales\Model\Config $salesConfig, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, + array $data = array() + ) { + $this->priceCurrency = $priceCurrency; + parent::__construct($context, $catalogData, $customerSession, $checkoutSession, $salesConfig, $data); + } + /** * Getter for a quote item name * @@ -111,7 +138,7 @@ class Nominal extends \Magento\Checkout\Block\Total\DefaultTotal */ public function formatPrice($amount) { - return $this->_store->formatPrice($amount, false); + return $this->priceCurrency->format($amount, false); } /** diff --git a/app/code/Magento/Checkout/Helper/Data.php b/app/code/Magento/Checkout/Helper/Data.php index ed2b7264a87da19dd486a26ccf6c46deab9c2465..45a51d6477b2f343fc036bbd6dc6232cb91dc096 100644 --- a/app/code/Magento/Checkout/Helper/Data.php +++ b/app/code/Magento/Checkout/Helper/Data.php @@ -23,6 +23,7 @@ */ namespace Magento\Checkout\Helper; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Store\Model\Store; use Magento\Sales\Model\Quote\Item\AbstractItem; @@ -69,6 +70,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ protected $inlineTranslation; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -77,6 +83,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\Framework\App\Helper\Context $context, @@ -85,7 +92,8 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Checkout\Model\Session $checkoutSession, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation + \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, + PriceCurrencyInterface $priceCurrency ) { $this->_scopeConfig = $scopeConfig; $this->_storeManager = $storeManager; @@ -93,6 +101,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper $this->_localeDate = $localeDate; $this->_transportBuilder = $transportBuilder; $this->inlineTranslation = $inlineTranslation; + $this->priceCurrency = $priceCurrency; parent::__construct($context); } @@ -122,7 +131,12 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ public function formatPrice($price) { - return $this->getQuote()->getStore()->formatPrice($price); + return $this->priceCurrency->format( + $price, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $this->getQuote()->getStore() + ); } /** @@ -132,7 +146,9 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ public function convertPrice($price, $format = true) { - return $this->getQuote()->getStore()->convertPrice($price, $format); + return $format + ? $this->priceCurrency->convertAndFormat($price) + : $this->priceCurrency->convert($price); } /** @@ -162,7 +178,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper $qty = $item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1); $taxAmount = $item->getTaxAmount() + $item->getDiscountTaxCompensation(); $price = floatval($qty) ? ($item->getRowTotal() + $taxAmount) / $qty : 0; - return $this->_storeManager->getStore()->roundPrice($price); + return $this->priceCurrency->round($price); } /** @@ -189,7 +205,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper $qty = $item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1); $taxAmount = $item->getBaseTaxAmount() + $item->getBaseDiscountTaxCompensation(); $price = floatval($qty) ? ($item->getBaseRowTotal() + $taxAmount) / $qty : 0; - return $this->_storeManager->getStore()->roundPrice($price); + return $this->priceCurrency->round($price); } /** diff --git a/app/code/Magento/Checkout/Model/Cart/Access/ReadPlugin.php b/app/code/Magento/Checkout/Model/Cart/Access/ReadPlugin.php new file mode 100644 index 0000000000000000000000000000000000000000..ec5eacba063f4ca91b793c494f5aaf407c23eaf9 --- /dev/null +++ b/app/code/Magento/Checkout/Model/Cart/Access/ReadPlugin.php @@ -0,0 +1,91 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Model\Cart\Access; + +use Magento\Authorization\Model\UserContextInterface; +use \Magento\Framework\Service\V1\Data\SearchCriteria; +use \Magento\Framework\Exception\AuthorizationException; + +class ReadPlugin +{ + /** + * @var UserContextInterface + */ + protected $userContext; + + /** + * @var int[] + */ + protected $allowedUserTypes = [ + UserContextInterface::USER_TYPE_ADMIN, + UserContextInterface::USER_TYPE_INTEGRATION + ]; + + /** + * @param UserContextInterface $userContext + */ + public function __construct(UserContextInterface $userContext) + { + $this->userContext = $userContext; + } + + /** + * Check whether access is allowed for cart resource + * + * @param \Magento\Checkout\Service\V1\Cart\ReadServiceInterface $subject + * @param int $cartId + * + * @return void + * @throws AuthorizationException if access denied + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeGetCart( + \Magento\Checkout\Service\V1\Cart\ReadServiceInterface $subject, + $cartId + ) { + if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { + throw new AuthorizationException('Access denied'); + } + } + + /** + * Check whether access is allowed for cart list resource + * + * @param \Magento\Checkout\Service\V1\Cart\ReadServiceInterface $subject + * @param SearchCriteria $searchCriteria + * + * @return void + * @throws AuthorizationException if access denied + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeGetCartList( + \Magento\Checkout\Service\V1\Cart\ReadServiceInterface $subject, + SearchCriteria $searchCriteria + ) { + if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { + throw new AuthorizationException('Access denied'); + } + } +} diff --git a/app/code/Magento/Checkout/Model/Cart/Access/WritePlugin.php b/app/code/Magento/Checkout/Model/Cart/Access/WritePlugin.php new file mode 100644 index 0000000000000000000000000000000000000000..2a9979c06482c30270a302a0a0e8642484228a4f --- /dev/null +++ b/app/code/Magento/Checkout/Model/Cart/Access/WritePlugin.php @@ -0,0 +1,73 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Model\Cart\Access; + +use Magento\Authorization\Model\UserContextInterface; +use \Magento\Framework\Exception\AuthorizationException; + +class WritePlugin +{ + /** + * @var UserContextInterface + */ + protected $userContext; + + /** + * @var int[] + */ + protected $allowedUserTypes = [ + UserContextInterface::USER_TYPE_ADMIN, + UserContextInterface::USER_TYPE_INTEGRATION + ]; + + /** + * @param UserContextInterface $userContext + */ + public function __construct(UserContextInterface $userContext) + { + $this->userContext = $userContext; + } + + /** + * Check whether access is allowed for create cart resource + * + * @param \Magento\Checkout\Service\V1\Cart\WriteServiceInterface $subject + * @param int $cartId + * @param int $customerId + * + * @return void + * @throws AuthorizationException if access denied + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeAssignCustomer( + \Magento\Checkout\Service\V1\Cart\WriteServiceInterface $subject, + $cartId, + $customerId + ) { + if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { + throw new AuthorizationException('Access denied'); + } + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php index 503da90a8b179db7fa6e2ebd3b83d477869e0eff..83e1f7de5f34b3f425ec78d087e0bc483582a7e2 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php @@ -29,9 +29,9 @@ use \Magento\Checkout\Service\V1\Address\Converter as AddressConverter; class ReadService implements ReadServiceInterface { /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var \Magento\Sales\Model\QuoteRepository */ - protected $quoteLoader; + protected $quoteRepository; /** * @var AddressConverter @@ -39,23 +39,15 @@ class ReadService implements ReadServiceInterface protected $addressConverter; /** - * @var \Magento\Framework\StoreManagerInterface - */ - protected $storeManager; - - /** - * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param \Magento\Sales\Model\QuoteRepository $quoteRepository * @param AddressConverter $addressConverter - * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - AddressConverter $addressConverter, - \Magento\Framework\StoreManagerInterface $storeManager + \Magento\Sales\Model\QuoteRepository $quoteRepository, + AddressConverter $addressConverter ) { - $this->quoteLoader = $quoteLoader; + $this->quoteRepository = $quoteRepository; $this->addressConverter = $addressConverter; - $this->storeManager = $storeManager; } /** @@ -63,10 +55,8 @@ class ReadService implements ReadServiceInterface */ public function getAddress($cartId) { - $storeId = $this->storeManager->getStore()->getId(); - /** @var \Magento\Sales\Model\Quote\Address $address */ - $address = $this->quoteLoader->load($cartId, $storeId)->getBillingAddress(); + $address = $this->quoteRepository->get($cartId)->getBillingAddress(); return $this->addressConverter->convertModelToDataObject($address); } } diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php index a965c7067ea1eb25939266ac89b32993cf515c06..1ca53780b300cf0503213a6d162c1a6b7d558d02 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php @@ -26,9 +26,8 @@ namespace Magento\Checkout\Service\V1\Address\Billing; use Magento\Framework\Exception\InputException; use Magento\Framework\Logger; -use \Magento\Checkout\Service\V1\QuoteLoader; +use \Magento\Sales\Model\QuoteRepository; use \Magento\Sales\Model\Quote\AddressFactory; -use Magento\Framework\StoreManagerInterface; use \Magento\Checkout\Service\V1\Address\Converter; use \Magento\Checkout\Service\V1\Address\Validator; @@ -49,41 +48,33 @@ class WriteService implements WriteServiceInterface */ protected $quoteAddressFactory; - /** - * @var StoreManagerInterface - */ - protected $storeManager; - /** * @var Converter */ protected $addressConverter; /** - * @var QuoteLoader + * @var QuoteRepository */ - protected $quoteLoader; + protected $quoteRepository; /** - * @param QuoteLoader $quoteLoader - * @param StoreManagerInterface $storeManager + * @param QuoteRepository $quoteRepository * @param Converter $addressConverter * @param Validator $addressValidator * @param AddressFactory $quoteAddressFactory * @param Logger $logger */ public function __construct( - QuoteLoader $quoteLoader, - StoreManagerInterface $storeManager, + QuoteRepository $quoteRepository, Converter $addressConverter, Validator $addressValidator, AddressFactory $quoteAddressFactory, Logger $logger ) { $this->addressValidator = $addressValidator; - $this->storeManager = $storeManager; $this->logger = $logger; - $this->quoteLoader = $quoteLoader; + $this->quoteRepository = $quoteRepository; $this->quoteAddressFactory = $quoteAddressFactory; $this->addressConverter = $addressConverter; } @@ -94,7 +85,7 @@ class WriteService implements WriteServiceInterface public function setAddress($cartId, $addressData) { /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); + $quote = $this->quoteRepository->get($cartId); /** @var \Magento\Sales\Model\Quote\Address $address */ $address = $this->quoteAddressFactory->create(); $this->addressValidator->validate($addressData); diff --git a/app/code/Magento/Checkout/Service/V1/Address/Converter.php b/app/code/Magento/Checkout/Service/V1/Address/Converter.php index b282663988b532e9a2b33b95d3cc7771eb88d3da..c3abebefd746735a46ee788382550c647f7687e0 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Converter.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Converter.php @@ -64,9 +64,9 @@ class Converter Address::KEY_ID => $address->getId(), Address::KEY_CUSTOMER_ID => $address->getCustomerId(), Address::KEY_REGION => array( - Region::KEY_REGION => $address->getRegion(), - Region::KEY_REGION_ID => $address->getRegionId(), - Region::KEY_REGION_CODE => $address->getRegionCode() + Region::REGION => $address->getRegion(), + Region::REGION_ID => $address->getRegionId(), + Region::REGION_CODE => $address->getRegionCode() ), Address::KEY_STREET => $address->getStreet(), Address::KEY_COMPANY => $address->getCompany(), diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php index ee81610db5641a0119a4b9c61cb42ad9e9cb95fc..1427051831a83afd217998b5c1494432b7fd6d8f 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php @@ -30,9 +30,9 @@ use \Magento\Framework\Exception\NoSuchEntityException; class ReadService implements ReadServiceInterface { /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var \Magento\Sales\Model\QuoteRepository */ - protected $quoteLoader; + protected $quoteRepository; /** * @var AddressConverter @@ -40,23 +40,15 @@ class ReadService implements ReadServiceInterface protected $addressConverter; /** - * @var \Magento\Framework\StoreManagerInterface - */ - protected $storeManager; - - /** - * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param \Magento\Sales\Model\QuoteRepository $quoteRepository * @param AddressConverter $addressConverter - * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - AddressConverter $addressConverter, - \Magento\Framework\StoreManagerInterface $storeManager + \Magento\Sales\Model\QuoteRepository $quoteRepository, + AddressConverter $addressConverter ) { - $this->quoteLoader = $quoteLoader; + $this->quoteRepository = $quoteRepository; $this->addressConverter = $addressConverter; - $this->storeManager = $storeManager; } /** @@ -64,10 +56,8 @@ class ReadService implements ReadServiceInterface */ public function getAddress($cartId) { - $storeId = $this->storeManager->getStore()->getId(); - /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $storeId); + $quote = $this->quoteRepository->get($cartId); if ($quote->isVirtual()) { throw new NoSuchEntityException( 'Cart contains virtual product(s) only. Shipping address is not applicable' diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php index abf6cae32c9bd8bc243e4e5d3275817987a903e6..cfc2a33425d62b24d04d1f5f842611ffddc725b6 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php @@ -31,14 +31,9 @@ use Magento\Framework\Logger; class WriteService implements WriteServiceInterface { /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var \Magento\Sales\Model\QuoteRepository */ - protected $quoteLoader; - - /** - * @var \Magento\Framework\StoreManagerInterface - */ - protected $storeManager; + protected $quoteRepository; /** * @var \Magento\Sales\Model\Quote\AddressFactory @@ -61,26 +56,23 @@ class WriteService implements WriteServiceInterface protected $logger; /** - * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader - * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Sales\Model\QuoteRepository $quoteRepository * @param \Magento\Checkout\Service\V1\Address\Converter $addressConverter * @param \Magento\Checkout\Service\V1\Address\Validator $addressValidator * @param \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory * @param Logger $logger */ public function __construct( - \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - \Magento\Framework\StoreManagerInterface $storeManager, + \Magento\Sales\Model\QuoteRepository $quoteRepository, \Magento\Checkout\Service\V1\Address\Converter $addressConverter, \Magento\Checkout\Service\V1\Address\Validator $addressValidator, \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory, Logger $logger ) { - $this->quoteLoader = $quoteLoader; + $this->quoteRepository = $quoteRepository; $this->quoteAddressFactory = $quoteAddressFactory; $this->addressConverter = $addressConverter; $this->addressValidator = $addressValidator; - $this->storeManager = $storeManager; $this->logger = $logger; } @@ -90,7 +82,7 @@ class WriteService implements WriteServiceInterface public function setAddress($cartId, $addressData) { /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); + $quote = $this->quoteRepository->get($cartId); if ($quote->isVirtual()) { throw new NoSuchEntityException( 'Cart contains virtual product(s) only. Shipping address is not applicable' @@ -104,6 +96,8 @@ class WriteService implements WriteServiceInterface } $address = $this->addressConverter->convertDataObjectToModel($addressData, $address); $address->setSameAsBilling(0); + $address->setCollectShippingRates(true); + $quote->setShippingAddress($address); $quote->setDataChanges(true); try { diff --git a/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php b/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php index a95483a5f59ca1c0ed35cd580b0620b578fcb6c7..3ee84d162de0307b23621cf9ba7a516ae12ae683 100644 --- a/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php @@ -28,26 +28,9 @@ use \Magento\Sales\Model\Quote; use \Magento\Sales\Model\QuoteRepository; use \Magento\Sales\Model\Resource\Quote\Collection as QuoteCollection; -use \Magento\Framework\Exception\NoSuchEntityException; use \Magento\Framework\Exception\InputException; use \Magento\Framework\Service\V1\Data\Search\FilterGroup; -use \Magento\Checkout\Service\V1\Data\CartSearchResultsBuilder; - -use \Magento\Checkout\Service\V1\Data\Cart; -use \Magento\Checkout\Service\V1\Data\CartBuilder; -use \Magento\Checkout\Service\V1\Data\CartMapper; -use \Magento\Checkout\Service\V1\Data\Cart\Totals; -use \Magento\Checkout\Service\V1\Data\Cart\TotalsBuilder; -use \Magento\Checkout\Service\V1\Data\Cart\TotalsMapper; -use \Magento\Checkout\Service\V1\Data\Cart\Customer; -use \Magento\Checkout\Service\V1\Data\Cart\CustomerBuilder; -use \Magento\Checkout\Service\V1\Data\Cart\CustomerMapper; -use \Magento\Checkout\Service\V1\Data\Cart\Currency; -use \Magento\Checkout\Service\V1\Data\Cart\CurrencyBuilder; -use \Magento\Checkout\Service\V1\Data\Cart\CurrencyMapper; -use \Magento\Checkout\Service\V1\Data\Cart\Totals\Item as ItemTotals; -use \Magento\Checkout\Service\V1\Data\Cart\Totals\ItemBuilder as ItemTotalsBuilder; -use \Magento\Checkout\Service\V1\Data\Cart\Totals\ItemMapper as ItemTotalsMapper; +use \Magento\Checkout\Service\V1\Data; class ReadService implements ReadServiceInterface { @@ -62,60 +45,15 @@ class ReadService implements ReadServiceInterface private $quoteCollection; /** - * @var CartSearchResultsBuilder + * @var Data\CartSearchResultsBuilder */ private $searchResultsBuilder; /** - * @var CartBuilder - */ - private $cartBuilder; - - /** - * @var CartMapper + * @var Data\CartMapper */ private $cartMapper; - /** - * @var CustomerBuilder - */ - private $customerBuilder; - - /** - * @var CustomerMapper - */ - private $customerMapper; - - /** - * @var TotalsBuilder - */ - private $totalsBuilder; - - /** - * @var TotalsMapper - */ - private $totalsMapper; - - /** - * @var CurrencyBuilder; - */ - private $currencyBuilder; - - /** - * @var CurrencyMapper; - */ - private $currencyMapper; - - /** - * @var ItemTotalsBuilder; - */ - private $itemTotalsBuilder; - - /** - * @var ItemTotalsMapper; - */ - private $itemTotalsMapper; - /** * @var array */ @@ -140,46 +78,19 @@ class ReadService implements ReadServiceInterface /** * @param QuoteRepository $quoteRepository * @param QuoteCollection $quoteCollection - * @param CartSearchResultsBuilder $searchResultsBuilder - * @param CartBuilder $cartBuilder - * @param CartMapper $cartMapper - * @param TotalsBuilder $totalsBuilder - * @param TotalsMapper $totalsMapper - * @param CustomerBuilder $customerBuilder - * @param CustomerMapper $customerMapper - * @param CurrencyBuilder $currencyBuilder - * @param CurrencyMapper $currencyMapper - * @param ItemTotalsBuilder $itemTotalsBuilder - * @param ItemTotalsMapper $itemTotalsMapper + * @param Data\CartSearchResultsBuilder $searchResultsBuilder + * @param Data\CartMapper $cartMapper */ public function __construct( QuoteRepository $quoteRepository, QuoteCollection $quoteCollection, - CartSearchResultsBuilder $searchResultsBuilder, - CartBuilder $cartBuilder, - CartMapper $cartMapper, - TotalsBuilder $totalsBuilder, - TotalsMapper $totalsMapper, - CustomerBuilder $customerBuilder, - CustomerMapper $customerMapper, - CurrencyBuilder $currencyBuilder, - CurrencyMapper $currencyMapper, - ItemTotalsBuilder $itemTotalsBuilder, - ItemTotalsMapper $itemTotalsMapper + Data\CartSearchResultsBuilder $searchResultsBuilder, + Data\CartMapper $cartMapper ) { $this->quoteRepository = $quoteRepository; $this->quoteCollection = $quoteCollection; $this->searchResultsBuilder = $searchResultsBuilder; - $this->cartBuilder = $cartBuilder; $this->cartMapper = $cartMapper; - $this->totalsBuilder = $totalsBuilder; - $this->totalsMapper = $totalsMapper; - $this->customerBuilder = $customerBuilder; - $this->customerMapper = $customerMapper; - $this->currencyBuilder = $currencyBuilder; - $this->currencyMapper = $currencyMapper; - $this->itemTotalsBuilder = $itemTotalsBuilder; - $this->itemTotalsMapper = $itemTotalsMapper; } /** @@ -188,7 +99,16 @@ class ReadService implements ReadServiceInterface public function getCart($cartId) { $quote = $this->quoteRepository->get($cartId); - return $this->createCartDataObject($quote); + return $this->cartMapper->map($quote); + } + + /** + * {@inheritdoc} + */ + public function getCartForCustomer($customerId) + { + $quote = $this->quoteRepository->getForCustomer($customerId); + return $this->cartMapper->map($quote); } /** @@ -205,10 +125,10 @@ class ReadService implements ReadServiceInterface $this->searchResultsBuilder->setTotalCount($this->quoteCollection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); if ($sortOrders) { - foreach ($sortOrders as $field => $direction) { + foreach ($sortOrders as $sortOrder) { $this->quoteCollection->addOrder( - $this->getQuoteSearchField($field), - $direction == SearchCriteria::SORT_ASC ? 'ASC' : 'DESC' + $this->getQuoteSearchField($sortOrder->getField()), + $sortOrder->getDirection() == SearchCriteria::SORT_ASC ? 'ASC' : 'DESC' ); } } @@ -218,48 +138,13 @@ class ReadService implements ReadServiceInterface $cartList = []; /** @var Quote $quote */ foreach ($this->quoteCollection as $quote) { - $cartList[] = $this->createCartDataObject($quote); + $cartList[] = $this->cartMapper->map($quote); } $this->searchResultsBuilder->setItems($cartList); return $this->searchResultsBuilder->create(); } - /** - * Create cart data object based on given quote - * - * @param Quote $quote - * @return Cart - */ - protected function createCartDataObject(Quote $quote) - { - $this->cartBuilder->populateWithArray($this->cartMapper->map($quote)); - $this->customerBuilder->populateWithArray($this->customerMapper->map($quote)); - $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote)); - $this->totalsBuilder->setItems($this->fetchItemTotalsData($quote)); - - $this->cartBuilder->setCustomer($this->customerBuilder->create()); - $this->cartBuilder->setTotals($this->totalsBuilder->create()); - $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote)); - return $this->cartBuilder->create(); - } - - /** - * Fetch quote item totals data - * - * @param Quote $quote - * @return array - */ - protected function fetchItemTotalsData(Quote $quote) - { - $items = []; - - foreach ($quote->getAllItems() as $item) { - $items[] = $this->itemTotalsMapper->extractDto($item); - } - return $items; - } - /** * Add FilterGroup to the given quote collection. * @@ -296,18 +181,4 @@ class ReadService implements ReadServiceInterface } return isset($this->searchFieldMap[$field]) ? $this->searchFieldMap[$field] : $field; } - - /** - * {@inheritdoc} - */ - public function getTotals($cartId) - { - /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteRepository->get($cartId); - - $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote)); - $this->totalsBuilder->setItems($this->fetchItemTotalsData($quote)); - - return $this->totalsBuilder->create(); - } } diff --git a/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php index 3e6051ea5eb185208b82b4f32e3ffdf094352a75..4a1ca0823b87950e426134a3d751481a2b103d2f 100644 --- a/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php +++ b/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php @@ -30,6 +30,7 @@ interface ReadServiceInterface /** * Retrieve information about cart represented by given ID * + * Access level: admin * @param int $cartId * @return \Magento\Checkout\Service\V1\Data\Cart * @throws \Magento\Framework\Exception\NoSuchEntityException @@ -37,19 +38,21 @@ interface ReadServiceInterface public function getCart($cartId); /** - * Retrieve list of carts that match given search criteria + * Retrieve information about cart of provided customer * - * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria - * @return \Magento\Checkout\Service\V1\Data\CartSearchResults + * @param int $customerId + * @return \Magento\Checkout\Service\V1\Data\Cart + * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function getCartList(SearchCriteria $searchCriteria); + public function getCartForCustomer($customerId); /** - * Retrieve quote totals data + * Retrieve list of carts that match given search criteria * - * @param int $cartId - * @return \Magento\Checkout\Service\V1\Data\Cart\Totals - * @throws \Magento\Framework\Exception\NoSuchEntityException + * Access level: admin + * + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Checkout\Service\V1\Data\CartSearchResults */ - public function getTotals($cartId); + 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 new file mode 100644 index 0000000000000000000000000000000000000000..afea3b331046b2616c29067d17dae7647f3ec1ad --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Cart/TotalsService.php @@ -0,0 +1,89 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Checkout\Service\V1\Cart; + +use Magento\Checkout\Service\V1\Data\Cart; +use Magento\Sales\Model\Quote; +use Magento\Sales\Model\QuoteRepository; +use \Magento\Checkout\Service\V1\Data\Cart\Totals; + +class TotalsService implements TotalsServiceInterface +{ + /** + * @var Cart\TotalsBuilder + */ + private $totalsBuilder; + + /** + * @var Cart\TotalsMapper + */ + private $totalsMapper; + + /** + * @var QuoteRepository + */ + private $quoteRepository; + + /** + * @var Totals\ItemMapper; + */ + private $itemTotalsMapper; + + /** + * @param Cart\TotalsBuilder $totalsBuilder + * @param Cart\TotalsMapper $totalsMapper + * @param QuoteRepository $quoteRepository + * @param Totals\ItemMapper $itemTotalsMapper + */ + 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} + */ + public function getTotals($cartId) + { + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteRepository->get($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/TotalsServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Cart/TotalsServiceInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..ff5eb7aea60c36bc9162c93ee1e5a1e7eb408c90 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Cart/TotalsServiceInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Checkout\Service\V1\Cart; + +interface TotalsServiceInterface +{ + /** + * Retrieve quote totals data + * + * @param int $cartId + * @return \Magento\Checkout\Service\V1\Data\Cart\Totals + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getTotals($cartId); +} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php index fed2d2b7b45eaff5d85364daf5728224ae6488f6..f537f5d80424f4de9dc4b9400ebb4c07a4664286 100644 --- a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php @@ -25,8 +25,8 @@ namespace Magento\Checkout\Service\V1\Cart; use Magento\Framework\Exception\CouldNotSaveException; -use \Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\StateException; +use Magento\Authorization\Model\UserContextInterface; class WriteService implements WriteServiceInterface { @@ -35,6 +35,11 @@ class WriteService implements WriteServiceInterface */ protected $quoteFactory; + /** + * @var \Magento\Sales\Model\QuoteRepository + */ + protected $quoteRepository; + /** * @var \Magento\Framework\StoreManagerInterface */ @@ -45,19 +50,38 @@ class WriteService implements WriteServiceInterface */ protected $customerRegistry; + /** + * @var UserContextInterface + */ + protected $userContext; + + /** + * @var \Magento\Sales\Model\Service\QuoteFactory + */ + protected $quoteServiceFactory; + /** * @param \Magento\Sales\Model\QuoteFactory $quoteFactory + * @param \Magento\Sales\Model\QuoteRepository $quoteRepository * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\CustomerRegistry $customerRegistry + * @param UserContextInterface $userContext + * @param \Magento\Sales\Model\Service\QuoteFactory $quoteServiceFactory */ public function __construct( \Magento\Sales\Model\QuoteFactory $quoteFactory, + \Magento\Sales\Model\QuoteRepository $quoteRepository, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Customer\Model\CustomerRegistry $customerRegistry + \Magento\Customer\Model\CustomerRegistry $customerRegistry, + UserContextInterface $userContext, + \Magento\Sales\Model\Service\QuoteFactory $quoteServiceFactory ) { $this->quoteFactory = $quoteFactory; + $this->quoteRepository = $quoteRepository; $this->storeManager = $storeManager; $this->customerRegistry = $customerRegistry; + $this->userContext = $userContext; + $this->quoteServiceFactory = $quoteServiceFactory; } /** @@ -65,11 +89,10 @@ class WriteService implements WriteServiceInterface */ public function create() { - $storeId = $this->storeManager->getStore()->getId(); + $quote = $this->userContext->getUserType() == UserContextInterface::USER_TYPE_CUSTOMER + ? $this->createCustomerCart() + : $this->createAnonymousCart(); - /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteFactory->create(); - $quote->setStoreId($storeId); try { $quote->save(); } catch (\Exception $e) { @@ -78,16 +101,51 @@ class WriteService implements WriteServiceInterface return $quote->getId(); } + /** + * Create anonymous cart + * + * @return \Magento\Sales\Model\Quote + */ + protected function createAnonymousCart() + { + $storeId = $this->storeManager->getStore()->getId(); + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteFactory->create(); + $quote->setStoreId($storeId); + return $quote; + } + + /** + * Create cart for current logged in customer + * + * @return \Magento\Sales\Model\Quote + * @throws CouldNotSaveException + */ + protected function createCustomerCart() + { + $storeId = $this->storeManager->getStore()->getId(); + $customer = $this->customerRegistry->retrieve($this->userContext->getUserId()); + + $currentCustomerQuote = $this->quoteFactory->create()->loadByCustomer($customer); + if ($currentCustomerQuote->getId() && $currentCustomerQuote->getIsActive()) { + throw new CouldNotSaveException('Cannot create quote'); + } + + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteFactory->create(); + $quote->setStoreId($storeId); + $quote->setCustomer($customer); + $quote->setCustomerIsGuest(0); + return $quote; + } + /** * {@inheritdoc} */ public function assignCustomer($cartId, $customerId) { $storeId = $this->storeManager->getStore()->getId(); - $quote = $this->quoteFactory->create()->load($cartId); - if ($quote->getId() != $cartId || $quote->getStoreId() != $storeId) { - throw new NoSuchEntityException('There is no cart with provided ID.'); - } + $quote = $this->quoteRepository->get($cartId); $customer = $this->customerRegistry->retrieve($customerId); if (!in_array($storeId, $customer->getSharedStoreIds())) { throw new StateException('Cannot assign customer to the given cart. The cart belongs to different store.'); @@ -105,4 +163,16 @@ class WriteService implements WriteServiceInterface $quote->save(); return true; } + + /** + * {@inheritdoc} + */ + public function order($cartId) + { + $quote = $this->quoteRepository->get($cartId); + /** @var \Magento\Sales\Model\Service\Quote $quoteService */ + $quoteService = $this->quoteServiceFactory->create(['quote' => $quote]); + $order = $quoteService->submitOrderWithDataObject(); + return $order->getId(); + } } diff --git a/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php index 6f761b98e0751d024279297e8b278c1f2b8c789e..e643df26347a385c188d3b034481d69cde014a9e 100644 --- a/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php +++ b/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php @@ -28,6 +28,8 @@ interface WriteServiceInterface /** * Create empty cart/quote for anonymous customer * + * Access level: admin or guest + * * @throws \Magento\Framework\Exception\CouldNotSaveException * @return int cart id */ @@ -41,4 +43,12 @@ interface WriteServiceInterface * @return boolean */ public function assignCustomer($cartId, $customerId); + + /** + * Place order for cart + * + * @param int $cartId + * @return int + */ + public function order($cartId); } diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php b/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php index 948871502fc3cf1e43d80f8c3df07d62c43d0d77..f170475d9f21146d1e2165296272d8f28ff67809 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php @@ -32,9 +32,9 @@ use \Magento\Checkout\Service\V1\Data\Cart\Coupon as Coupon; class ReadService implements ReadServiceInterface { /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var \Magento\Sales\Model\QuoteRepository */ - protected $quoteLoader; + protected $quoteRepository; /** * @var CouponBuilder @@ -42,23 +42,15 @@ class ReadService implements ReadServiceInterface protected $couponBuilder; /** - * @var \Magento\Framework\StoreManagerInterface - */ - protected $storeManager; - - /** - * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param \Magento\Sales\Model\QuoteRepository $quoteRepository * @param CouponBuilder $couponBuilder - * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - CouponBuilder $couponBuilder, - \Magento\Framework\StoreManagerInterface $storeManager + \Magento\Sales\Model\QuoteRepository $quoteRepository, + CouponBuilder $couponBuilder ) { - $this->quoteLoader = $quoteLoader; + $this->quoteRepository = $quoteRepository; $this->couponBuilder = $couponBuilder; - $this->storeManager = $storeManager; } /** @@ -66,9 +58,8 @@ class ReadService implements ReadServiceInterface */ public function get($cartId) { - $storeId = $this->storeManager->getStore()->getId(); /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $storeId); + $quote = $this->quoteRepository->get($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/WriteService.php b/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php index 33dbe23e25047226148961c9bb802a46a9d3f4a2..509219fcc20c612d79bc1d6e960824ff379d6a9e 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php @@ -34,9 +34,9 @@ use Magento\Framework\Exception\CouldNotSaveException; class WriteService implements WriteServiceInterface { /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var \Magento\Sales\Model\QuoteRepository */ - protected $quoteLoader; + protected $quoteRepository; /** * @var CouponBuilder @@ -44,23 +44,15 @@ class WriteService implements WriteServiceInterface protected $couponBuilder; /** - * @var \Magento\Framework\StoreManagerInterface - */ - protected $storeManager; - - /** - * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param \Magento\Sales\Model\QuoteRepository $quoteRepository * @param CouponBuilder $couponBuilder - * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - CouponBuilder $couponBuilder, - \Magento\Framework\StoreManagerInterface $storeManager + \Magento\Sales\Model\QuoteRepository $quoteRepository, + CouponBuilder $couponBuilder ) { - $this->quoteLoader = $quoteLoader; + $this->quoteRepository = $quoteRepository; $this->couponBuilder = $couponBuilder; - $this->storeManager = $storeManager; } /** @@ -68,9 +60,8 @@ class WriteService implements WriteServiceInterface */ public function set($cartId, \Magento\Checkout\Service\V1\Data\Cart\Coupon $couponCodeData) { - $storeId = $this->storeManager->getStore()->getId(); /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $storeId); + $quote = $this->quoteRepository->get($cartId); if (!$quote->getItemsCount()) { throw new NoSuchEntityException("Cart $cartId doesn't contain products"); } @@ -94,9 +85,8 @@ class WriteService implements WriteServiceInterface */ public function delete($cartId) { - $storeId = $this->storeManager->getStore()->getId(); /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $storeId); + $quote = $this->quoteRepository->get($cartId); if (!$quote->getItemsCount()) { throw new NoSuchEntityException("Cart $cartId doesn't contain products"); } diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Coupon/WriteServiceInterface.php index f6b6f3ee47e510cfdb19c9aa11b97a6213585b96..8f2ca64d084cf3354d030bf99a6aa0280e2a6568 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/WriteServiceInterface.php +++ b/app/code/Magento/Checkout/Service/V1/Coupon/WriteServiceInterface.php @@ -23,9 +23,6 @@ */ namespace Magento\Checkout\Service\V1\Coupon; -/** - * Interface WriteServiceInterface - */ interface WriteServiceInterface { /** 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 index 45d0f0e6f21d7840d10977bf5922b26f2f643391..78124a81bba472dfb558c3c5a9ba452ddaf88170 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.php @@ -24,18 +24,18 @@ namespace Magento\Checkout\Service\V1\Data\Cart\Address; /** - * Data Object for Address Region + * @codeCoverageIgnore */ class Region extends \Magento\Framework\Service\Data\AbstractExtensibleObject { /**#@+ * Array keys */ - const KEY_REGION_CODE = 'region_code'; + const REGION_CODE = 'region_code'; - const KEY_REGION = 'region'; + const REGION = 'region'; - const KEY_REGION_ID = 'region_id'; + const REGION_ID = 'region_id'; /**#@-*/ @@ -46,7 +46,7 @@ class Region extends \Magento\Framework\Service\Data\AbstractExtensibleObject */ public function getRegionCode() { - return $this->_get(self::KEY_REGION_CODE); + return $this->_get(self::REGION_CODE); } /** @@ -56,7 +56,7 @@ class Region extends \Magento\Framework\Service\Data\AbstractExtensibleObject */ public function getRegion() { - return $this->_get(self::KEY_REGION); + return $this->_get(self::REGION); } /** @@ -66,6 +66,6 @@ class Region extends \Magento\Framework\Service\Data\AbstractExtensibleObject */ public function getRegionId() { - return $this->_get(self::KEY_REGION_ID); + 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 index 5a1c98d748e4c827f21155eb9d00413349fa3e79..355d91d09649a7c3c9224eeab76ca64fae1afafc 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php @@ -90,7 +90,7 @@ class AddressBuilder extends AbstractExtensibleObjectBuilder if (!is_array($data[Address::KEY_REGION])) { // Region data has been submitted as individual keys of Address object. Let's extract it. $regionData = array(); - foreach (array(Region::KEY_REGION, Region::KEY_REGION_CODE, Region::KEY_REGION_ID) as $attrCode) { + foreach (array(Region::REGION, Region::REGION_CODE, Region::REGION_ID) as $attrCode) { if (isset($data[$attrCode])) { $regionData[$attrCode] = $data[$attrCode]; } diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod.php index 10e4dbb72a0713075f43fc55054ddbc9cbf691ad..ea3eb475b8f5ac12c3e28b39000b572840bc7429 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod.php @@ -24,6 +24,9 @@ namespace Magento\Checkout\Service\V1\Data\Cart; +/** + * @codeCoverageIgnore + */ class PaymentMethod extends \Magento\Framework\Service\Data\AbstractExtensibleObject { /** 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 index 7a8b8062f0093951cdb43c1a75bff791b82f77d1..570ab831e2e06bd43a9cc6dccee884e3871ffccf 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Builder.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Builder.php @@ -28,9 +28,6 @@ use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod as QuotePaymentMethod; use Magento\Sales\Model\Quote; use Magento\Framework\Exception\LocalizedException; -/** - * Class Builder - */ class Builder { /** 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 index e57d7cb16d22e6dce0a1324c64e4dbbab32fa69b..34d0db56bd2b5dc10e7772af94b83b31be7b3332 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Converter.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethod/Converter.php @@ -36,9 +36,8 @@ class Converter /** * @param \Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder $builder */ - public function __construct( - \Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder $builder - ) { + public function __construct(\Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder $builder) + { $this->builder = $builder; } diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethodBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethodBuilder.php deleted file mode 100644 index 18b01b5070fae5a9707f699ae364e7e5961f439b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/PaymentMethodBuilder.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * @method PaymentMethod create() - */ -class PaymentMethodBuilder extends \Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder -{ - /** - * Get purchase order number - * - * @param string $value - * @return $this - */ - public function setPoNumber($value) - { - return $this->_set(PaymentMethod::PO_NUMBER, $value); - } - - /** - * Get payment method code - * - * @param string $value - * @return $this - */ - public function setMethod($value) - { - return $this->_set(PaymentMethod::METHOD, $value); - } - - /** - * Get credit card owner - * - * @param string $value - * @return $this - */ - public function setCcOwner($value) - { - return $this->_set(PaymentMethod::CC_OWNER, $value); - } - - /** - * Get credit card number - * - * @param string $value - * @return $this - */ - public function setCcNumber($value) - { - return $this->_set(PaymentMethod::CC_NUMBER, $value); - } - - /** - * Get credit card type - * - * @param string $value - * @return $this - */ - public function setCcType($value) - { - return $this->_set(PaymentMethod::CC_TYPE, $value); - } - - /** - * Get credit card expiration year - * - * @param string $value - * @return $this - */ - public function setCcExpYear($value) - { - return $this->_set(PaymentMethod::CC_EXP_YEAR, $value); - } - - /** - * Get credit card expiration month - * - * @param string $value - * @return $this - */ - public function setCcExpMonth($value) - { - return $this->_set(PaymentMethod::CC_EXP_MONTH, $value); - } - - /** - * Set payment additional payment details - * - * @param string $value - * @return $this - */ - public function setPaymentDetails($value) - { - return $this->_set(PaymentMethod::PAYMENT_DETAILS, $value); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodBuilder.php deleted file mode 100644 index 3caf49427ed7a7e602a312a644709527243bfc69..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodBuilder.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * Builder for the Shipping Method Data - */ -class ShippingMethodBuilder extends \Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder -{ - /** - * Set carrier code - * - * @param string $value - * @return $this - */ - public function setCarrierCode($value) - { - return $this->_set(ShippingMethod::CARRIER_CODE, $value); - } - - /** - * Set shipping method code - * - * @param string $value - * @return $this - */ - public function setMethodCode($value) - { - return $this->_set(ShippingMethod::METHOD_CODE, $value); - } - - /** - * Set shipping carrier title - * - * @param string $value - * @return $this - */ - public function setCarrierTitle($value) - { - return $this->_set(ShippingMethod::CARRIER_TITLE, $value); - } - - /** - * Set shipping method title - * - * @param string $value - * @return $this - */ - public function setMethodTitle($value) - { - return $this->_set(ShippingMethod::METHOD_TITLE, $value); - } - - /** - * Set shipping amount - * - * @param float $value - * @return $this - */ - public function setAmount($value) - { - return $this->_set(ShippingMethod::SHIPPING_AMOUNT, $value); - } - - /** - * Set base shipping amount - * - * @param float $value - * @return $this - */ - public function setBaseAmount($value) - { - return $this->_set(ShippingMethod::BASE_SHIPPING_AMOUNT, $value); - } - - /** - * Set method availability flag - * - * @param bool $value - * @return $this - */ - public function setAvailable($value) - { - return $this->_set(ShippingMethod::AVAILABLE, (bool)$value); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsBuilder.php deleted file mode 100644 index 8ea172a7e36f1bb1055fe95b8d0fd1657c99c608..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsBuilder.php +++ /dev/null @@ -1,285 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Checkout\Service\V1\Data\Cart; - -/** - * Cart Totals Builder - * - * @codeCoverageIgnore - */ -class TotalsBuilder extends \Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder -{ - /** - * Set grand total in quote currency - * - * @param float|null $value - * @return $this - */ - public function setGrandTotal($value) - { - return $this->_set(Totals::GRAND_TOTAL, $value); - } - - /** - * Set grand total in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseGrandTotal($value) - { - return $this->_set(Totals::BASE_GRAND_TOTAL, $value); - } - - /** - * Set subtotal in quote currency - * - * @param float|null $value - * @return $this - */ - public function setSubtotal($value) - { - return $this->_set(Totals::SUBTOTAL, $value); - } - - /** - * Set subtotal in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseSubtotal($value) - { - return $this->_set(Totals::BASE_SUBTOTAL, $value); - } - - /** - * Set discount amount in quote currency - * - * @param float|null $value - * @return $this - */ - public function setDiscountAmount($value) - { - return $this->_set(Totals::DISCOUNT_AMOUNT, $value); - } - - /** - * Set discount amount in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseDiscountAmount($value) - { - return $this->_set(Totals::BASE_DISCOUNT_AMOUNT, $value); - } - - /** - * Set subtotal in quote currency with applied discount - * - * @param float|null $value - * @return $this - */ - public function setSubtotalWithDiscount($value) - { - return $this->_set(Totals::SUBTOTAL_WITH_DISCOUNT, $value); - } - - /** - * Set subtotal in base currency with applied discount - * - * @param float|null $value - * @return $this - */ - public function setBaseSubtotalWithDiscount($value) - { - return $this->_set(Totals::BASE_SUBTOTAL_WITH_DISCOUNT, $value); - } - - /** - * Set shipping amount in quote currency - * - * @param float|null $value - * @return $this - */ - public function setShippingAmount($value) - { - return $this->_set(Totals::SHIPPING_AMOUNT, $value); - } - - /** - * Set shipping amount in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseShippingAmount($value) - { - return $this->_set(Totals::BASE_SHIPPING_AMOUNT, $value); - } - - /** - * Set shipping discount amount in quote currency - * - * @param float|null $value - * @return $this - */ - public function setShippingDiscountAmount($value) - { - return $this->_set(Totals::SHIPPING_DISCOUNT_AMOUNT, $value); - } - - /** - * Set shipping discount amount in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseShippingDiscountAmount($value) - { - return $this->_set(Totals::BASE_SHIPPING_DISCOUNT_AMOUNT, $value); - } - - /** - * Set tax amount in quote currency - * - * @param float|null $value - * @return $this - */ - public function setTaxAmount($value) - { - return $this->_set(Totals::TAX_AMOUNT, $value); - } - - /** - * Set tax amount in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseTaxAmount($value) - { - return $this->_set(Totals::BASE_TAX_AMOUNT, $value); - } - - /** - * Set shipping tax amount in quote currency - * - * @param float|null $value - * @return $this - */ - public function setShippingTaxAmount($value) - { - return $this->_set(Totals::SHIPPING_TAX_AMOUNT, $value); - } - - /** - * Set shipping tax amount in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseShippingTaxAmount($value) - { - return $this->_set(Totals::BASE_SHIPPING_TAX_AMOUNT, $value); - } - - /** - * Set subtotal including tax in quote currency - * - * @param float|null $value - * @return $this - */ - public function setSubtotalInclTax($value) - { - return $this->_set(Totals::SUBTOTAL_INCL_TAX, $value); - } - - /** - * Set subtotal including tax in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseSubtotalInclTax($value) - { - return $this->_set(Totals::BASE_SUBTOTAL_INCL_TAX, $value); - } - - /** - * Set shipping including tax in quote currency - * - * @param float|null $value - * @return $this - */ - public function setShippingInclTax($value) - { - return $this->_set(Totals::SHIPPING_INCL_TAX, $value); - } - - /** - * Set shipping including tax in base currency - * - * @param float|null $value - * @return $this - */ - public function setBaseShippingInclTax($value) - { - return $this->_set(Totals::BASE_SHIPPING_INCL_TAX, $value); - } - - /** - * Set base currency code - * - * @param string|null $value - * @return $this - */ - public function setBaseCurrencyCode($value) - { - return $this->_set(Currency::BASE_CURRENCY_CODE, $value); - } - - /** - * Set quote currency code - * - * @param string|null $value - * @return $this - */ - public function setQuoteCurrencyCode($value) - { - return $this->_set(Currency::QUOTE_CURRENCY_CODE, $value); - } - - /** - * Set items totals info - * - * @param \Magento\Checkout\Service\V1\Data\Cart\Totals\Item[]|null $value - * @return $this - */ - public function setItems($value) - { - return $this->_set(Totals::ITEMS, $value); - } -} diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartMapper.php b/app/code/Magento/Checkout/Service/V1/Data/CartMapper.php index 970f242bb300d5d9ac75e7d44a1ec0ff0acf3967..d8c9212a6d55ccb710e08608552fefa7b8d68b3d 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/CartMapper.php +++ b/app/code/Magento/Checkout/Service/V1/Data/CartMapper.php @@ -24,12 +24,75 @@ namespace Magento\Checkout\Service\V1\Data; use \Magento\Sales\Model\Quote; +use \Magento\Checkout\Service\V1\Data\Cart; /** * Cart mapper */ 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 * @@ -38,7 +101,7 @@ class CartMapper */ public function map(Quote $quote) { - return [ + $this->cartBuilder->populateWithArray([ Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), @@ -51,6 +114,19 @@ class CartMapper 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 index fdde733b14c30939f0d71e14b1cd55edcca1424f..19442cccb8bf10415836f6e377fba5443ae6577c 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php +++ b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php @@ -23,6 +23,9 @@ */ namespace Magento\Checkout\Service\V1\Data; +/** + * @codeCoverageIgnore + */ class CartSearchResults extends \Magento\Framework\Service\V1\Data\SearchResults { /** diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php index d61a29cd62addb12bf6893206f8e6d7d9459df25..8fb67d717cbecb56fbfaa36c1e15010a22660a55 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php +++ b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php @@ -29,6 +29,9 @@ use Magento\Framework\Service\Data\ObjectFactory; use Magento\Framework\Service\V1\Data\AbstractSearchResultsBuilder; use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +/** + * @codeCoverageIgnore + */ class CartSearchResultsBuilder extends AbstractSearchResultsBuilder { /** diff --git a/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod.php b/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod.php index 1d3e06d744a3315440b4c1c45a62a81a9c79e32c..2e7b6271c2c4bf7f5c48d0ce35d1d4578199001b 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod.php +++ b/app/code/Magento/Checkout/Service/V1/Data/PaymentMethod.php @@ -24,6 +24,9 @@ namespace Magento\Checkout\Service\V1\Data; +/** + * @codeCoverageIgnore + */ class PaymentMethod extends \Magento\Framework\Service\Data\AbstractExtensibleObject { const CODE = 'code'; diff --git a/app/code/Magento/Checkout/Service/V1/Item/ReadService.php b/app/code/Magento/Checkout/Service/V1/Item/ReadService.php index a7ca54c6c9711a01a9eb1d8d54ae6fdbd008963f..5c858a7907477393e18ab2241fe43696be192dc6 100644 --- a/app/code/Magento/Checkout/Service/V1/Item/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Item/ReadService.php @@ -27,7 +27,7 @@ namespace Magento\Checkout\Service\V1\Item; class ReadService implements ReadServiceInterface { /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var \Magento\Sales\Model\QuoteRepository */ protected $quoteRepository; diff --git a/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php index 2ced087aeeaf4fcb7ae6b3b504c285825523870b..2a3d580d25201b2fbf3e79ce4400c6241467e574 100644 --- a/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php +++ b/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php @@ -26,6 +26,8 @@ namespace Magento\Checkout\Service\V1\Item; interface ReadServiceInterface { /** + * Get items assigned to a cart + * * @param int $cartId * @return \Magento\Checkout\Service\V1\Data\Cart\Item[] * @throws \Magento\Framework\Exception\NoSuchEntityException diff --git a/app/code/Magento/Checkout/Service/V1/Item/WriteService.php b/app/code/Magento/Checkout/Service/V1/Item/WriteService.php index ef29a3ccc2941f2ce1288dda47664af8e4f0a581..c421182ac3f8c788adce0c2ac0252a2961cd09c4 100644 --- a/app/code/Magento/Checkout/Service/V1/Item/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Item/WriteService.php @@ -31,7 +31,7 @@ use Magento\Framework\Exception\InputException; class WriteService implements WriteServiceInterface { /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var \Magento\Sales\Model\QuoteRepository */ protected $quoteRepository; diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php index dfc0d2c008618c2a36d4c06f968f60ddf3abf240..20b45310af2c92f192b52798821a6d7533875993 100644 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php @@ -24,24 +24,18 @@ namespace Magento\Checkout\Service\V1\PaymentMethod; -use \Magento\Checkout\Service\V1\QuoteLoader; -use Magento\Framework\StoreManagerInterface; +use \Magento\Sales\Model\QuoteRepository; +use \Magento\Framework\StoreManagerInterface; use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter as QuoteMethodConverter; use Magento\Checkout\Service\V1\Data\PaymentMethod\Converter as PaymentMethodConverter; use \Magento\Payment\Model\MethodList; -use \Magento\Framework\Exception\State\InvalidTransitionException; class ReadService implements ReadServiceInterface { /** - * @var StoreManagerInterface + * @var QuoteRepository */ - protected $storeManager; - - /** - * @var QuoteLoader - */ - protected $quoteLoader; + protected $quoteRepository; /** * @var QuoteMethodConverter @@ -59,21 +53,18 @@ class ReadService implements ReadServiceInterface protected $methodList; /** - * @param QuoteLoader $quoteLoader - * @param StoreManagerInterface $storeManager + * @param QuoteRepository $quoteRepository * @param QuoteMethodConverter $quoteMethodConverter * @param PaymentMethodConverter $paymentMethodConverter * @param MethodList $methodList */ public function __construct( - QuoteLoader $quoteLoader, - StoreManagerInterface $storeManager, + QuoteRepository $quoteRepository, QuoteMethodConverter $quoteMethodConverter, PaymentMethodConverter $paymentMethodConverter, MethodList $methodList ) { - $this->storeManager = $storeManager; - $this->quoteLoader = $quoteLoader; + $this->quoteRepository = $quoteRepository; $this->quoteMethodConverter = $quoteMethodConverter; $this->paymentMethodConverter = $paymentMethodConverter; $this->methodList = $methodList; @@ -85,8 +76,7 @@ class ReadService implements ReadServiceInterface public function getPayment($cartId) { /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); - + $quote = $this->quoteRepository->get($cartId); $payment = $quote->getPayment(); if (!$payment->getId()) { return null; @@ -101,7 +91,7 @@ class ReadService implements ReadServiceInterface { $output = []; /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); + $quote = $this->quoteRepository->get($cartId); foreach ($this->methodList->getAvailableMethods($quote) as $method) { $output[] = $this->paymentMethodConverter->toDataObject($method); } diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php index b162bce65ef16fa49b2b3cc03c9a15dafbf385a9..48212c9196a295b4444d2261b6786a7798b82b25 100644 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php @@ -24,23 +24,17 @@ namespace Magento\Checkout\Service\V1\PaymentMethod; -use \Magento\Checkout\Service\V1\QuoteLoader; -use Magento\Framework\StoreManagerInterface; +use \Magento\Sales\Model\QuoteRepository; use \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder; use \Magento\Framework\Exception\State\InvalidTransitionException; -use \Magento\Payment\Model\MethodList; +use \Magento\Payment\Model\Checks\ZeroTotal; class WriteService implements WriteServiceInterface { /** - * @var \Magento\Framework\StoreManagerInterface + * @var QuoteRepository */ - protected $storeManager; - - /** - * @var QuoteLoader - */ - protected $quoteLoader; + protected $quoteRepository; /** * @var Builder @@ -48,24 +42,21 @@ class WriteService implements WriteServiceInterface protected $paymentMethodBuilder; /** - * @var \Magento\Payment\Model\Checks\ZeroTotal + * @var ZeroTotal */ protected $zeroTotalValidator; /** - * @param QuoteLoader $quoteLoader - * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param QuoteRepository $quoteRepository * @param Builder $paymentMethodBuilder - * @param \Magento\Payment\Model\Checks\ZeroTotal $zeroTotalValidator + * @param ZeroTotal $zeroTotalValidator */ public function __construct( - QuoteLoader $quoteLoader, - StoreManagerInterface $storeManager, + QuoteRepository $quoteRepository, Builder $paymentMethodBuilder, - \Magento\Payment\Model\Checks\ZeroTotal $zeroTotalValidator + ZeroTotal $zeroTotalValidator ) { - $this->storeManager = $storeManager; - $this->quoteLoader = $quoteLoader; + $this->quoteRepository = $quoteRepository; $this->paymentMethodBuilder = $paymentMethodBuilder; $this->zeroTotalValidator = $zeroTotalValidator; } @@ -75,7 +66,7 @@ class WriteService implements WriteServiceInterface */ public function set(\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod $method, $cartId) { - $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); + $quote = $this->quoteRepository->get($cartId); $payment = $this->paymentMethodBuilder->build($method, $quote); if ($quote->isVirtual()) { diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php index 370d45b8462155c5b74ce4daa18c0ea23173eb20..5c965a3b48575e182f5a42ba04787a44094a172a 100644 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php @@ -24,7 +24,9 @@ namespace Magento\Checkout\Service\V1\ShippingMethod; +use \Magento\Sales\Model\QuoteRepository; use \Magento\Checkout\Service\V1\Data\Cart\ShippingMethod; +use \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter; use \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder; use \Magento\Framework\Exception\StateException; use \Magento\Framework\Exception\InputException; @@ -32,14 +34,9 @@ use \Magento\Framework\Exception\InputException; class ReadService implements ReadServiceInterface { /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var QuoteRepository */ - protected $quoteLoader; - - /** - * @var \Magento\Framework\StoreManagerInterface - */ - protected $storeManager; + protected $quoteRepository; /** * @var \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder @@ -47,24 +44,21 @@ class ReadService implements ReadServiceInterface protected $methodBuilder; /** - * @var \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter + * @var ShippingMethodConverter */ protected $converter; /** - * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader - * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter $converter - * @param ShippingMethodBuilder $methodBuilder + * @param QuoteRepository $quoteRepository + * @param ShippingMethodConverter $converter + * @param \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $methodBuilder */ public function __construct( - \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter $converter, + QuoteRepository $quoteRepository, + ShippingMethodConverter $converter, \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $methodBuilder ) { - $this->quoteLoader = $quoteLoader; - $this->storeManager = $storeManager; + $this->quoteRepository = $quoteRepository; $this->converter = $converter; $this->methodBuilder = $methodBuilder; } @@ -74,10 +68,8 @@ class ReadService implements ReadServiceInterface */ public function getMethod($cartId) { - $storeId = $this->storeManager->getStore()->getId(); - /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $storeId); + $quote = $this->quoteRepository->get($cartId); /** @var \Magento\Sales\Model\Quote\Address $shippingAddress */ $shippingAddress = $quote->getShippingAddress(); @@ -127,10 +119,8 @@ class ReadService implements ReadServiceInterface { $output = []; - $storeId = $this->storeManager->getStore()->getId(); - /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $storeId); + $quote = $this->quoteRepository->get($cartId); // no methods applicable for empty carts or carts with virtual products if ($quote->isVirtual() || 0 == $quote->getItemsCount()) { diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceInterface.php index de6e97fb506aced0120c9397a6b9d84afc8162ce..2543f3f3d90da5c89aa916b4ec5d286c46d8a6df 100644 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceInterface.php +++ b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceInterface.php @@ -37,7 +37,6 @@ interface ReadServiceInterface */ public function getMethod($cartId); - /** * Get list of applicable shipping methods for quote * diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php index 91069b36753d5b19b22b28a130e120f7c340a671..1f42987f194c4fd0e26d948748ecc60cedff5cf4 100644 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php @@ -23,6 +23,7 @@ */ namespace Magento\Checkout\Service\V1\ShippingMethod; +use \Magento\Sales\Model\QuoteRepository; use \Magento\Framework\Exception\CouldNotSaveException; use \Magento\Framework\Exception\NoSuchEntityException; use \Magento\Framework\Exception\InputException; @@ -36,28 +37,20 @@ class WriteService implements WriteServiceInterface protected $addressFactory; /** - * @var \Magento\Checkout\Service\V1\QuoteLoader + * @var QuoteRepository */ - protected $quoteLoader; + protected $quoteRepository; /** - * @var \Magento\Framework\StoreManagerInterface - */ - protected $storeManager; - - /** - * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Quote\AddressFactory $addressFactory - * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param QuoteRepository $quoteRepository */ public function __construct( - \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Quote\AddressFactory $addressFactory, - \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + QuoteRepository $quoteRepository ) { $this->addressFactory = $addressFactory; - $this->quoteLoader = $quoteLoader; - $this->storeManager = $storeManager; + $this->quoteRepository = $quoteRepository; } /** @@ -66,7 +59,7 @@ class WriteService implements WriteServiceInterface public function setMethod($cartId, $carrierCode, $methodCode) { /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); + $quote = $this->quoteRepository->get($cartId); if (0 == $quote->getItemsCount()) { throw new InputException('Shipping method is not applicable for empty cart'); } diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 36015c01be5a21356f520baf46de309b85aab970..241e2ac7bace3b58824407385bbe7add42f417bf 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -3,25 +3,26 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-gift-message": "0.1.0-alpha95", - "magento/module-wishlist": "0.1.0-alpha95", - "magento/module-page-cache": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-authorization": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-gift-message": "0.1.0-alpha96", + "magento/module-wishlist": "0.1.0-alpha96", + "magento/module-page-cache": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Checkout/etc/di.xml b/app/code/Magento/Checkout/etc/di.xml index 8c72b8c0fa84270c80ce9d9051472cdd20d445e5..b3b93417a9a9c4b351f86437efa25c6916d0fee6 100644 --- a/app/code/Magento/Checkout/etc/di.xml +++ b/app/code/Magento/Checkout/etc/di.xml @@ -48,6 +48,7 @@ <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" /> diff --git a/app/code/Magento/Checkout/etc/module.xml b/app/code/Magento/Checkout/etc/module.xml index 38fae3889957b4e9dd34bbeaa4d16efe10f66917..f2e9d84340a4ff8d84f9573b972ddc78f33123cd 100644 --- a/app/code/Magento/Checkout/etc/module.xml +++ b/app/code/Magento/Checkout/etc/module.xml @@ -44,6 +44,7 @@ <module name="Magento_Wishlist"/> <module name="Magento_PageCache"/> <module name="Magento_Theme"/> + <module name="Magento_Authorization"/> </depends> </module> </config> diff --git a/app/code/Magento/Checkout/etc/webapi.xml b/app/code/Magento/Checkout/etc/webapi.xml index 1ebbfdc3b68d163f446c47bbf79f367cdf3c41c9..5be1fc5caac5acdb859689754d341d8badb421d0 100644 --- a/app/code/Magento/Checkout/etc/webapi.xml +++ b/app/code/Magento/Checkout/etc/webapi.xml @@ -67,6 +67,12 @@ <resource ref="Magento_Catalog::products" /> </resources> </route> + <route url="/V1/customer/:customerId/cart" method="GET"> + <service class="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" method="getCartForCustomer"/> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> <route url="/V1/carts" method="PUT"> <service class="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" method="getCartList"/> <resources> @@ -152,7 +158,13 @@ </resources> </route> <route url="/V1/carts/:cartId/totals" method="GET"> - <service class="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" method="getTotals"/> + <service class="Magento\Checkout\Service\V1\Cart\TotalsServiceInterface" method="getTotals"/> + <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"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/view/items/renderer/downloadable.phtml b/app/code/Magento/Checkout/etc/webapi_rest/di.xml similarity index 52% rename from app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/view/items/renderer/downloadable.phtml rename to app/code/Magento/Checkout/etc/webapi_rest/di.xml index 21e394e3e56ce8a10edc436524743462cc4b1326..05087e2a829caa5df68eada243b67080dc4b3b5b 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/view/items/renderer/downloadable.phtml +++ b/app/code/Magento/Checkout/etc/webapi_rest/di.xml @@ -1,4 +1,5 @@ -<?php +<?xml version="1.0"?> +<!-- /** * Magento * @@ -21,22 +22,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -?> -<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> -<?php $_item = $this->getItem() ?> -<?php $this->setPriceDataObject($_item) ?> -<tr class="border"> - <td class="col-product"><?php echo $this->getColumnHtml($_item, 'downloadable') ?></td> - <td class="col-price"> - <?php echo $this->getColumnHtml($_item, 'price')?> - </td> - <td class="col-qty"><?php echo $_item->getQty()*1 ?></td> - <td class="col-subtotal"> - <?php echo $this->getColumnHtml($_item, 'subtotal')?> - </td> - <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> - <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> - <td class="col-total last"> - <?php echo $this->getColumnHtml($_item, 'total')?> - </td> -</tr> +--> +<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> + <type name="Magento\Checkout\Service\V1\Cart\WriteServiceInterface"> + <plugin name="admin_access" type="\Magento\Checkout\Model\Cart\Access\WritePlugin" /> + </type> +</config> diff --git a/app/code/Magento/Checkout/etc/webapi_soap/di.xml b/app/code/Magento/Checkout/etc/webapi_soap/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..05087e2a829caa5df68eada243b67080dc4b3b5b --- /dev/null +++ b/app/code/Magento/Checkout/etc/webapi_soap/di.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<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> + <type name="Magento\Checkout\Service\V1\Cart\WriteServiceInterface"> + <plugin name="admin_access" type="\Magento\Checkout\Model\Cart\Access\WritePlugin" /> + </type> +</config> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml index e4fe7fc63a01fca199b3b580f6d0f1a010e704b2..b88c21432ee005efca152bd40baa3996cc9d07cc 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml @@ -64,12 +64,12 @@ $_item = $this->getItem(); <td class="col qty"><span class="qty"><?php echo $_item->getQty() ?></span></td> <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> <td class="col subtotal excl tax"> - <?php echo $this->getRowtotalExclTaxHtml($_item); ?> + <?php echo $this->getRowTotalExclTaxHtml($_item); ?> </td> <?php endif; ?> <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> <td class="col subtotal incl tax"> - <?php echo $this->getRowtotalInclTaxHtml($_item); ?> + <?php echo $this->getRowTotalInclTaxHtml($_item); ?> </td> <?php endif; ?> </tr> diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index 050712e044196811972a0b196f613d6603b24c92..e535109311ad8b916f8d85cb496b5e335a765ed2 100644 --- a/app/code/Magento/CheckoutAgreements/composer.json +++ b/app/code/Magento/CheckoutAgreements/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-store": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-store": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index 0a450210906c9943ec3a6c825f0ad2f5df58ae95..abc36c49bc8d3ff486abba7a02ff1df109db398b 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-widget": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-email": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-widget": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-email": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index c4e60a26ee1435b2e5435f035fe4bd541fa990db..cba14ac474c13b190301c6952920b3b2d0b5e831 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -3,11 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-url-redirect": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95" + "magento/module-url-redirect": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json index b84ae5a7bcf9f92e126b7681fbe48c2085095880..7a1f9aad02ea02503205938075919fd368113d32 100644 --- a/app/code/Magento/ConfigurableImportExport/composer.json +++ b/app/code/Magento/ConfigurableImportExport/composer.json @@ -3,15 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-catalog-import-export": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-import-export": "0.1.0-alpha95", - "magento/module-configurable-product": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95" + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-catalog-import-export": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-import-export": "0.1.0-alpha96", + "magento/module-configurable-product": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php index 94e2e720151d426466ceb4d80a67baf9365ec4a2..30e01bf478bfc02d6a65eaed480f566eb5cf8e2b 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php @@ -37,36 +37,6 @@ class Configurable extends Renderer implements IdentityInterface */ const CONFIG_THUMBNAIL_SOURCE = 'checkout/cart/configurable_product_image'; - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Catalog\Helper\Product\Configuration $productConfig - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Catalog\Helper\Image $imageHelper - * @param \Magento\Core\Helper\Url $urlHelper - * @param \Magento\Framework\Message\ManagerInterface $messageManager - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Catalog\Helper\Product\Configuration $productConfig, - \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Catalog\Helper\Image $imageHelper, - \Magento\Core\Helper\Url $urlHelper, - \Magento\Framework\Message\ManagerInterface $messageManager, - array $data = array() - ) { - parent::__construct( - $context, - $productConfig, - $checkoutSession, - $imageHelper, - $urlHelper, - $messageManager, - $data - ); - $this->_isScopePrivate = true; - } - /** * Get item configurable child product * diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index 7e83d31d35c4cc42992a859e846ec46cd5134f15..3338046d8f78b3b05591d4a2bb6fe931d6474c62 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -26,6 +26,7 @@ namespace Magento\ConfigurableProduct\Block\Product\View\Type; use Magento\Customer\Helper\Session\CurrentCustomer; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -63,6 +64,11 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView */ protected $helper; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils @@ -70,6 +76,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView * @param \Magento\ConfigurableProduct\Helper\Data $helper * @param \Magento\Catalog\Helper\Product $catalogProduct * @param CurrentCustomer $currentCustomer + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( @@ -79,8 +86,10 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView \Magento\ConfigurableProduct\Helper\Data $helper, \Magento\Catalog\Helper\Product $catalogProduct, CurrentCustomer $currentCustomer, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->helper = $helper; $this->jsonEncoder = $jsonEncoder; $this->catalogProduct = $catalogProduct; @@ -226,9 +235,9 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView return 0; } - $price = $this->getCurrentStore()->convertPrice($price); + $price = $this->priceCurrency->convert($price); if ($round) { - $price = $this->getCurrentStore()->roundPrice($price); + $price = $this->priceCurrency->round($price); } return $price; diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php index 1ce75115d4368ee6349cc8e491620d6dddfa789b..d70c788bb2556df8d01acb65eef0d5bebf80e8f1 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php @@ -26,6 +26,7 @@ namespace Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\Catalog\Model\Product\PriceModifierInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; class Price extends \Magento\Catalog\Model\Product\Type\Price { @@ -40,6 +41,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param PriceCurrencyInterface $priceCurrency * @param PriceModifierInterface $priceModifier */ public function __construct( @@ -48,10 +50,11 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Event\ManagerInterface $eventManager, + PriceCurrencyInterface $priceCurrency, PriceModifierInterface $priceModifier ) { $this->priceModifier = $priceModifier; - parent::__construct($ruleFactory, $storeManager, $localeDate, $customerSession, $eventManager); + parent::__construct($ruleFactory, $storeManager, $localeDate, $customerSession, $eventManager, $priceCurrency); } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php index ce7a85a10e33c659fa2403446be6258662a9fae8..9acb5e37e60a52981db5eebecb10654b0cd1a2da 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php @@ -66,7 +66,7 @@ class AssociatedProduct extends \Magento\Catalog\Model\Resource\Product\Collecti * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -92,7 +92,7 @@ class AssociatedProduct extends \Magento\Catalog\Model\Resource\Product\Collecti \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -119,7 +119,7 @@ class AssociatedProduct extends \Magento\Catalog\Model\Resource\Product\Collecti $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php index 95dd75fbdbcfd4b3aaba5548fdda27a131fa56fb..ee194c2f413592ba2475ca261cb95ec39457c9ca 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php @@ -31,6 +31,8 @@ use Magento\Framework\Pricing\Adjustment\CalculatorInterface; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\PriceModifierInterface; use Magento\Framework\Pricing\Amount\AmountInterface; +use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Class PriceOptions @@ -50,20 +52,28 @@ class AttributePrice extends AbstractPrice implements AttributePriceInterface */ protected $storeManager; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param Product $saleableItem * @param float $quantity * @param CalculatorInterface $calculator * @param PriceModifierInterface $modifier * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( Product $saleableItem, $quantity, CalculatorInterface $calculator, PriceModifierInterface $modifier, - \Magento\Framework\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager, + PriceCurrencyInterface $priceCurrency ) { + $this->priceCurrency = $priceCurrency; $this->priceModifier = $modifier; $this->storeManager = $storeManager; parent::__construct($saleableItem, $quantity, $calculator); @@ -139,34 +149,32 @@ class AttributePrice extends AbstractPrice implements AttributePriceInterface * Get Option Value including price rule * * @param array $value - * @param string $exclude * @return AmountInterface */ public function getOptionValueModified( - array $value = [], - $exclude = \Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE + array $value = [] ) { $pricingValue = $this->getPricingValue($value); $this->product->setParentId(true); $amount = $this->priceModifier->modifyPrice($pricingValue, $this->product); - return $this->calculator->getAmount(floatval($amount), $this->product, $exclude); + $context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true]; + return $this->calculator->getAmount(floatval($amount), $this->product, null, $context); } /** * Get Option Value Amount with no Catalog Rules * * @param array $value - * @param string $exclude * @return AmountInterface */ public function getOptionValueAmount( - array $value = [], - $exclude = \Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE + array $value = [] ) { $amount = $this->getPricingValue($value); - return $this->calculator->getAmount(floatval($amount), $this->product, $exclude); + $context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true]; + return $this->calculator->getAmount(floatval($amount), $this->product, null, $context); } /** @@ -265,9 +273,9 @@ class AttributePrice extends AbstractPrice implements AttributePriceInterface return 0; } - $price = $this->storeManager->getStore()->convertPrice($price); + $price = $this->priceCurrency->convert($price); if ($round) { - $price = $this->storeManager->getStore()->roundPrice($price); + $price = $this->priceCurrency->round($price); } return $price; diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index 722d22f5713ed130ee39f6d0b7db7fc00ac48810..42dd8794a7f533af0f54d3397347233421cd8392 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -3,25 +3,24 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-catalog-rule": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-weee": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", - "magento/module-webapi": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-catalog-rule": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/module-webapi": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/etc/module.xml b/app/code/Magento/ConfigurableProduct/etc/module.xml index 0b9cba1389f59167fd782f16e6262a926e9962d1..45f5c2af24f7d777e6392123d47d7cbaf4b69a58 100644 --- a/app/code/Magento/ConfigurableProduct/etc/module.xml +++ b/app/code/Magento/ConfigurableProduct/etc/module.xml @@ -44,7 +44,6 @@ <module name="Magento_Customer" /> <module name="Magento_CatalogRule" /> <module name="Magento_Directory" /> - <module name="Magento_Weee" /> <module name="Magento_Webapi"/> </depends> </module> diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index 5ba1d3b07bf7569235d55857b5cd43df9880c72e..bf22cae32ad9dd5c40aad9460fb257823ae0ab66 100644 --- a/app/code/Magento/Contact/composer.json +++ b/app/code/Magento/Contact/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json index 67fbd0494bde24a1139f382ae0ccb35b985e62d9..7406f63fc50040eac93a9b89ea7237ab89e4c1a4 100644 --- a/app/code/Magento/Core/composer.json +++ b/app/code/Magento/Core/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-cron": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-page-cache": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-cron": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-page-cache": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index 4d8994e83cc78d9885eddb381fa89507d39926a1..72ba009dcc69a6ce7fb65776e997c8e7606be4ec 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -110,6 +110,11 @@ <argument name="cacheLifetime" xsi:type="string">86400</argument> </arguments> </type> + <type name="Magento\Framework\Event\Config\Data"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Framework\Event\Config\Reader\Proxy</argument> + </arguments> + </type> <type name="Magento\Framework\Acl\Cache"> <arguments> <argument name="cacheKey" xsi:type="string">global_acl_resources</argument> @@ -119,7 +124,7 @@ <type name="Magento\Core\Model\Theme\Collection" shared="false" /> <type name="Magento\Core\Model\Layout\Merge"> <arguments> - <argument name="fileSource" xsi:type="object">Magento\Framework\View\Layout\File\Collector\Aggregated</argument> + <argument name="fileSource" xsi:type="object">Magento\Framework\View\Layout\File\Collector\Aggregated\Proxy</argument> <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Layout</argument> </arguments> </type> @@ -277,6 +282,11 @@ <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> </arguments> </type> + <type name="Magento\Framework\App\Config\Initial"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Framework\App\Config\Initial\Reader\Proxy</argument> + </arguments> + </type> <type name="Magento\Framework\App\Config\Initial\SchemaLocator"> <arguments> <argument name="moduleName" xsi:type="string">Magento_Core</argument> @@ -287,6 +297,11 @@ <argument name="converter" xsi:type="object">Magento\Framework\App\Config\Initial\Converter</argument> </arguments> </type> + <type name="Magento\Framework\App\Route\Config"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Framework\App\Route\Config\Reader\Proxy</argument> + </arguments> + </type> <type name="Magento\Core\App\Router\Base"> <arguments> <argument name="routerId" xsi:type="string">standard</argument> @@ -333,7 +348,7 @@ </type> <type name="Magento\Framework\Object\Copy\Config\Data"> <arguments> - <argument name="reader" xsi:type="object">Magento\Framework\Object\Copy\Config\Reader</argument> + <argument name="reader" xsi:type="object">Magento\Framework\Object\Copy\Config\Reader\Proxy</argument> <argument name="cacheId" xsi:type="string">fieldset_config</argument> </arguments> </type> @@ -419,6 +434,11 @@ <type name="Magento\Framework\App\FrontController"> <plugin name="install" type="Magento\Framework\Module\Plugin\DbStatusValidator" sortOrder="40"/> </type> + <type name="Magento\Framework\Module\Plugin\DbStatusValidator"> + <arguments> + <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> + </arguments> + </type> <type name="Magento\Framework\App\Action\Action"> <plugin name="storeCheck" type="Magento\Store\App\Action\Plugin\StoreCheck" sortOrder="10"/> <plugin name="designLoader" type="Magento\Core\App\Action\Plugin\Design" sortOrder="30"/> diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index f7f0c5fbf5160d576f7fc69b3e3e237976e2dfdf..2c54b3deff58472bb72c8a5b493d5e16a0158604 100644 --- a/app/code/Magento/Cron/composer.json +++ b/app/code/Magento/Cron/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index 1167b1a964591fcc3b84fd25a3b9abc31810a4e8..3ed42a6ef46e94b73fdabfec93b06fde8061c9c6 100644 --- a/app/code/Magento/CurrencySymbol/composer.json +++ b/app/code/Magento/CurrencySymbol/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-page-cache": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-page-cache": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index ecfc6424ec88260d9e3a2e7718d74ec8c2cb8f73..ff5775d3367b7b8e9538c04d5a603810f2c1e114 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -3,28 +3,28 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-newsletter": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-wishlist": "0.1.0-alpha95", - "magento/module-index": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-review": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-page-cache": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", - "magento/module-authorization": "0.1.0-alpha95", - "magento/module-integration": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-newsletter": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-wishlist": "0.1.0-alpha96", + "magento/module-index": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-review": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-page-cache": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/module-authorization": "0.1.0-alpha96", + "magento/module-integration": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index fae0105f3303357073aae8aa3591e1bbdcecba99..f811eba8aff85eb4560e2f7c01a0057d36872486 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -111,6 +111,11 @@ </argument> </arguments> </type> + <type name="Magento\Customer\Model\Address\Config"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Customer\Model\Address\Config\Reader\Proxy</argument> + </arguments> + </type> <type name="Magento\Customer\Model\Visitor"> <arguments> <argument name="ignoredUserAgents" xsi:type="array"> diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index b49fe86e51de7cadb3e2580375c4888e507728b0..548dc13521753bc1c12f3d812dbe04c4c8be05ca 100644 --- a/app/code/Magento/CustomerImportExport/composer.json +++ b/app/code/Magento/CustomerImportExport/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-import-export": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-import-export": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index a45ad0cde17af44428ad2f5d2a4d01b1e4a53cfe..cefb80f55336d3f8c58b58f4f64f482e84a4a462 100644 --- a/app/code/Magento/DesignEditor/composer.json +++ b/app/code/Magento/DesignEditor/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-url-rewrite": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-url-rewrite": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index f78d20be33e0ce101296269b786c8794d02df172..663cd5d8450b29db623a31c1eb43dc6f0627d9c3 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-shipping": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-shipping": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Directory/Model/Currency/Filter.php b/app/code/Magento/Directory/Model/Currency/Filter.php index 6e5700f289b1624be6806f4e23843b923c24e4f1..0210959d793f785a1e5fc172e4eacced2116e687 100644 --- a/app/code/Magento/Directory/Model/Currency/Filter.php +++ b/app/code/Magento/Directory/Model/Currency/Filter.php @@ -27,6 +27,8 @@ */ namespace Magento\Directory\Model\Currency; +use Magento\Framework\Pricing\PriceCurrencyInterface; + class Filter implements \Zend_Filter_Interface { /** @@ -58,10 +60,18 @@ class Filter implements \Zend_Filter_Interface */ protected $_localeCurrency; + /** + * Price currency + * + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency + * @param PriceCurrencyInterface $priceCurrency * @param string $code * @param int $rate */ @@ -69,12 +79,14 @@ class Filter implements \Zend_Filter_Interface \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, + PriceCurrencyInterface $priceCurrency, $code, $rate = 1 ) { $this->_localeFormat = $localeFormat; $this->_storeManager = $storeManager; $this->_currency = $localeCurrency->getCurrency($code); + $this->priceCurrency = $priceCurrency; $this->_rate = $rate; } @@ -98,7 +110,7 @@ class Filter implements \Zend_Filter_Interface public function filter($value) { $value = $this->_localeFormat->getNumber($value); - $value = $this->_storeManager->getStore()->roundPrice($this->_rate * $value); + $value = $this->priceCurrency->round($this->_rate * $value); $value = sprintf("%f", $value); return $this->_currency->toCurrency($value); } diff --git a/app/code/Magento/Directory/Model/PriceCurrency.php b/app/code/Magento/Directory/Model/PriceCurrency.php index e89210b81bef7f4a3acc7d2a42a11e98745a1166..92004eca78f05c8bd37722adc98fe976e2764181 100644 --- a/app/code/Magento/Directory/Model/PriceCurrency.php +++ b/app/code/Magento/Directory/Model/PriceCurrency.php @@ -155,4 +155,15 @@ class PriceCurrency implements \Magento\Framework\Pricing\PriceCurrencyInterface } return $store; } + + /** + * Round price + * + * @param float $price + * @return float + */ + public function round($price) + { + return round($price, 2); + } } diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index 3a7c4476593230224d8fd294f51981878d71bf15..e52b58243fb299ed8a12f57cc232e55868199acf 100644 --- a/app/code/Magento/Directory/composer.json +++ b/app/code/Magento/Directory/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php b/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php index 8205fb1f2d9f60db9d35862b4589db66f250dcfa..3c916e095d9c0c13a50f876c4eee712eb9eb2b2d 100644 --- a/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php +++ b/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php @@ -29,6 +29,8 @@ */ namespace Magento\Downloadable\Block\Checkout\Cart\Item; +use Magento\Framework\Pricing\PriceCurrencyInterface; + class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer { /** @@ -45,6 +47,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer * @param \Magento\Catalog\Helper\Image $imageHelper * @param \Magento\Core\Helper\Url $urlHelper * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Downloadable\Helper\Catalog\Product\Configuration $dwnCtlgProdConfig * @param array $data */ @@ -55,6 +58,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer \Magento\Catalog\Helper\Image $imageHelper, \Magento\Core\Helper\Url $urlHelper, \Magento\Framework\Message\ManagerInterface $messageManager, + PriceCurrencyInterface $priceCurrency, \Magento\Downloadable\Helper\Catalog\Product\Configuration $dwnCtlgProdConfig, array $data = array() ) { @@ -66,6 +70,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer $imageHelper, $urlHelper, $messageManager, + $priceCurrency, $data ); } diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index b57f50f4d99af2a29532cbc8ffd7958a4c0c79d2..d4f93e34f4dc06bb68dbf05e3d9661b4733ac926 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-wishlist": "0.1.0-alpha95", - "magento/module-gift-message": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-wishlist": "0.1.0-alpha96", + "magento/module-gift-message": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_new.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_new.xml index 6b3a4ce19cfd9a14f44944ee44e0c26825aab2e0..8f0cb9bd31d14a54603106e7c71647c95ee6be1b 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_new.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_new.xml @@ -25,7 +25,6 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceBlock name="order_items"> - <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="downloadable" template="Magento_Downloadable::sales/order/creditmemo/create/items/renderer/downloadable.phtml"/> - <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_downloadable" template="sales/items/column/downloadable/creditmemo/name.phtml" group="column"/> + <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_name_downloadable" template="sales/items/column/downloadable/creditmemo/name.phtml" group="column"/> </referenceBlock> </page> diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml index 6b3a4ce19cfd9a14f44944ee44e0c26825aab2e0..8f0cb9bd31d14a54603106e7c71647c95ee6be1b 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml @@ -25,7 +25,6 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceBlock name="order_items"> - <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="downloadable" template="Magento_Downloadable::sales/order/creditmemo/create/items/renderer/downloadable.phtml"/> - <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_downloadable" template="sales/items/column/downloadable/creditmemo/name.phtml" group="column"/> + <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_name_downloadable" template="sales/items/column/downloadable/creditmemo/name.phtml" group="column"/> </referenceBlock> </page> diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_view.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_view.xml index 2a5688ee41afee22dfd8dbc0050d6b6bb51d3b26..079d6594d2bf597b2218149c44ba43cdaa62d6f2 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_view.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_creditmemo_view.xml @@ -25,7 +25,6 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceBlock name="creditmemo_items"> - <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="downloadable" template="Magento_Downloadable::sales/order/creditmemo/view/items/renderer/downloadable.phtml"/> - <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_downloadable" template="sales/items/column/downloadable/creditmemo/name.phtml" group="column"/> + <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_name_downloadable" template="sales/items/column/downloadable/creditmemo/name.phtml" group="column"/> </referenceBlock> </page> diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_new.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_new.xml index f13d76ccd551fd2501a44cff80cdad39e7c2e380..a28086b3f8d56b6762e3ed9e13d050968905841d 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_new.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_new.xml @@ -25,7 +25,6 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceBlock name="order_items"> - <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="downloadable" template="Magento_Downloadable::sales/order/invoice/create/items/renderer/downloadable.phtml"/> - <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_downloadable" template="sales/items/column/downloadable/invoice/name.phtml" group="column"/> + <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_name_downloadable" template="sales/items/column/downloadable/invoice/name.phtml" group="column"/> </referenceBlock> </page> diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_updateqty.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_updateqty.xml index f13d76ccd551fd2501a44cff80cdad39e7c2e380..a28086b3f8d56b6762e3ed9e13d050968905841d 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_updateqty.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_updateqty.xml @@ -25,7 +25,6 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceBlock name="order_items"> - <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="downloadable" template="Magento_Downloadable::sales/order/invoice/create/items/renderer/downloadable.phtml"/> - <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_downloadable" template="sales/items/column/downloadable/invoice/name.phtml" group="column"/> + <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_name_downloadable" template="sales/items/column/downloadable/invoice/name.phtml" group="column"/> </referenceBlock> </page> diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_view.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_view.xml index 46794994ac263db96a9ad0bea136ff1dccdf638a..dffde9fb6d3112e2950c257fa0060b6e28cc92da 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_view.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_invoice_view.xml @@ -25,7 +25,6 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceBlock name="invoice_items"> - <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="downloadable" template="Magento_Downloadable::sales/order/invoice/view/items/renderer/downloadable.phtml"/> - <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_downloadable" template="sales/items/column/downloadable/invoice/name.phtml" group="column"/> + <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_name_downloadable" template="sales/items/column/downloadable/invoice/name.phtml" group="column"/> </referenceBlock> </page> diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_view.xml index da411eed580d4c751c24115d24b93eee3a2c9dd2..4f5bd3ae97696b150682e0c2395ebb770a90cdc7 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_view.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/sales_order_view.xml @@ -25,7 +25,6 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceBlock name="order_items"> - <block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="downloadable" template="Magento_Downloadable::sales/order/view/items/renderer/downloadable.phtml"/> - <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_downloadable" template="sales/items/column/downloadable/name.phtml" group="column"/> + <block class="Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name" name="column_name_downloadable" template="sales/items/column/downloadable/name.phtml" group="column"/> </referenceBlock> </page> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/create/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/create/items/renderer/downloadable.phtml deleted file mode 100644 index 94908c13403d68e95189514931cac119361617de..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/create/items/renderer/downloadable.phtml +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -?> -<?php /** @var \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer $this */?> -<?php $_item = $this->getItem() ?> -<?php $this->setPriceDataObject($_item); ?> -<tr class="border"> - <td class="col-product"><?php echo $this->getColumnHtml($_item, 'downloadable') ?></td> - <td class="col-price"> - <?php echo $this->getColumnHtml($_item, 'price')?> - </td> - <td class="col-ordered-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> - <?php if ($this->canParentReturnToStock($_item)) : ?> - <td class="col-return-to-stock"> - <?php if ($this->canReturnItemToStock($_item)) : ?> - <input type="checkbox" name="creditmemo[items][<?php echo $_item->getOrderItemId() ?>][back_to_stock]" value="1"<?php if ($_item->getBackToStock()):?> checked<?php endif;?>/> - <?php endif; ?> - </td> - <?php endif; ?> - <td class="col-refund"> - <?php if ($this->canEditQty()) : ?> - <input type="text" class="input-text qty-input" name="creditmemo[items][<?php echo $_item->getOrderItemId() ?>][qty]" value="<?php echo $_item->getQty()*1 ?>"/> - <?php else : ?> - <?php echo $_item->getQty()*1 ?> - <?php endif; ?> - </td> - <td class="col-subtotal"> - <?php echo $this->getColumnHtml($_item, 'subtotal')?> - </td> - <td class="col-tax-amount"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> - <td class="col-discont"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> - <td class="col-total last"> - <?php echo $this->getColumnHtml($_item, 'total')?> - </td> -</tr> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/create/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/create/items/renderer/downloadable.phtml deleted file mode 100644 index 6092b89ef9549e7f42ee5631dbede403bc02c36d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/create/items/renderer/downloadable.phtml +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -?> -<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> -<?php $_item = $this->getItem() ?> -<?php $this->setPriceDataObject($_item)?> -<tr class="border"> - <td class="col-product"><?php echo $this->getColumnHtml($_item, 'downloadable') ?></td> - <td class="col-price"> - <?php echo $this->getColumnHtml($_item, 'price')?> - </td> - <td class="col-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> - <td class="col-qty-invoice"> - <?php if ($this->canEditQty()) : ?> - <input type="text" class="input-text qty-input" name="invoice[items][<?php echo $_item->getOrderItemId() ?>]" value="<?php echo $_item->getQty()*1 ?>"/> - <?php else : ?> - <?php echo $_item->getQty()*1 ?> - <?php endif; ?> - </td> - <td class="col-subtotal"> - <?php echo $this->getColumnHtml($_item, 'subtotal')?> - </td> - <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> - <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> - <td class="col-total last"> - <?php echo $this->getColumnHtml($_item, 'total')?> - </td> -</tr> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/view/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/view/items/renderer/downloadable.phtml deleted file mode 100644 index 0ccf9b73fd35763a946fcc950e2a85c549c7d86b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/view/items/renderer/downloadable.phtml +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -?> -<?php /** @var $this \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer */ ?> -<?php $_item = $this->getItem() ?> -<?php $this->setPriceDataObject($_item) ?> -<tr<?php if ($this->canDisplayGiftmessage()): ?> class="border"<?php endif; ?>> - <td class="giftmessage-single-item col-product"> - <?php if ($this->canDisplayContainer()): ?> - <div id="<?php echo $this->getHtmlId() ?>" class="item-container"> - <?php endif; ?> - <div class="item-text"> - <?php echo $this->getColumnHtml($_item, 'downloadable') ?> - </div> - <?php if ($this->canDisplayContainer()): ?> - </div> - <?php endif ?> - </td> - <td class="col-status"><?php echo $_item->getStatus() ?></td> - <td class="col-price-original"><?php echo $this->displayPriceAttribute('original_price') ?></td> - <td class="col-price"> - <?php echo $this->getColumnHtml($_item, 'price')?> - </td> - <td class="col-ordered-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> - <td class="col-subtotal"> - <?php echo $this->getColumnHtml($_item, 'subtotal')?> - </td> - <td class="col-tax-amount"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> - <td class="col-tax-percent"><?php echo $this->displayTaxPercent($_item) ?></td> - <td class="col-discont"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> - <td class="col-total last"> - <?php echo $this->getColumnHtml($_item, 'total')?> - </td> -</tr> diff --git a/app/code/Magento/Downloadable/view/frontend/templates/sales/order/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/templates/sales/order/items/renderer/downloadable.phtml index 5fd5789eba47455b769079f0651d29ae37eac198..46b9e5481a2525b0e4197297a478c8c02312d2fe 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/sales/order/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/sales/order/items/renderer/downloadable.phtml @@ -113,12 +113,4 @@ <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> <?php echo $this->getItemRowTotalHtml(); ?> </td> - <?php /* - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <th class="a-right"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?></th> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <th class="a-right"><?php echo $this->getOrder()->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem())); ?></th> - <?php endif; ?> - */ ?> </tr> diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index 7937cc3ea93daee1819978cc55ea57c2969106fa..a3e663f3090606fd35827849170519a0f67b3d75 100644 --- a/app/code/Magento/Eav/composer.json +++ b/app/code/Magento/Eav/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Eav/etc/di.xml b/app/code/Magento/Eav/etc/di.xml index 4fb09a1fc82365ca6d5266b711efb9ec2f1909ec..6fb75afb1a980cbba20dc72b437c8e1e58a5f605 100644 --- a/app/code/Magento/Eav/etc/di.xml +++ b/app/code/Magento/Eav/etc/di.xml @@ -25,6 +25,11 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Eav\Model\Entity\Setup\PropertyMapperInterface" type="Magento\Eav\Model\Entity\Setup\PropertyMapper\Composite" /> + <type name="Magento\Eav\Model\Entity\Attribute\Config"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Eav\Model\Entity\Attribute\Config\Reader\Proxy</argument> + </arguments> + </type> <type name="Magento\Eav\Model\Resource\Helper"> <arguments> <argument name="modulePrefix" xsi:type="string">eav</argument> diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index f9d14e6c5a9c9250cf7a52cfd116df187fb29895..7a66e13c43e3aeda2f0779cfd3fba52fc1e2e038 100644 --- a/app/code/Magento/Email/composer.json +++ b/app/code/Magento/Email/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/etc/frontend/di.xml b/app/code/Magento/Email/etc/frontend/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..291e1a6ba296d4f08cffb2fcf6ffcb30e7a94217 --- /dev/null +++ b/app/code/Magento/Email/etc/frontend/di.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Widget\Model\Template\Filter"> + <arguments> + <argument name="backendUrlBuilder" xsi:type="object">Magento\Backend\Model\UrlInterface\Proxy</argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 852b8cd0614c30968d4045bc792f03eeca412185..f80702833742f74a610866c036f9e8b6522684b3 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-shipping": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-shipping": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/GiftMessage/Service/V1/ReadService.php b/app/code/Magento/GiftMessage/Service/V1/ReadService.php index 0cff21aafd1c72d70914c8d55c50a7460b00993e..152f05f061e8c74bf061a71e31ed2882602daf53 100644 --- a/app/code/Magento/GiftMessage/Service/V1/ReadService.php +++ b/app/code/Magento/GiftMessage/Service/V1/ReadService.php @@ -38,11 +38,6 @@ class ReadService implements ReadServiceInterface */ protected $messageFactory; - /** - * @var \Magento\GiftMessage\Service\V1\Data\MessageBuilder - */ - protected $builder; - /** * @var \Magento\GiftMessage\Service\V1\Data\MessageMapper */ @@ -51,18 +46,15 @@ class ReadService implements ReadServiceInterface /** * @param \Magento\Sales\Model\QuoteRepository $quoteRepository * @param \Magento\GiftMessage\Model\MessageFactory $messageFactory - * @param Data\MessageBuilder $builder * @param \Magento\GiftMessage\Service\V1\Data\MessageMapper $messageMapper */ public function __construct( \Magento\Sales\Model\QuoteRepository $quoteRepository, \Magento\GiftMessage\Model\MessageFactory $messageFactory, - \Magento\GiftMessage\Service\V1\Data\MessageBuilder $builder, \Magento\GiftMessage\Service\V1\Data\MessageMapper $messageMapper ) { $this->quoteRepository = $quoteRepository; $this->messageFactory = $messageFactory; - $this->builder = $builder; $this->messageMapper = $messageMapper; } diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index 70536951d15edd84c4362d056664a5b78917a72f..7cfb649cea5119ca4e12fe2b3f07d1ebc66d294a 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-multishipping": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-multishipping": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index 71158c07b85744753194f1bc4a0f7066f7294cde..e37ee726ebb038813bb0faf2358bf8ddaaaf2fd0 100644 --- a/app/code/Magento/GoogleAdwords/composer.json +++ b/app/code/Magento/GoogleAdwords/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 1d7cdd63d97dcaeb126f2e619efe3ad6cc0f040d..ab0d0972e6bda7ed347ed59ba85328c89070960d 100644 --- a/app/code/Magento/GoogleAnalytics/composer.json +++ b/app/code/Magento/GoogleAnalytics/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index 56f957632a58b5b950a2eb7124e343a74797c98f..5fcca9ffc28b74a6cbbef6cd4e0c8cdb1161bb64 100644 --- a/app/code/Magento/GoogleOptimizer/composer.json +++ b/app/code/Magento/GoogleOptimizer/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-google-analytics": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-google-analytics": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php index 30253a5836f98423e2a369824d4ee34b9718713c..e322f584deccda6638f07932a51b0ec1a8e4a2fd 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php @@ -25,6 +25,7 @@ namespace Magento\GoogleShopping\Model\Attribute; use Magento\Catalog\Model\Product; use Magento\Framework\Gdata\Gshopping\Entry; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Tax\Model\Config; /** @@ -70,6 +71,11 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute */ protected $_customerGroupService; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -84,6 +90,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute * @param \Magento\Customer\Service\V1\CustomerGroupService $customerGroupService * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\Data\Collection\Db $resourceCollection + * @param PriceCurrencyInterface $priceCurrency * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -101,9 +108,11 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute \Magento\GoogleShopping\Model\Config $config, \Magento\Customer\Service\V1\CustomerGroupService $customerGroupService, \Magento\Catalog\Helper\Data $catalogData, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_storeManager = $storeManager; $this->_config = $config; $this->_taxData = $taxData; @@ -186,12 +195,12 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute protected function _setAttributePrice($entry, $product, $value, $name = 'price') { $store = $this->_storeManager->getStore($product->getStoreId()); - $price = $store->convertPrice($value); + $price = $this->priceCurrency->convert($value, $store); return $this->_setAttribute( $entry, $name, self::ATTRIBUTE_TYPE_FLOAT, - sprintf('%.2f', $store->roundPrice($price)), + sprintf('%.2f', $this->priceCurrency->round($price)), $store->getDefaultCurrencyCode() ); } diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 12d9330d1294aaee04dc0c1a95e5300797fb4211..f457471c4f18ac2d80273f63d74592fe51bd76e3 100644 --- a/app/code/Magento/GoogleShopping/composer.json +++ b/app/code/Magento/GoogleShopping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json index 766e679ced63d54f682e92fc46175fc7476be472..9387c28ecddfce9f36c6f7aae3fe5e5fce13afa3 100644 --- a/app/code/Magento/GroupedImportExport/composer.json +++ b/app/code/Magento/GroupedImportExport/composer.json @@ -3,15 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-import-export": "0.1.0-alpha95", - "magento/module-catalog-import-export": "0.1.0-alpha95", - "magento/module-grouped-product": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95" + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-import-export": "0.1.0-alpha96", + "magento/module-catalog-import-export": "0.1.0-alpha96", + "magento/module-grouped-product": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php b/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php index de8da79bed79a1c4dfd61d8ded10d7eff8e77ccf..4f85d9655ceaa2c9409e02c422d485799a520650 100644 --- a/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php @@ -37,36 +37,6 @@ class Grouped extends Renderer implements IdentityInterface */ const CONFIG_THUMBNAIL_SOURCE = 'checkout/cart/grouped_product_image'; - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Catalog\Helper\Product\Configuration $productConfig - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Catalog\Helper\Image $imageHelper - * @param \Magento\Core\Helper\Url $urlHelper - * @param \Magento\Framework\Message\ManagerInterface $messageManager - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Catalog\Helper\Product\Configuration $productConfig, - \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Catalog\Helper\Image $imageHelper, - \Magento\Core\Helper\Url $urlHelper, - \Magento\Framework\Message\ManagerInterface $messageManager, - array $data = array() - ) { - parent::__construct( - $context, - $productConfig, - $checkoutSession, - $imageHelper, - $urlHelper, - $messageManager, - $data - ); - $this->_isScopePrivate = true; - } - /** * Get item grouped product * diff --git a/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts/ListAssociatedProducts.php b/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts/ListAssociatedProducts.php index c76268bf652ca2a7da8885871065df5943679087..933074ac8e19e8742543e31ff6622f36daf1b584 100644 --- a/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts/ListAssociatedProducts.php +++ b/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts/ListAssociatedProducts.php @@ -38,17 +38,25 @@ class ListAssociatedProducts extends \Magento\Backend\Block\Template */ protected $_registry; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, array $data = array() ) { parent::__construct($context, $data); + $this->priceCurrency = $priceCurrency; $this->_registry = $registry; } @@ -69,7 +77,7 @@ class ListAssociatedProducts extends \Magento\Backend\Block\Template 'id' => $product->getId(), 'sku' => $product->getSku(), 'name' => $product->getName(), - 'price' => $this->_storeManager->getStore()->formatPrice($product->getPrice(), false), + 'price' => $this->priceCurrency->format($product->getPrice(), false), 'qty' => $product->getQty(), 'position' => $product->getPosition() ); diff --git a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php index dfd18080b65712d3d9c3ef02500c8db13ca5c4ff..e37b6152e90f93cd0db888688d64b92b87299d23 100644 --- a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php +++ b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php @@ -55,7 +55,7 @@ class AssociatedProductsCollection extends \Magento\Catalog\Model\Resource\Produ * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -80,7 +80,7 @@ class AssociatedProductsCollection extends \Magento\Catalog\Model\Resource\Produ \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -105,7 +105,7 @@ class AssociatedProductsCollection extends \Magento\Catalog\Model\Resource\Produ $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index 9058151754d08f843d0018a18c080b04f44d28e7..b0fba94c66a2357d9577c013ddd59d721dca829f 100644 --- a/app/code/Magento/GroupedProduct/composer.json +++ b/app/code/Magento/GroupedProduct/composer.json @@ -3,22 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedProduct/etc/module.xml b/app/code/Magento/GroupedProduct/etc/module.xml index 3363c1f1cb2c10a49036363174e94e180389759d..c6b6ca0063ee5c94999a3b1467721c796248c1f2 100644 --- a/app/code/Magento/GroupedProduct/etc/module.xml +++ b/app/code/Magento/GroupedProduct/etc/module.xml @@ -36,7 +36,6 @@ <module name="Magento_CatalogInventory" /> <module name="Magento_Sales" /> <module name="Magento_Core" /> - <module name="Magento_Tax" /> <module name="Magento_Checkout" /> <module name="Magento_Backend" /> <module name="Magento_Eav" /> diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/templates/catalog/product/composite/fieldset/grouped.phtml b/app/code/Magento/GroupedProduct/view/adminhtml/templates/catalog/product/composite/fieldset/grouped.phtml index e08864f013854a4133aead41f0c5fd3f58d01877..7d67666d138b7bb891396e9036a86e8b63b52308 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/templates/catalog/product/composite/fieldset/grouped.phtml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/templates/catalog/product/composite/fieldset/grouped.phtml @@ -53,7 +53,6 @@ <?php if ($_hasAssociatedProducts): ?> <?php $i = 0 ?> <?php foreach ($_associatedProducts as $_item): ?> - <?php $_finalPriceInclTax = $this->helper('Magento\Catalog\Helper\Data')->getTaxPrice($_item, $_item->getFinalPrice(), true) ?> <tr class="<?php echo (++$i % 2) ? 'even' : 'odd' ?>"> <td class="col-id"><?php echo $_item->getId() ?></td> <td class="col-sku"><?php echo $this->escapeHtml($_item->getSku()) ?></td> diff --git a/app/code/Magento/GroupedProduct/view/frontend/templates/product/price.phtml b/app/code/Magento/GroupedProduct/view/frontend/templates/product/price.phtml deleted file mode 100644 index 7199a5fc7ed41c300a8e4174d33bd507a1309406..0000000000000000000000000000000000000000 --- a/app/code/Magento/GroupedProduct/view/frontend/templates/product/price.phtml +++ /dev/null @@ -1,85 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -/** - * Template for displaying grouped product price in different places (products grid, product view page etc) - */ -?> -<?php -/* @var $_coreHelper \Magento\Core\Helper\Data */ -$_coreHelper = $this->helper('Magento\Core\Helper\Data'); -/* @var $taxHelper \Magento\Tax\Helper\Data */ -$taxHelper = $this->helper('Magento\Tax\Helper\Data'); -/* @var $catalogHelper \Magento\Catalog\Helper\Data */ -$catalogHelper = $this->helper('Magento\Catalog\Helper\Data'); - -$_product = $this->getProduct(); -$_id = $_product->getId(); -$_minimalPriceValue = $_product->getMinimalPrice(); -$showMinPrice = $this->getDisplayMinimalPrice(); - -if ($showMinPrice && $_minimalPriceValue) { - $_exclTax = $catalogHelper->getTaxPrice($_product, $_minimalPriceValue); - $_inclTax = $catalogHelper->getTaxPrice($_product, $_minimalPriceValue, true); - $price = $showMinPrice ? $_minimalPriceValue : 0; -} else { - $price = $_product->getFinalPrice(); - $_exclTax = $catalogHelper->getTaxPrice($_product, $price); - $_inclTax = $catalogHelper->getTaxPrice($_product, $price, true); -} -?> - -<?php if ($price): ?> - <div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer"> - <p<?php if ($showMinPrice): ?> class="minimal-price"<?php endif ?>> - <?php if ($showMinPrice): ?> - <span class="price-label"><?php echo __('Starting at:') ?></span> - <?php endif ?> - <?php if ($taxHelper->displayBothPrices()): ?> - <span class="price-excluding-tax"> - <span class="label"><?php echo __('Excl. Tax:') ?></span> - <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>" itemprop="price"> - <?php echo $_coreHelper->currency($_exclTax, true, false) ?> - </span> - </span> - <span class="price-including-tax"> - <span class="label"><?php echo __('Incl. Tax:') ?></span> - <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> - <?php echo $_coreHelper->currency($_inclTax, true, false) ?> - </span> - </span> - <?php else: ?> - <?php - $_showPrice = $_inclTax; - if (!$taxHelper->displayPriceIncludingTax()) { - $_showPrice = $_exclTax; - } - ?> - <span class="price" id="product-minimal-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>" itemprop="price"> - <?php echo $_coreHelper->currency($_showPrice, true, false) ?> - </span> - <?php endif; ?> - </p> - </div> -<?php endif; ?> diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index f2211bd99785d102587b5a761841934d746b4906..35e9b69c05d60e3044dd5b52aa70ce229d8eb3ae 100644 --- a/app/code/Magento/ImportExport/composer.json +++ b/app/code/Magento/ImportExport/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-indexer": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-indexer": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Index/composer.json b/app/code/Magento/Index/composer.json index 7eedb06bfd4b46d96773e981120551d40b0915f3..5cd219b4584643f46682e502fd02490e73a6dd89 100644 --- a/app/code/Magento/Index/composer.json +++ b/app/code/Magento/Index/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index 866f2f5b127ed8991d4ce63474a3cfba46798723..fa1728a98e0ed66142cbcfb2bcbdb2265bc187ed 100644 --- a/app/code/Magento/Indexer/composer.json +++ b/app/code/Magento/Indexer/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-page-cache": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-page-cache": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Install/composer.json b/app/code/Magento/Install/composer.json index 5bea19a8a3ae3610b4545c77c675d571fcd4fdf5..94f9c15eff73ad4180d1a2041a41c96e24ccd909 100644 --- a/app/code/Magento/Install/composer.json +++ b/app/code/Magento/Install/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-user": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-user": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index afe75132936fd40da68ec286c8f1b3bd31c9d23a..effb8a631bc25d084025a3a66f0411287190a778 100644 --- a/app/code/Magento/Integration/composer.json +++ b/app/code/Magento/Integration/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-user": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", - "magento/module-authorization": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-user": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/module-authorization": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index 7d6c1dff5077711ce259499eb9796cda98d8326b..eb767363badb5db2313686d9bfb4687019c8c622 100644 --- a/app/code/Magento/LayeredNavigation/composer.json +++ b/app/code/Magento/LayeredNavigation/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index 1a2c5bb38194cc2416d24662d701ccb8689a34b7..83aa5c46e14f3d36297eaa52c780211672d54c28 100644 --- a/app/code/Magento/Log/composer.json +++ b/app/code/Magento/Log/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Multishipping/Block/Checkout/Overview.php b/app/code/Magento/Multishipping/Block/Checkout/Overview.php index b2ef3b2f96ae25c96c7cce328d0a520315a69cfd..7355583ef19fb24b99d8d368156aa29088bcd508 100644 --- a/app/code/Magento/Multishipping/Block/Checkout/Overview.php +++ b/app/code/Magento/Multishipping/Block/Checkout/Overview.php @@ -23,6 +23,7 @@ */ namespace Magento\Multishipping\Block\Checkout; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Quote\Address; /** @@ -179,7 +180,7 @@ class Overview extends \Magento\Sales\Block\Items\AbstractItems */ public function formatPrice($price) { - return $this->getQuote()->getStore()->formatPrice($price); + return $this->pirceCurrency->format($price, true, PriceCurrencyInterface::DEFAULT_PRECISION, $this->getQuote()->getStore()); } /** diff --git a/app/code/Magento/Multishipping/Block/Checkout/Shipping.php b/app/code/Magento/Multishipping/Block/Checkout/Shipping.php index 6e0ed078a62a6d7351c2064f153e5cb9ae816553..f74e00187f24db7db481708072bd2bc9d7c41f48 100644 --- a/app/code/Magento/Multishipping/Block/Checkout/Shipping.php +++ b/app/code/Magento/Multishipping/Block/Checkout/Shipping.php @@ -23,6 +23,7 @@ */ namespace Magento\Multishipping\Block\Checkout; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Quote\Address; /** @@ -42,11 +43,17 @@ class Shipping extends \Magento\Sales\Block\Items\AbstractItems */ protected $_taxHelper; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Filter\Object\GridFactory $filterGridFactory * @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping * @param \Magento\Tax\Helper\Data $taxHelper + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( @@ -54,8 +61,10 @@ class Shipping extends \Magento\Sales\Block\Items\AbstractItems \Magento\Framework\Filter\Object\GridFactory $filterGridFactory, \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping, \Magento\Tax\Helper\Data $taxHelper, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_taxHelper = $taxHelper; $this->_filterGridFactory = $filterGridFactory; $this->_multishipping = $multishipping; @@ -200,9 +209,11 @@ class Shipping extends \Magento\Sales\Block\Items\AbstractItems */ public function getShippingPrice($address, $price, $flag) { - return $address->getQuote()->getStore()->convertPrice( + return $this->priceCurrency->convertAndFormat( $this->_taxHelper->getShippingPrice($price, $flag, $address), - true + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $address->getQuote()->getStore() ); } diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index f69ff209750a714e4590c7d3bd4dd2a5d6d6617c..f8ec20a86afc84a6cad3d511e6b03abf2686cfa6 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -24,6 +24,7 @@ namespace Magento\Multishipping\Model\Checkout\Type; use Magento\Customer\Service\V1\CustomerAddressServiceInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** @@ -109,6 +110,11 @@ class Multishipping extends \Magento\Framework\Object */ protected $orderSender; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession @@ -123,6 +129,7 @@ class Multishipping extends \Magento\Framework\Object * @param \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification * @param \Magento\Multishipping\Helper\Data $helper * @param OrderSender $orderSender + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( @@ -139,6 +146,7 @@ class Multishipping extends \Magento\Framework\Object \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, \Magento\Multishipping\Helper\Data $helper, OrderSender $orderSender, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { $this->_eventManager = $eventManager; @@ -154,6 +162,7 @@ class Multishipping extends \Magento\Framework\Object $this->_orderFactory = $orderFactory; $this->_customerAddressService = $customerAddressService; $this->orderSender = $orderSender; + $this->priceCurrency = $priceCurrency; parent::__construct($data); $this->_init(); } @@ -557,7 +566,7 @@ class Multishipping extends \Magento\Framework\Object } $order->setPayment($this->_quote->paymentToOrderPayment($quote->getPayment())); - if ($this->_storeManager->getStore()->roundPrice($address->getGrandTotal()) == 0) { + if ($this->priceCurrency->round($address->getGrandTotal()) == 0) { $order->getPayment()->setMethod('free'); } diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index d7b017fc380de2959325fed2bc06e7d4b6b125f6..1af5f787da71187feedeb6f25ff812af7efaf6d9 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -3,20 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-weee": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Multishipping/etc/module.xml b/app/code/Magento/Multishipping/etc/module.xml index 2002818416e401d4e75a15ceeda36654b532f3fc..8627a0baa4cfc2eb9cc8554a91d47d6ba5c287cf 100644 --- a/app/code/Magento/Multishipping/etc/module.xml +++ b/app/code/Magento/Multishipping/etc/module.xml @@ -38,7 +38,6 @@ <module name="Magento_Payment"/> <module name="Magento_Tax"/> <module name="Magento_Customer"/> - <module name="Magento_Weee"/> <module name="Magento_Theme"/> </depends> </module> diff --git a/app/code/Magento/Multishipping/view/frontend/templates/checkout/overview/item.phtml b/app/code/Magento/Multishipping/view/frontend/templates/checkout/overview/item.phtml index a05c6fbba58695e2a5d2a53b809bd8267f6192f2..5c6d7e287d04bb3c35cc1948306e2710a4aabe18 100644 --- a/app/code/Magento/Multishipping/view/frontend/templates/checkout/overview/item.phtml +++ b/app/code/Magento/Multishipping/view/frontend/templates/checkout/overview/item.phtml @@ -29,51 +29,14 @@ * @see \Magento\Checkout\Block\Cart\Item\Renderer */ ?> +<?php /** @var $this Magento\Checkout\Block\Cart\Item\Renderer */ ?> <?php $_item = $this->getItem() ?> <tr> <td class="col item"><?php echo $this->getRenderedBlock()->getItemHtml($_item) ?></td> <?php /* Excluding Tax */ ?> <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> <td class="col price excl tax"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getCalculationPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount'],true,true); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount_incl_tax'],true,true); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount_incl_tax'],true,true); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - </div> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <div class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $_item->getId(); ?>"}'> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span> - </div> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getUnitPriceExclTaxHtml($_item); ?> </td> <?php endif; ?> <?php /* // Excluding Tax */ ?> @@ -81,44 +44,7 @@ <?php /* Including Tax */ ?> <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> <td class="col price incll tax"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount'],true,true); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount_incl_tax'],true,true); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount_incl_tax'],true,true); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </div> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <div class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $_item->getId(); ?>"}'> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - </div> - <?php endif; ?> - <?php endif; ?> - + <?php echo $this->getUnitPriceInclTaxHtml($_item); ?> </td> <?php endif; ?> <?php /* // Including Tax */ ?> @@ -126,43 +52,7 @@ <?php /* Excluding Tax Subtotal */ ?> <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> <td class="col subtotal excl tax"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount'],true,true); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </div> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <div class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> - <span class="weee"><?php echo __('Total'); ?>:<br /> <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - </div> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getRowTotalExclTaxHtml($_item); ?> </td> <?php endif; ?> <?php /* //Excluding Tax Subtotal */ ?> @@ -170,44 +60,7 @@ <?php /* Including Tax Subtotal */ ?> <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> <td class="col subtotal incl tax"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount'],true,true); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="weee"><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </div> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <div class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> - <span class="weee"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - </div> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getRowTotalInclTaxHtml($_item); ?> </td> <?php endif; ?> <?php /* //Including Tax Subtotal */ ?> diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 01d876cb1f21fc3729995b260157ac8a77f685c2..b21997e27c9645e1857093f4d50104ef55a321bb 100644 --- a/app/code/Magento/Newsletter/composer.json +++ b/app/code/Magento/Newsletter/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-widget": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-email": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-cron": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-widget": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-email": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-cron": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 9a025f1dbaa6a0d84a06cb2788f0dc3b102cc31a..dfecdfa001fe3b678e222bcb4dcf566e7c82193d 100644 --- a/app/code/Magento/OfflinePayments/composer.json +++ b/app/code/Magento/OfflinePayments/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-payment": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 03fa0cfd628ab606189cfb69e7c186b7ad3abfc8..efc97818ad1edf0115cf9181e7268c0e0b100fb8 100644 --- a/app/code/Magento/OfflineShipping/composer.json +++ b/app/code/Magento/OfflineShipping/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-shipping": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-sales-rule": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-shipping": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-sales-rule": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Ogone/composer.json b/app/code/Magento/Ogone/composer.json index c6baf06222845bfcd6c83d407f6e9f803bb3b3b1..bd859235d5b86a22ab41890d3ea532a7136c9ca5 100644 --- a/app/code/Magento/Ogone/composer.json +++ b/app/code/Magento/Ogone/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/PageCache/Model/Observer.php b/app/code/Magento/PageCache/Model/Observer.php deleted file mode 100644 index eade45976adc82dfe98d1c7963e254f291af399b..0000000000000000000000000000000000000000 --- a/app/code/Magento/PageCache/Model/Observer.php +++ /dev/null @@ -1,216 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\PageCache\Model; - -/** - * Class Observer - */ -class Observer -{ - /** - * Application config object - * - * @var \Magento\PageCache\Model\Config - */ - protected $_config; - - /** - * @var \Magento\Framework\App\PageCache\Cache - */ - protected $_cache; - - /** - * @var \Magento\PageCache\Helper\Data - */ - protected $_helper; - - /** - * @var \Magento\Framework\App\Cache\TypeListInterface - */ - protected $_typeList; - - /** - * @var \Magento\Framework\Session\Generic - */ - protected $_session; - - /** - * @var \Magento\Framework\Escaper - */ - protected $_escaper; - - /** - * @var \Magento\Framework\App\PageCache\FormKey - */ - protected $_formKey; - - /** - * Constructor - * - * @param Config $config - * @param \Magento\Framework\App\PageCache\Cache $cache - * @param \Magento\PageCache\Helper\Data $helper - * @param \Magento\Framework\App\Cache\TypeListInterface $typeList - * @param \Magento\Framework\Session\Generic $session - * @param \Magento\Framework\App\PageCache\FormKey $formKey - * @param \Magento\Framework\Escaper $escaper - */ - public function __construct( - \Magento\PageCache\Model\Config $config, - \Magento\Framework\App\PageCache\Cache $cache, - \Magento\PageCache\Helper\Data $helper, - \Magento\Framework\App\Cache\TypeListInterface $typeList, - \Magento\Framework\App\PageCache\FormKey $formKey, - \Magento\Framework\Session\Generic $session, - \Magento\Framework\Escaper $escaper - ) { - $this->_config = $config; - $this->_cache = $cache; - $this->_helper = $helper; - $this->_typeList = $typeList; - $this->_session = $session; - $this->_formKey = $formKey; - $this->_escaper = $escaper; - } - - /** - * Add comment cache containers to private blocks - * Blocks are wrapped only if page is cacheable - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function processLayoutRenderElement(\Magento\Framework\Event\Observer $observer) - { - $event = $observer->getEvent(); - /** @var \Magento\Framework\View\Layout $layout */ - $layout = $event->getLayout(); - if ($layout->isCacheable() && $this->_config->isEnabled()) { - $name = $event->getElementName(); - $block = $layout->getBlock($name); - $transport = $event->getTransport(); - if ($block instanceof \Magento\Framework\View\Element\AbstractBlock) { - $blockTtl = $block->getTtl(); - $varnishIsEnabledFlag = ($this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH); - $output = $transport->getData('output'); - if ($varnishIsEnabledFlag && isset($blockTtl)) { - $output = $this->_wrapEsi($block); - } elseif ($block->isScopePrivate()) { - $output = sprintf( - '<!-- BLOCK %1$s -->%2$s<!-- /BLOCK %1$s -->', - $block->getNameInLayout(), - $output - ); - } - $transport->setData('output', $output); - } - } - } - - /** - * Replace the output of the block, containing ttl attribute, with ESI tag - * - * @param \Magento\Framework\View\Element\AbstractBlock $block - * @return string - */ - protected function _wrapEsi(\Magento\Framework\View\Element\AbstractBlock $block) - { - $url = $block->getUrl( - 'page_cache/block/esi', - array( - 'blocks' => json_encode(array($block->getNameInLayout())), - 'handles' => json_encode($this->_helper->getActualHandles()) - ) - ); - return sprintf('<esi:include src="%s" />', $url); - } - - /** - * If Built-In caching is enabled it collects array of tags - * of incoming object and asks to clean cache. - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function flushCacheByTags(\Magento\Framework\Event\Observer $observer) - { - if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN && $this->_config->isEnabled()) { - $object = $observer->getEvent()->getObject(); - if ($object instanceof \Magento\Framework\Object\IdentityInterface) { - $tags = $object->getIdentities(); - foreach ($tags as $tag) { - $tags[] = preg_replace("~_\\d+$~", '', $tag); - } - $this->_cache->clean(array_unique($tags)); - } - } - } - - /** - * Flash Built-In cache - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function flushAllCache(\Magento\Framework\Event\Observer $observer) - { - if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) { - $this->_cache->clean(); - } - } - - /** - * Invalidate full page cache - * - * @return \Magento\PageCache\Model\Observer - */ - public function invalidateCache() - { - if ($this->_config->isEnabled()) { - $this->_typeList->invalidate('full_page'); - } - return $this; - } - - /** - * Register form key in session from cookie value - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function registerFormKeyFromCookie(\Magento\Framework\Event\Observer $observer) - { - $formKeyFromCookie = $this->_formKey->get(); - if ($formKeyFromCookie) { - $this->_session->setData( - \Magento\Framework\Data\Form\FormKey::FORM_KEY, - $this->_escaper->escapeHtml($formKeyFromCookie) - ); - } - } -} diff --git a/app/code/Magento/PageCache/Model/Observer/FlushAllCache.php b/app/code/Magento/PageCache/Model/Observer/FlushAllCache.php new file mode 100644 index 0000000000000000000000000000000000000000..68ccfc821f9256c639eb2109379adc172500f8da --- /dev/null +++ b/app/code/Magento/PageCache/Model/Observer/FlushAllCache.php @@ -0,0 +1,62 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Observer; + +class FlushAllCache +{ + /** + * @var \Magento\Framework\App\PageCache\Cache + */ + protected $_cache; + + /** + * Application config object + * + * @var \Magento\PageCache\Model\Config + */ + protected $_config; + + /** + * @param \Magento\PageCache\Model\Config $config + * @param \Magento\Framework\App\PageCache\Cache $cache + */ + public function __construct(\Magento\PageCache\Model\Config $config, \Magento\Framework\App\PageCache\Cache $cache) + { + $this->_config = $config; + $this->_cache = $cache; + } + + /** + * Flash Built-In cache + * + * @return void + */ + public function execute() + { + if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) { + $this->_cache->clean(); + } + } +} diff --git a/app/code/Magento/PageCache/Model/Observer/FlushCacheByTags.php b/app/code/Magento/PageCache/Model/Observer/FlushCacheByTags.php new file mode 100644 index 0000000000000000000000000000000000000000..02305db2a9767ad13b5c829eb16c1511c6e70709 --- /dev/null +++ b/app/code/Magento/PageCache/Model/Observer/FlushCacheByTags.php @@ -0,0 +1,71 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Observer; + +class FlushCacheByTags +{ + /** + * @var \Magento\Framework\App\PageCache\Cache + */ + protected $_cache; + + /** + * Application config object + * + * @var \Magento\PageCache\Model\Config + */ + protected $_config; + + /** + * @param \Magento\PageCache\Model\Config $config + * @param \Magento\Framework\App\PageCache\Cache $cache + */ + public function __construct(\Magento\PageCache\Model\Config $config, \Magento\Framework\App\PageCache\Cache $cache) + { + $this->_config = $config; + $this->_cache = $cache; + } + + /** + * If Built-In caching is enabled it collects array of tags + * of incoming object and asks to clean cache. + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN && $this->_config->isEnabled()) { + $object = $observer->getEvent()->getObject(); + if ($object instanceof \Magento\Framework\Object\IdentityInterface) { + $tags = $object->getIdentities(); + foreach ($tags as $tag) { + $tags[] = preg_replace("~_\\d+$~", '', $tag); + } + $this->_cache->clean(array_unique($tags)); + } + } + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/RegionBuilder.php b/app/code/Magento/PageCache/Model/Observer/InvalidateCache.php similarity index 55% rename from app/code/Magento/Checkout/Service/V1/Data/Cart/Address/RegionBuilder.php rename to app/code/Magento/PageCache/Model/Observer/InvalidateCache.php index f1d88270ccf718b3e4bcb4015e9ace72a698b6f2..56c4f0e273263f0d60a92811e06451dc7ad8b84a 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/RegionBuilder.php +++ b/app/code/Magento/PageCache/Model/Observer/InvalidateCache.php @@ -1,5 +1,6 @@ <?php /** + * * Magento * * NOTICE OF LICENSE @@ -21,48 +22,44 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Checkout\Service\V1\Data\Cart\Address; +namespace Magento\PageCache\Model\Observer; -/** - * Builder for the Region Service Data Object - * - * @method Region create() - */ -class RegionBuilder extends \Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder +class InvalidateCache { /** - * Set region code - * - * @param string $regionCode - * @return $this + * @var \Magento\Framework\App\Cache\TypeListInterface */ - public function setRegionCode($regionCode) - { - $this->_data[Region::KEY_REGION_CODE] = $regionCode; - return $this; - } + protected $_typeList; /** - * Set region + * Application config object * - * @param string $regionName - * @return $this + * @var \Magento\PageCache\Model\Config */ - public function setRegion($regionName) - { - $this->_data[Region::KEY_REGION] = $regionName; - return $this; + protected $_config; + + /** + * @param \Magento\PageCache\Model\Config $config + * @param \Magento\Framework\App\Cache\TypeListInterface $typeList + */ + public function __construct( + \Magento\PageCache\Model\Config $config, + \Magento\Framework\App\Cache\TypeListInterface $typeList + ) { + $this->_config = $config; + $this->_typeList = $typeList; } /** - * Set region id + * Invalidate full page cache * - * @param string $regionId - * @return $this + * @return void */ - public function setRegionId($regionId) + public function execute() { - $this->_data[Region::KEY_REGION_ID] = $regionId; + if ($this->_config->isEnabled()) { + $this->_typeList->invalidate('full_page'); + } return $this; } } diff --git a/app/code/Magento/PageCache/Model/Observer/ProcessLayoutRenderElement.php b/app/code/Magento/PageCache/Model/Observer/ProcessLayoutRenderElement.php new file mode 100644 index 0000000000000000000000000000000000000000..a24e27e91276f9102ec1a4b17cea8511ab809490 --- /dev/null +++ b/app/code/Magento/PageCache/Model/Observer/ProcessLayoutRenderElement.php @@ -0,0 +1,104 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Observer; + +class ProcessLayoutRenderElement +{ + /** + * @var \Magento\PageCache\Helper\Data + */ + protected $_helper; + + /** + * Application config object + * + * @var \Magento\PageCache\Model\Config + */ + protected $_config; + + /** + * @param \Magento\PageCache\Model\Config $config + * @param \Magento\PageCache\Helper\Data $helper + */ + public function __construct( + \Magento\PageCache\Model\Config $config, + \Magento\PageCache\Helper\Data $helper + ) { + $this->_config = $config; + $this->_helper = $helper; + } + + /** + * Replace the output of the block, containing ttl attribute, with ESI tag + * + * @param \Magento\Framework\View\Element\AbstractBlock $block + * @return string + */ + protected function _wrapEsi(\Magento\Framework\View\Element\AbstractBlock $block) + { + $url = $block->getUrl( + 'page_cache/block/esi', + array( + 'blocks' => json_encode(array($block->getNameInLayout())), + 'handles' => json_encode($this->_helper->getActualHandles()) + ) + ); + return sprintf('<esi:include src="%s" />', $url); + } + + /** + * Add comment cache containers to private blocks + * Blocks are wrapped only if page is cacheable + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + $event = $observer->getEvent(); + /** @var \Magento\Framework\View\Layout $layout */ + $layout = $event->getLayout(); + if ($layout->isCacheable() && $this->_config->isEnabled()) { + $name = $event->getElementName(); + $block = $layout->getBlock($name); + $transport = $event->getTransport(); + if ($block instanceof \Magento\Framework\View\Element\AbstractBlock) { + $blockTtl = $block->getTtl(); + $varnishIsEnabledFlag = ($this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH); + $output = $transport->getData('output'); + if ($varnishIsEnabledFlag && isset($blockTtl)) { + $output = $this->_wrapEsi($block); + } elseif ($block->isScopePrivate()) { + $output = sprintf( + '<!-- BLOCK %1$s -->%2$s<!-- /BLOCK %1$s -->', + $block->getNameInLayout(), + $output + ); + } + $transport->setData('output', $output); + } + } + } +} diff --git a/app/code/Magento/PageCache/Model/Observer/RegisterFormKeyFromCookie.php b/app/code/Magento/PageCache/Model/Observer/RegisterFormKeyFromCookie.php new file mode 100644 index 0000000000000000000000000000000000000000..946afafb73d2995385fc55863657086e521dd7c7 --- /dev/null +++ b/app/code/Magento/PageCache/Model/Observer/RegisterFormKeyFromCookie.php @@ -0,0 +1,74 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Observer; + +class RegisterFormKeyFromCookie +{ + /** + * @var \Magento\Framework\App\PageCache\FormKey + */ + protected $_formKey; + + /** + * @var \Magento\Framework\Session\Generic + */ + protected $_session; + + /** + * @var \Magento\Framework\Escaper + */ + protected $_escaper; + + /** + * @param \Magento\Framework\Session\Generic $session + * @param \Magento\Framework\App\PageCache\FormKey $formKey + * @param \Magento\Framework\Escaper $escaper + */ + public function __construct( + \Magento\Framework\App\PageCache\FormKey $formKey, + \Magento\Framework\Session\Generic $session, + \Magento\Framework\Escaper $escaper + ) { + $this->_session = $session; + $this->_formKey = $formKey; + $this->_escaper = $escaper; + } + + /** + * Register form key in session from cookie value + * + * @return void + */ + public function execute() + { + $formKeyFromCookie = $this->_formKey->get(); + if ($formKeyFromCookie) { + $this->_session->setData( + \Magento\Framework\Data\Form\FormKey::FORM_KEY, + $this->_escaper->escapeHtml($formKeyFromCookie) + ); + } + } +} diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index 0dda6829dd4f262091f94586c9d3616e577eef83..f8da46fc5f2e99b27ebf2bc0cf27b47727308f26 100644 --- a/app/code/Magento/PageCache/composer.json +++ b/app/code/Magento/PageCache/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/PageCache/etc/events.xml b/app/code/Magento/PageCache/etc/events.xml index a00c8488bf151f2c7124fdd9cbcbad223f52e075..37fdf78b623e920993e8de1fa2176cfc4f2e1a92 100644 --- a/app/code/Magento/PageCache/etc/events.xml +++ b/app/code/Magento/PageCache/etc/events.xml @@ -25,55 +25,53 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> <event name="core_layout_render_element"> - <observer name="pagecache" instance="Magento\PageCache\Model\Observer" method="processLayoutRenderElement" /> + <observer name="pagecache" instance="Magento\PageCache\Model\Observer\ProcessLayoutRenderElement" method="execute" /> </event> <event name="clean_cache_by_tags"> - <observer name="invalidate_builtin" instance="Magento\PageCache\Model\Observer" method="flushCacheByTags" /> + <observer name="invalidate_builtin" instance="Magento\PageCache\Model\Observer\FlushCacheByTags" method="execute" /> </event> <event name="clean_cache_after_reindex"> - <observer name="reindex_cache_flush" instance="Magento\PageCache\Model\Observer" method="invalidateCache" /> + <observer name="reindex_cache_flush" instance="Magento\PageCache\Model\Observer\InvalidateCache" method="execute" /> </event> <event name="adminhtml_cache_flush_system"> - <observer name="flush_system_pagecache" instance="Magento\PageCache\Model\Observer" method="flushAllCache" /> + <observer name="flush_system_pagecache" instance="Magento\PageCache\Model\Observer\FlushAllCache" method="execute" /> </event> <event name="adminhtml_cache_flush_all"> - <observer name="magento_all_pagecache" instance="Magento\PageCache\Model\Observer" method="flushAllCache" /> + <observer name="magento_all_pagecache" instance="Magento\PageCache\Model\Observer\FlushAllCache" method="execute" /> </event> <event name="adminhtml_cache_refresh_type"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="flushAllCache" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\FlushAllCache" method="execute" /> </event> <event name="clean_media_cache_after"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="invalidateCache" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\InvalidateCache" method="execute" /> </event> <event name="clean_catalog_images_cache_after"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="invalidateCache" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\InvalidateCache" method="execute" /> </event> <event name="assigned_theme_changed"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="flushCacheByTags" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\FlushCacheByTags" method="execute" /> </event> <event name="assign_theme_to_stores_after"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="invalidateCache" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\InvalidateCache" method="execute" /> </event> <event name="controller_action_postdispatch_adminhtml_system_currency_saveRates"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="invalidateCache" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\InvalidateCache" method="execute" /> </event> <event name="controller_action_postdispatch_adminhtml_system_config_save"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="invalidateCache" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\InvalidateCache" method="execute" /> </event> <event name="controller_action_postdispatch_catalog_product_save"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="flushCacheByTags" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\FlushCacheByTags" method="execute" /> </event> <event name="controller_action_postdispatch_adminhtml_system_currencysymbol_save"> - <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="invalidateCache" /> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer\InvalidateCache" method="execute" /> </event> <event name="model_save_commit_after"> - <observer name="flush_cache_after_model_save" - instance="Magento\PageCache\Model\Observer" - method="flushCacheByTags" /> + <observer name="flush_cache_after_model_save" instance="Magento\PageCache\Model\Observer\FlushCacheByTags" method="execute" /> </event> <event name="controller_action_predispatch"> <observer name="register_form_key" - instance="Magento\PageCache\Model\Observer" - method="registerFormKeyFromCookie" /> + instance="Magento\PageCache\Model\Observer\RegisterFormKeyFromCookie" + method="execute" /> </event> </config> diff --git a/app/code/Magento/PayPalRecurringPayment/composer.json b/app/code/Magento/PayPalRecurringPayment/composer.json index 4538e1236c589bcf6dc76902811e433639ad629e..7b016f8c135e3c43ad8bf39a0cce1772e7bebe54 100644 --- a/app/code/Magento/PayPalRecurringPayment/composer.json +++ b/app/code/Magento/PayPalRecurringPayment/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-paypal": "0.1.0-alpha95", - "magento/module-recurring-payment": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-paypal": "0.1.0-alpha96", + "magento/module-recurring-payment": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Payment/Model/Method/Free.php b/app/code/Magento/Payment/Model/Method/Free.php index 2322741f5964458538c16142420537f7d891d189..539fa5f9d7d9c170b909cb9e96d5e3630548a44a 100644 --- a/app/code/Magento/Payment/Model/Method/Free.php +++ b/app/code/Magento/Payment/Model/Method/Free.php @@ -23,6 +23,8 @@ */ namespace Magento\Payment\Model\Method; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Free payment method */ @@ -52,20 +54,16 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod protected $_code = 'free'; /** - * Store manager - * - * @var \Magento\Framework\StoreManagerInterface + * @var PriceCurrencyInterface */ - protected $_storeManager; + protected $priceCurrency; /** - * Construct - * * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( @@ -73,11 +71,11 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, - \Magento\Framework\StoreManagerInterface $storeManager, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { parent::__construct($eventManager, $paymentData, $scopeConfig, $logAdapterFactory, $data); - $this->_storeManager = $storeManager; + $this->priceCurrency = $priceCurrency; } /** @@ -90,7 +88,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod { return parent::isAvailable( $quote - ) && !empty($quote) && $this->_storeManager->getStore()->roundPrice( + ) && !empty($quote) && $this->priceCurrency->round( $quote->getGrandTotal() ) == 0; } diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 0edbbc14963a161c2eb6d5d7b68d8dff14ba0180..a3d80826c452092a6fc8c2f224746ba930130631 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-centinel": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-centinel": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Payment/etc/di.xml b/app/code/Magento/Payment/etc/di.xml index 0983fc499a488d61e95658f10f6a3c1479ee7f70..93b4f3a888ee01601ddb16482128e46f3a1ae5cb 100644 --- a/app/code/Magento/Payment/etc/di.xml +++ b/app/code/Magento/Payment/etc/di.xml @@ -33,7 +33,7 @@ </type> <virtualType name="Magento\Payment\Model\Config\Data" type="Magento\Framework\Config\Data"> <arguments> - <argument name="reader" xsi:type="object">Magento\Payment\Model\Config\Reader</argument> + <argument name="reader" xsi:type="object">Magento\Payment\Model\Config\Reader\Proxy</argument> <argument name="cacheId" xsi:type="string">payment_config</argument> </arguments> </virtualType> diff --git a/app/code/Magento/Paypal/Block/Express/Review.php b/app/code/Magento/Paypal/Block/Express/Review.php index bf3005b4035d1f82524c3c68b62f6b6f5e10018d..672839d7e3b22e2ffd47cbad2db387145c58c25d 100644 --- a/app/code/Magento/Paypal/Block/Express/Review.php +++ b/app/code/Magento/Paypal/Block/Express/Review.php @@ -23,6 +23,8 @@ */ namespace Magento\Paypal\Block\Express; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Paypal Express Onepage checkout block * @@ -65,19 +67,25 @@ class Review extends \Magento\Framework\View\Element\Template protected $_taxHelper; /** - * Initialize dependencies. - * + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Tax\Helper\Data $taxHelper * @param \Magento\Customer\Model\Address\Config $addressConfig + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Tax\Helper\Data $taxHelper, \Magento\Customer\Model\Address\Config $addressConfig, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_taxHelper = $taxHelper; $this->_addressConfig = $addressConfig; parent::__construct($context, $data); @@ -228,7 +236,12 @@ class Review extends \Magento\Framework\View\Element\Template */ protected function _formatPrice($price) { - return $this->_quote->getStore()->convertPrice($price, true); + return $this->priceCurrency->convertAndFormat( + $price, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $this->_quote->getStore() + ); } /** diff --git a/app/code/Magento/Paypal/Model/Observer.php b/app/code/Magento/Paypal/Model/Observer.php index b2021785f7bc04bf92c652407384dd47026602d3..77e23a27ecafd78cec07d461d46e853631adbed4 100644 --- a/app/code/Magento/Paypal/Model/Observer.php +++ b/app/code/Magento/Paypal/Model/Observer.php @@ -66,11 +66,6 @@ class Observer */ protected $_view; - /** - * @var \Magento\Framework\AuthorizationInterface - */ - protected $_authorization; - /** * @var \Magento\Paypal\Model\Billing\AgreementFactory */ @@ -98,7 +93,6 @@ class Observer * @param \Magento\Framework\Logger $logger * @param Report\SettlementFactory $settlementFactory * @param \Magento\Framework\App\ViewInterface $view - * @param \Magento\Framework\AuthorizationInterface $authorization * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Paypal\Helper\Shortcut\Factory $shortcutFactory @@ -110,7 +104,6 @@ class Observer \Magento\Framework\Logger $logger, \Magento\Paypal\Model\Report\SettlementFactory $settlementFactory, \Magento\Framework\App\ViewInterface $view, - \Magento\Framework\AuthorizationInterface $authorization, \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Paypal\Helper\Shortcut\Factory $shortcutFactory @@ -121,7 +114,6 @@ class Observer $this->_logger = $logger; $this->_settlementFactory = $settlementFactory; $this->_view = $view; - $this->_authorization = $authorization; $this->_agreementFactory = $agreementFactory; $this->_checkoutSession = $checkoutSession; $this->_shortcutFactory = $shortcutFactory; @@ -210,25 +202,6 @@ class Observer return $this; } - /** - * Block admin ability to use customer billing agreements - * - * @param EventObserver $observer - * @return void - */ - public function restrictAdminBillingAgreementUsage($observer) - { - $event = $observer->getEvent(); - $methodInstance = $event->getMethodInstance(); - if ($methodInstance instanceof \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement && - false == $this->_authorization->isAllowed( - 'Magento_Paypal::use' - ) - ) { - $event->getResult()->isAvailable = false; - } - } - /** * @param EventObserver $observer * @return void diff --git a/app/code/Magento/Checkout/Service/V1/QuoteLoader.php b/app/code/Magento/Paypal/Model/Observer/RestrictAdminBillingAgreementUsage.php similarity index 50% rename from app/code/Magento/Checkout/Service/V1/QuoteLoader.php rename to app/code/Magento/Paypal/Model/Observer/RestrictAdminBillingAgreementUsage.php index 653f55c4f26086a362ed53aba48e14baaf5232f0..89320cafb54dc36b6b2e546c1226c1d0cf0da2b7 100644 --- a/app/code/Magento/Checkout/Service/V1/QuoteLoader.php +++ b/app/code/Magento/Paypal/Model/Observer/RestrictAdminBillingAgreementUsage.php @@ -1,5 +1,6 @@ <?php /** + * * Magento * * NOTICE OF LICENSE @@ -21,39 +22,42 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Paypal\Model\Observer; -namespace Magento\Checkout\Service\V1; - -use \Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Event\Observer as EventObserver; -class QuoteLoader +class RestrictAdminBillingAgreementUsage { /** - * @var \Magento\Sales\Model\QuoteFactory + * @var \Magento\Framework\AuthorizationInterface */ - protected $quoteFactory; + protected $_authorization; /** - * @param \Magento\Sales\Model\QuoteFactory $quoteFactory + * @param \Magento\Framework\AuthorizationInterface $authorization */ - public function __construct(\Magento\Sales\Model\QuoteFactory $quoteFactory) - { - $this->quoteFactory = $quoteFactory; + public function __construct( + \Magento\Framework\AuthorizationInterface $authorization + ) { + $this->_authorization = $authorization; } /** - * @param int $cartId - * @param int $storeId - * @return \Magento\Sales\Model\Quote - * @throws \Magento\Framework\Exception\NoSuchEntityException + * Block admin ability to use customer billing agreements + * + * @param EventObserver $observer + * @return void */ - public function load($cartId, $storeId) + public function execute($observer) { - $quote = $this->quoteFactory->create(); - $quote->setStoreId($storeId)->load($cartId); - if (!$quote->getId() || !$quote->getIsActive()) { - throw NoSuchEntityException::singleField('cartId', $cartId); + $event = $observer->getEvent(); + $methodInstance = $event->getMethodInstance(); + if ($methodInstance instanceof \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement && + false == $this->_authorization->isAllowed( + 'Magento_Paypal::use' + ) + ) { + $event->getResult()->isAvailable = false; } - return $quote; } } diff --git a/app/code/Magento/Paypal/composer.json b/app/code/Magento/Paypal/composer.json index d968f5165867ed51b59345e5da5cb6ffba9125df..d35eb98c64c86490160469e541138bad5597a8ba 100644 --- a/app/code/Magento/Paypal/composer.json +++ b/app/code/Magento/Paypal/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-centinel": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-centinel": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/etc/adminhtml/events.xml b/app/code/Magento/Paypal/etc/adminhtml/events.xml index 73533435cfd16b2c9afd9aec733b1a80aec1d952..71b1af273eb6ea2c9d12811a071a80757f959a19 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/events.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/events.xml @@ -25,6 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> <event name="payment_method_is_active"> - <observer name="sales_billing_agreement" instance="Magento\Paypal\Model\Observer" method="restrictAdminBillingAgreementUsage" /> + <observer name="sales_billing_agreement" instance="Magento\Paypal\Model\Observer\RestrictAdminBillingAgreementUsage" method="execute" /> </event> </config> diff --git a/app/code/Magento/Persistent/Controller/Index.php b/app/code/Magento/Persistent/Controller/Index.php index 5203055a409c57e620be0fcc3ca9d6ff60d57fde..b14decd47fc6bf1ac7f4b4584d797531067b744c 100644 --- a/app/code/Magento/Persistent/Controller/Index.php +++ b/app/code/Magento/Persistent/Controller/Index.php @@ -54,23 +54,21 @@ class Index extends \Magento\Framework\App\Action\Action * * @var \Magento\Persistent\Model\Observer */ - protected $_persistentObserver; + protected $quoteManager; /** - * Construct - * * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Persistent\Model\Observer $persistentObserver + * @param \Magento\Persistent\Model\QuoteManager $quoteManager * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession */ public function __construct( \Magento\Framework\App\Action\Context $context, - \Magento\Persistent\Model\Observer $persistentObserver, + \Magento\Persistent\Model\QuoteManager $quoteManager, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession ) { - $this->_persistentObserver = $persistentObserver; + $this->quoteManager = $quoteManager; $this->_checkoutSession = $checkoutSession; $this->_customerSession = $customerSession; parent::__construct($context); diff --git a/app/code/Magento/Persistent/Controller/Index/SaveMethod.php b/app/code/Magento/Persistent/Controller/Index/SaveMethod.php index 5080a526a7b48372b0741d84cffcbf54e30055b8..b24e6a283fa20742ac2b87e34d1b692e7edd5eed 100644 --- a/app/code/Magento/Persistent/Controller/Index/SaveMethod.php +++ b/app/code/Magento/Persistent/Controller/Index/SaveMethod.php @@ -26,6 +26,11 @@ namespace Magento\Persistent\Controller\Index; class SaveMethod extends \Magento\Persistent\Controller\Index { + /** + * @var \Magento\Persistent\Model\QuoteManager + */ + protected $quoteManager; + /** * Save onepage checkout method to be register * @@ -39,7 +44,7 @@ class SaveMethod extends \Magento\Persistent\Controller\Index $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null); } - $this->_persistentObserver->setQuoteGuest(); + $this->quoteManager->setGuest(); } $checkoutUrl = $this->_redirect->getRefererUrl(); diff --git a/app/code/Magento/Persistent/Model/Observer.php b/app/code/Magento/Persistent/Model/Observer.php index 257a102009f36d41744df7ccbaa01da4d96cb39d..a551e159c27283bf01742c2e890a06ae915dea19 100644 --- a/app/code/Magento/Persistent/Model/Observer.php +++ b/app/code/Magento/Persistent/Model/Observer.php @@ -30,20 +30,6 @@ namespace Magento\Persistent\Model; */ class Observer { - /** - * Whether set quote to be persistent in workflow - * - * @var bool - */ - protected $_setQuotePersistent = true; - - /** - * Persistent data - * - * @var \Magento\Persistent\Helper\Data - */ - protected $_persistentData = null; - /** * Persistent session * @@ -51,13 +37,6 @@ class Observer */ protected $_persistentSession = null; - /** - * Core event manager proxy - * - * @var \Magento\Framework\Event\ManagerInterface - */ - protected $_eventManager = null; - /** * Layout model * @@ -65,34 +44,6 @@ class Observer */ protected $_layout; - /** - * Request http - * - * @var \Magento\Framework\App\RequestInterface - */ - protected $_requestHttp; - - /** - * Persistent config factory - * - * @var \Magento\Persistent\Model\Persistent\ConfigFactory - */ - protected $_persistentConfigFactory; - - /** - * Quote factory - * - * @var \Magento\Sales\Model\QuoteFactory - */ - protected $_quoteFactory; - - /** - * Session factory - * - * @var \Magento\Persistent\Model\SessionFactory - */ - protected $_sessionFactory; - /** * Url model * @@ -100,35 +51,11 @@ class Observer */ protected $_url; - /** - * Checkout session - * - * @var \Magento\Checkout\Model\Session - */ - protected $_checkoutSession; - - /** - * Website collection factory - * - * @var \Magento\Store\Model\Resource\Website\CollectionFactory - */ - protected $_websiteCollectionFactory; - /** * @var \Magento\Framework\Escaper */ protected $_escaper; - /** - * @var \Magento\Framework\Message\ManagerInterface - */ - protected $messageManager; - - /** - * @var \Magento\Checkout\Helper\ExpressRedirect - */ - protected $_expressRedirectHelper; - /** * Customer view helper * @@ -144,121 +71,29 @@ class Observer protected $_customerAccountService; /** - * Construct - * - * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Persistent\Helper\Session $persistentSession - * @param \Magento\Persistent\Helper\Data $persistentData - * @param \Magento\Store\Model\Resource\Website\CollectionFactory $websiteCollectionFactory - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Persistent\Model\SessionFactory $sessionFactory - * @param \Magento\Sales\Model\QuoteFactory $quoteFactory - * @param \Magento\Persistent\Model\Persistent\ConfigFactory $persistentConfigFactory - * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\Escaper $escaper - * @param \Magento\Framework\Message\ManagerInterface $messageManager - * @param \Magento\Checkout\Helper\ExpressRedirect $expressRedirectHelper * @param \Magento\Customer\Helper\View $customerViewHelper * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Persistent\Helper\Session $persistentSession, - \Magento\Persistent\Helper\Data $persistentData, - \Magento\Store\Model\Resource\Website\CollectionFactory $websiteCollectionFactory, - \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Customer\Model\Session $customerSession, \Magento\Framework\UrlInterface $url, - \Magento\Persistent\Model\SessionFactory $sessionFactory, - \Magento\Sales\Model\QuoteFactory $quoteFactory, - \Magento\Persistent\Model\Persistent\ConfigFactory $persistentConfigFactory, - \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Escaper $escaper, - \Magento\Framework\Message\ManagerInterface $messageManager, - \Magento\Checkout\Helper\ExpressRedirect $expressRedirectHelper, \Magento\Customer\Helper\View $customerViewHelper, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService ) { - $this->_eventManager = $eventManager; $this->_persistentSession = $persistentSession; - $this->_persistentData = $persistentData; - $this->_websiteCollectionFactory = $websiteCollectionFactory; - $this->_checkoutSession = $checkoutSession; - $this->_customerSession = $customerSession; $this->_url = $url; - $this->_sessionFactory = $sessionFactory; - $this->_quoteFactory = $quoteFactory; - $this->_persistentConfigFactory = $persistentConfigFactory; - $this->_requestHttp = $requestHttp; $this->_layout = $layout; $this->_escaper = $escaper; - $this->messageManager = $messageManager; - $this->_expressRedirectHelper = $expressRedirectHelper; $this->_customerViewHelper = $customerViewHelper; $this->_customerAccountService = $customerAccountService; } - /** - * Apply persistent data - * - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function applyPersistentData($observer) - { - if (!$this->_persistentData->canProcess( - $observer - ) || !$this->_persistentSession->isPersistent() || $this->_customerSession->isLoggedIn() - ) { - return $this; - } - /** @var \Magento\Persistent\Model\Persistent\Config $persistentConfig */ - $persistentConfig = $this->_persistentConfigFactory->create(); - $persistentConfig->setConfigFilePath($this->_persistentData->getPersistentConfigFilePath())->fire(); - return $this; - } - - /** - * Apply persistent data to specific block - * - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function applyBlockPersistentData($observer) - { - if (!$this->_persistentSession->isPersistent() || $this->_customerSession->isLoggedIn()) { - return $this; - } - - /** @var $block \Magento\Framework\View\Element\AbstractBlock */ - $block = $observer->getEvent()->getBlock(); - - if (!$block) { - return $this; - } - - $configFilePath = $observer->getEvent()->getConfigFilePath(); - if (!$configFilePath) { - $configFilePath = $this->_persistentData->getPersistentConfigFilePath(); - } - - /** @var $persistentConfig \Magento\Persistent\Model\Persistent\Config */ - $persistentConfig = $this->_persistentConfigFactory->create(); - $persistentConfig->setConfigFilePath($configFilePath); - - foreach ($persistentConfig->getBlockConfigInfo(get_class($block)) as $persistentConfigInfo) { - $persistentConfig->fireOne($persistentConfigInfo, $block); - } - - return $this; - } - /** * Emulate 'welcome' block with persistent data * @@ -268,7 +103,11 @@ class Observer public function emulateWelcomeBlock($block) { $escapedName = $this->_escaper->escapeHtml( - $this->_customerViewHelper->getCustomerName($this->_getPersistentCustomer()), + $this->_customerViewHelper->getCustomerName( + $this->_customerAccountService->getCustomer( + $this->_persistentSession->getSession()->getCustomerId() + ) + ), null ); @@ -302,413 +141,4 @@ class Observer $this->_applyAccountLinksPersistentData(); $block->removeLinkByUrl($this->_url->getUrl('customer/account/login')); } - - /** - * Emulate quote by persistent data - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function emulateQuote($observer) - { - $stopActions = array('persistent_index_saveMethod', 'customer_account_createpost'); - - if (!$this->_persistentData->canProcess($observer) - || !$this->_persistentSession->isPersistent() - || $this->_customerSession->isLoggedIn() - ) { - return; - } - - $actionName = $observer->getEvent()->getRequest()->getFullActionName(); - - if (in_array($actionName, $stopActions)) { - return; - } - - if ($this->_isShoppingCartPersist()) { - $this->_checkoutSession->setCustomerData($this->_getPersistentCustomer()); - if (!$this->_checkoutSession->hasQuote()) { - $this->_checkoutSession->getQuote(); - } - } - } - - /** - * Set persistent data into quote - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function setQuotePersistentData($observer) - { - if (!$this->_isPersistent()) { - return; - } - - /** @var $quote \Magento\Sales\Model\Quote */ - $quote = $observer->getEvent()->getQuote(); - if (!$quote) { - return; - } - - if ($this->_isGuestShoppingCart() && $this->_setQuotePersistent) { - //Quote is not actual customer's quote, just persistent - $quote->setIsActive(false)->setIsPersistent(true); - } - } - - /** - * Set quote to be loaded even if not active - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function setLoadPersistentQuote($observer) - { - if (!$this->_isGuestShoppingCart()) { - return; - } - - if ($this->_checkoutSession) { - $this->_checkoutSession->setLoadInactive(); - } - } - - /** - * Prevent clear checkout session - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function preventClearCheckoutSession($observer) - { - $action = $this->_checkClearCheckoutSessionNecessity($observer); - - if ($action) { - $action->setClearCheckoutSession(false); - } - } - - /** - * Make persistent quote to be guest - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function makePersistentQuoteGuest($observer) - { - if (!$this->_checkClearCheckoutSessionNecessity($observer)) { - return; - } - - $this->setQuoteGuest(true); - } - - /** - * Check if checkout session should NOT be cleared - * - * @param \Magento\Framework\Event\Observer $observer - * @return bool|\Magento\Persistent\Controller\Index - */ - protected function _checkClearCheckoutSessionNecessity($observer) - { - if (!$this->_isGuestShoppingCart()) { - return false; - } - - /** @var $action \Magento\Persistent\Controller\Index */ - $action = $observer->getEvent()->getControllerAction(); - if ($action instanceof \Magento\Persistent\Controller\Index) { - return $action; - } - - return false; - } - - /** - * Reset session data when customer re-authenticates - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function customerAuthenticatedEvent($observer) - { - $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null); - - if ($this->_requestHttp->getParam('context') != 'checkout') { - $this->_expirePersistentSession(); - return; - } - - $this->setQuoteGuest(); - } - - /** - * Unset persistent cookie and make customer's quote as a guest - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function removePersistentCookie($observer) - { - if (!$this->_persistentData->canProcess($observer) || !$this->_isPersistent()) { - return; - } - - $this->_persistentSession->getSession()->removePersistentCookie(); - - if (!$this->_customerSession->isLoggedIn()) { - $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null); - } - - $this->setQuoteGuest(); - } - - /** - * Disable guest checkout if we are in persistent mode - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function disableGuestCheckout($observer) - { - if ($this->_persistentSession->isPersistent()) { - $observer->getEvent()->getResult()->setIsAllowed(false); - } - } - - /** - * Prevent express checkout - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function preventExpressCheckout(\Magento\Framework\Event\Observer $observer) - { - if (!$this->_isLoggedOut()) { - return; - } - - /** @var $controllerAction \Magento\Checkout\Controller\Express\RedirectLoginInterface*/ - $controllerAction = $observer->getEvent()->getControllerAction(); - if (!$controllerAction || - !$controllerAction instanceof \Magento\Checkout\Controller\Express\RedirectLoginInterface || - $controllerAction->getRedirectActionName() != $controllerAction->getRequest()->getActionName() - ) { - return; - } - - $this->messageManager->addNotice(__('To check out, please log in using your email address.')); - $customerBeforeAuthUrl = $this->_url->getUrl('persistent/index/expressCheckout'); - - $this->_expressRedirectHelper->redirectLogin($controllerAction, $customerBeforeAuthUrl); - } - - /** - * Retrieve persistent customer instance - * - * @return \Magento\Customer\Service\V1\Data\Customer - */ - protected function _getPersistentCustomer() - { - return $this->_customerAccountService->getCustomer($this->_persistentSession->getSession()->getCustomerId()); - } - - /** - * Return current active quote for persistent customer - * - * @return \Magento\Sales\Model\Quote - */ - protected function _getQuote() - { - /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $this->_quoteFactory->create(); - $quote->loadByCustomer($this->_persistentSession->getSession()->getCustomerId()); - return $quote; - } - - /** - * Check whether shopping cart is persistent - * - * @return bool - */ - protected function _isShoppingCartPersist() - { - return $this->_persistentData->isShoppingCartPersist(); - } - - /** - * Check whether persistent mode is running - * - * @return bool - */ - protected function _isPersistent() - { - return $this->_persistentSession->isPersistent(); - } - - /** - * Check if persistent mode is running and customer is logged out - * - * @return bool - */ - protected function _isLoggedOut() - { - return $this->_isPersistent() && !$this->_customerSession->isLoggedIn(); - } - - /** - * Check if shopping cart is guest while persistent session and user is logged out - * - * @return bool - */ - protected function _isGuestShoppingCart() - { - return $this->_isLoggedOut() && !$this->_persistentData->isShoppingCartPersist(); - } - - /** - * Make quote to be guest - * - * @param bool $checkQuote Check quote to be persistent (not stolen) - * @return void - */ - public function setQuoteGuest($checkQuote = false) - { - /** @var $quote \Magento\Sales\Model\Quote */ - $quote = $this->_checkoutSession->getQuote(); - if ($quote && $quote->getId()) { - if ($checkQuote && !$this->_persistentData->isShoppingCartPersist() && !$quote->getIsPersistent()) { - $this->_checkoutSession->clearQuote()->clearStorage(); - return; - } - - $quote->getPaymentsCollection()->walk('delete'); - $quote->getAddressesCollection()->walk('delete'); - $this->_setQuotePersistent = false; - $quote->setIsActive( - true - )->setCustomerId( - null - )->setCustomerEmail( - null - )->setCustomerFirstname( - null - )->setCustomerLastname( - null - )->setCustomerGroupId( - \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID - )->setIsPersistent( - false - )->removeAllAddresses(); - //Create guest addresses - $quote->getShippingAddress(); - $quote->getBillingAddress(); - $quote->collectTotals()->save(); - } - - $this->_persistentSession->getSession()->removePersistentCookie(); - } - - /** - * Check and clear session data if persistent session expired - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function checkExpirePersistentQuote(\Magento\Framework\Event\Observer $observer) - { - if (!$this->_persistentData->canProcess($observer)) { - return; - } - - if ($this->_persistentData->isEnabled() && - !$this->_isPersistent() && - !$this->_customerSession->isLoggedIn() && - $this->_checkoutSession->getQuoteId() && - !$observer->getControllerAction() instanceof \Magento\Checkout\Controller\Onepage - // persistent session does not expire on onepage checkout page to not spoil customer group id - ) { - $this->_eventManager->dispatch('persistent_session_expired'); - $this->_expirePersistentSession(); - $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null); - } - } - - /** - * @return void - */ - protected function _expirePersistentSession() - { - $quote = $this->_checkoutSession->setLoadInactive()->getQuote(); - if ($quote->getIsActive() && $quote->getCustomerId()) { - $this->_checkoutSession->setCustomerData(null)->clearQuote()->clearStorage(); - } else { - $quote - ->setIsActive(true) - ->setIsPersistent(false) - ->setCustomerId(null) - ->setCustomerGroupId(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID); - } - } - - /** - * Clear expired persistent sessions - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function clearExpiredCronJob(\Magento\Cron\Model\Schedule $schedule) - { - $websiteIds = $this->_websiteCollectionFactory->create()->getAllIds(); - if (!is_array($websiteIds)) { - return $this; - } - - foreach ($websiteIds as $websiteId) { - $this->_sessionFactory->create()->deleteExpired($websiteId); - } - - return $this; - } - - /** - * Update customer id and customer group id if user is in persistent session - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function updateCustomerCookies(\Magento\Framework\Event\Observer $observer) - { - if (!$this->_isPersistent()) { - return; - } - - $customerCookies = $observer->getEvent()->getCustomerCookies(); - if ($customerCookies instanceof \Magento\Framework\Object) { - $persistentCustomer = $this->_getPersistentCustomer(); - $customerCookies->setCustomerId($persistentCustomer->getId()); - $customerCookies->setCustomerGroupId($persistentCustomer->getGroupId()); - } - } - - /** - * Set persistent data to customer session - * - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function emulateCustomer($observer) - { - if (!$this->_persistentData->canProcess($observer) || !$this->_isShoppingCartPersist()) { - return $this; - } - - if ($this->_isLoggedOut()) { - $customer = $this->_getPersistentCustomer(); - $this->_customerSession->setCustomerId($customer->getId())->setCustomerGroupId($customer->getGroupId()); - } - return $this; - } } diff --git a/app/code/Magento/Persistent/Model/Observer/ApplyBlockPersistentData.php b/app/code/Magento/Persistent/Model/Observer/ApplyBlockPersistentData.php new file mode 100644 index 0000000000000000000000000000000000000000..7c4bec59e24ea1c25d54573a409ec15ec0a8b161 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/ApplyBlockPersistentData.php @@ -0,0 +1,109 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class ApplyBlockPersistentData +{ + /** + * Persistent config factory + * + * @var \Magento\Persistent\Model\Persistent\ConfigFactory + */ + protected $_persistentConfigFactory; + + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Persistent\Model\Persistent\ConfigFactory $persistentConfigFactory + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Customer\Model\Session $customerSession, + \Magento\Persistent\Model\Persistent\ConfigFactory $persistentConfigFactory + ) { + $this->_persistentSession = $persistentSession; + $this->_persistentData = $persistentData; + $this->_customerSession = $customerSession; + $this->_persistentConfigFactory = $persistentConfigFactory; + } + + /** + * Apply persistent data to specific block + * + * @param \Magento\Framework\Event\Observer $observer + * @return $this + */ + public function execute($observer) + { + if (!$this->_persistentSession->isPersistent() || $this->_customerSession->isLoggedIn()) { + return $this; + } + + /** @var $block \Magento\Framework\View\Element\AbstractBlock */ + $block = $observer->getEvent()->getBlock(); + + if (!$block) { + return $this; + } + + $configFilePath = $observer->getEvent()->getConfigFilePath(); + if (!$configFilePath) { + $configFilePath = $this->_persistentData->getPersistentConfigFilePath(); + } + + /** @var $persistentConfig \Magento\Persistent\Model\Persistent\Config */ + $persistentConfig = $this->_persistentConfigFactory->create(); + $persistentConfig->setConfigFilePath($configFilePath); + + foreach ($persistentConfig->getBlockConfigInfo(get_class($block)) as $persistentConfigInfo) { + $persistentConfig->fireOne($persistentConfigInfo, $block); + } + + return $this; + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/ApplyPersistentData.php b/app/code/Magento/Persistent/Model/Observer/ApplyPersistentData.php new file mode 100644 index 0000000000000000000000000000000000000000..c5e4e132af1e4ef733b96cdcdfec336d7278d305 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/ApplyPersistentData.php @@ -0,0 +1,94 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class ApplyPersistentData +{ + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Persistent config factory + * + * @var \Magento\Persistent\Model\Persistent\ConfigFactory + */ + protected $_persistentConfigFactory; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Persistent\Model\Persistent\ConfigFactory $persistentConfigFactory + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Customer\Model\Session $customerSession, + \Magento\Persistent\Model\Persistent\ConfigFactory $persistentConfigFactory + ) { + $this->_persistentSession = $persistentSession; + $this->_persistentData = $persistentData; + $this->_customerSession = $customerSession; + $this->_persistentConfigFactory = $persistentConfigFactory; + } + + /** + * Apply persistent data + * + * @param \Magento\Framework\Event\Observer $observer + * @return $this + */ + public function execute($observer) + { + if (!$this->_persistentData->canProcess($observer) + || !$this->_persistentSession->isPersistent() + || $this->_customerSession->isLoggedIn() + ) { + return $this; + } + /** @var \Magento\Persistent\Model\Persistent\Config $persistentConfig */ + $persistentConfig = $this->_persistentConfigFactory->create(); + $persistentConfig->setConfigFilePath($this->_persistentData->getPersistentConfigFilePath())->fire(); + return $this; + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/CheckExpirePersistentQuote.php b/app/code/Magento/Persistent/Model/Observer/CheckExpirePersistentQuote.php new file mode 100644 index 0000000000000000000000000000000000000000..7f294879c8f98ae817bb7260b6800fc959fb42f2 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/CheckExpirePersistentQuote.php @@ -0,0 +1,117 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class CheckExpirePersistentQuote +{ + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Checkout session + * + * @var \Magento\Checkout\Model\Session + */ + protected $_checkoutSession; + + /** + * Core event manager proxy + * + * @var \Magento\Framework\Event\ManagerInterface + */ + protected $_eventManager = null; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * @var \Magento\Persistent\Model\QuoteManager + */ + protected $quoteManager; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Persistent\Model\QuoteManager $quoteManager + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Persistent\Model\QuoteManager $quoteManager, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Customer\Model\Session $customerSession, + \Magento\Checkout\Model\Session $checkoutSession + ) { + $this->_persistentSession = $persistentSession; + $this->quoteManager = $quoteManager; + $this->_customerSession = $customerSession; + $this->_checkoutSession = $checkoutSession; + $this->_eventManager = $eventManager; + $this->_persistentData = $persistentData; + } + + /** + * Check and clear session data if persistent session expired + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + if (!$this->_persistentData->canProcess($observer)) { + return; + } + + if ($this->_persistentData->isEnabled() && + !$this->_persistentSession->isPersistent() && + !$this->_customerSession->isLoggedIn() && + $this->_checkoutSession->getQuoteId() && + !$observer->getControllerAction() instanceof \Magento\Checkout\Controller\Onepage + // persistent session does not expire on onepage checkout page to not spoil customer group id + ) { + $this->_eventManager->dispatch('persistent_session_expired'); + $this->quoteManager->expire(); + $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null); + } + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/ClearExpiredCronJob.php b/app/code/Magento/Persistent/Model/Observer/ClearExpiredCronJob.php new file mode 100644 index 0000000000000000000000000000000000000000..3fb2f3dbb106f55a06955498aa27c643d17ba3a8 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/ClearExpiredCronJob.php @@ -0,0 +1,74 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class ClearExpiredCronJob +{ + /** + * Website collection factory + * + * @var \Magento\Store\Model\Resource\Website\CollectionFactory + */ + protected $_websiteCollectionFactory; + + /** + * Session factory + * + * @var \Magento\Persistent\Model\SessionFactory + */ + protected $_sessionFactory; + + /** + * @param \Magento\Store\Model\Resource\Website\CollectionFactory $websiteCollectionFactory + * @param \Magento\Persistent\Model\SessionFactory $sessionFactory + */ + public function __construct( + \Magento\Store\Model\Resource\Website\CollectionFactory $websiteCollectionFactory, + \Magento\Persistent\Model\SessionFactory $sessionFactory + ) { + $this->_websiteCollectionFactory = $websiteCollectionFactory; + $this->_sessionFactory = $sessionFactory; + } + + /** + * Clear expired persistent sessions + * + * @param \Magento\Cron\Model\Schedule $schedule + * @return $this + */ + public function execute(\Magento\Cron\Model\Schedule $schedule) + { + $websiteIds = $this->_websiteCollectionFactory->create()->getAllIds(); + if (!is_array($websiteIds)) { + return $this; + } + + foreach ($websiteIds as $websiteId) { + $this->_sessionFactory->create()->deleteExpired($websiteId); + } + + return $this; + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/CustomerAuthenticatedEvent.php b/app/code/Magento/Persistent/Model/Observer/CustomerAuthenticatedEvent.php new file mode 100644 index 0000000000000000000000000000000000000000..aafa6046761aea9ea295d4195a04038ce8d83f57 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/CustomerAuthenticatedEvent.php @@ -0,0 +1,80 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class CustomerAuthenticatedEvent +{ + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Request http + * + * @var \Magento\Framework\App\RequestInterface + */ + protected $_requestHttp; + + /** + * @var \Magento\Persistent\Model\QuoteManager + */ + protected $quoteManager; + + /** + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Framework\App\RequestInterface $request + * @param \Magento\Persistent\Model\QuoteManager $quoteManager + */ + public function __construct( + \Magento\Customer\Model\Session $customerSession, + \Magento\Framework\App\RequestInterface $request, + \Magento\Persistent\Model\QuoteManager $quoteManager + ) { + $this->_customerSession = $customerSession; + $this->_requestHttp = $request; + $this->quoteManager = $quoteManager; + } + + /** + * Reset session data when customer re-authenticates + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null); + + if ($this->_requestHttp->getParam('context') != 'checkout') { + $this->quoteManager->expire(); + return; + } + + $this->quoteManager->setGuest(); + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/DisableGuestCheckout.php b/app/code/Magento/Persistent/Model/Observer/DisableGuestCheckout.php new file mode 100644 index 0000000000000000000000000000000000000000..ab61da2e1c0f7466079e0efdb7e6a756f77f3d0f --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/DisableGuestCheckout.php @@ -0,0 +1,56 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class DisableGuestCheckout +{ + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + */ + public function __construct(\Magento\Persistent\Helper\Session $persistentSession) + { + $this->_persistentSession = $persistentSession; + } + + /** + * Disable guest checkout if we are in persistent mode + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + if ($this->_persistentSession->isPersistent()) { + $observer->getEvent()->getResult()->setIsAllowed(false); + } + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/EmulateCustomer.php b/app/code/Magento/Persistent/Model/Observer/EmulateCustomer.php new file mode 100644 index 0000000000000000000000000000000000000000..309649e6836b16ec543362a417f0a71fa6529136 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/EmulateCustomer.php @@ -0,0 +1,95 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class EmulateCustomer +{ + /** + * Customer account service + * + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $_customerAccountService; + + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Customer\Model\Session $customerSession, + \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService + ) { + $this->_persistentSession = $persistentSession; + $this->_persistentData = $persistentData; + $this->_customerSession = $customerSession; + $this->_customerAccountService = $customerAccountService; + } + + /** + * Set persistent data to customer session + * + * @param \Magento\Framework\Event\Observer $observer + * @return $this + */ + public function execute($observer) + { + if (!$this->_persistentData->canProcess($observer) || !$this->_persistentData->isShoppingCartPersist()) { + return $this; + } + + if ($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) { + $customer = $this->_customerAccountService->getCustomer( + $this->_persistentSession->getSession()->getCustomerId() + ); + $this->_customerSession->setCustomerId($customer->getId())->setCustomerGroupId($customer->getGroupId()); + } + return $this; + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/EmulateQuote.php b/app/code/Magento/Persistent/Model/Observer/EmulateQuote.php new file mode 100644 index 0000000000000000000000000000000000000000..11ac84dc07e6c8a0ce5a81e88b87d27495e87a0a --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/EmulateQuote.php @@ -0,0 +1,117 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class EmulateQuote +{ + /** + * Customer account service + * + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $_customerAccountService; + + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Checkout session + * + * @var \Magento\Checkout\Model\Session + */ + protected $_checkoutSession; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Checkout\Model\Session $checkoutSession, + \Magento\Customer\Model\Session $customerSession, + \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService + ) { + $this->_persistentSession = $persistentSession; + $this->_persistentData = $persistentData; + $this->_checkoutSession = $checkoutSession; + $this->_customerSession = $customerSession; + $this->_customerAccountService = $customerAccountService; + } + + /** + * Emulate quote by persistent data + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + $stopActions = array('persistent_index_saveMethod', 'customer_account_createpost'); + + if (!$this->_persistentData->canProcess($observer) + || !$this->_persistentSession->isPersistent() + || $this->_customerSession->isLoggedIn() + ) { + return; + } + + $actionName = $observer->getEvent()->getRequest()->getFullActionName(); + + if (in_array($actionName, $stopActions)) { + return; + } + + if ($this->_persistentData->isShoppingCartPersist()) { + $this->_checkoutSession->setCustomerData( + $this->_customerAccountService->getCustomer($this->_persistentSession->getSession()->getCustomerId()) + ); + if (!$this->_checkoutSession->hasQuote()) { + $this->_checkoutSession->getQuote(); + } + } + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/MakePersistentQuoteGuest.php b/app/code/Magento/Persistent/Model/Observer/MakePersistentQuoteGuest.php new file mode 100644 index 0000000000000000000000000000000000000000..370e0e795af888fe0ed8d67a88f2324a31089150 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/MakePersistentQuoteGuest.php @@ -0,0 +1,91 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class MakePersistentQuoteGuest +{ + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * @var \Magento\Persistent\Model\QuoteManager + */ + protected $quoteManager; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Persistent\Model\QuoteManager $quoteManager + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Customer\Model\Session $customerSession, + \Magento\Persistent\Model\QuoteManager $quoteManager + ) { + $this->_persistentSession = $persistentSession; + $this->_persistentData = $persistentData; + $this->_customerSession = $customerSession; + $this->quoteManager = $quoteManager; + } + + /** + * Make persistent quote to be guest + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + /** @var $action \Magento\Persistent\Controller\Index */ + $action = $observer->getEvent()->getControllerAction(); + if ($action instanceof \Magento\Persistent\Controller\Index) { + if ((($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) + || $this->_persistentData->isShoppingCartPersist()) + ) { + $this->quoteManager->setGuest(true); + } + } + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/PreventClearCheckoutSession.php b/app/code/Magento/Persistent/Model/Observer/PreventClearCheckoutSession.php new file mode 100644 index 0000000000000000000000000000000000000000..05e233119775377484a6c10f9a415b2aa9fe4f81 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/PreventClearCheckoutSession.php @@ -0,0 +1,83 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class PreventClearCheckoutSession +{ + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Customer\Model\Session $customerSession + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Customer\Model\Session $customerSession + ) { + $this->_persistentSession = $persistentSession; + $this->_persistentData = $persistentData; + $this->_customerSession = $customerSession; + } + + /** + * Prevent clear checkout session + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + /** @var $action \Magento\Persistent\Controller\Index */ + $action = $observer->getEvent()->getControllerAction(); + if ($action instanceof \Magento\Persistent\Controller\Index) { + if (($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) + || !$this->_persistentData->isShoppingCartPersist() + ) { + $action->setClearCheckoutSession(false); + } + } + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/PreventExpressCheckout.php b/app/code/Magento/Persistent/Model/Observer/PreventExpressCheckout.php new file mode 100644 index 0000000000000000000000000000000000000000..88d78832a814fb7928cfcfbb50075f05bf50b062 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/PreventExpressCheckout.php @@ -0,0 +1,105 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class PreventExpressCheckout +{ + /** + * @var \Magento\Framework\Message\ManagerInterface + */ + protected $messageManager; + + /** + * Url model + * + * @var \Magento\Framework\UrlInterface + */ + protected $_url; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * @var \Magento\Checkout\Helper\ExpressRedirect + */ + protected $_expressRedirectHelper; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Framework\UrlInterface $url + * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param \Magento\Checkout\Helper\ExpressRedirect $expressRedirectHelper + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Customer\Model\Session $customerSession, + \Magento\Framework\UrlInterface $url, + \Magento\Framework\Message\ManagerInterface $messageManager, + \Magento\Checkout\Helper\ExpressRedirect $expressRedirectHelper + ) { + $this->_persistentSession = $persistentSession; + $this->_customerSession = $customerSession; + $this->_url = $url; + $this->messageManager = $messageManager; + $this->_expressRedirectHelper = $expressRedirectHelper; + } + + /** + * Prevent express checkout + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + if (!($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn())) { + return; + } + + /** @var $controllerAction \Magento\Checkout\Controller\Express\RedirectLoginInterface*/ + $controllerAction = $observer->getEvent()->getControllerAction(); + if (!$controllerAction || + !$controllerAction instanceof \Magento\Checkout\Controller\Express\RedirectLoginInterface || + $controllerAction->getRedirectActionName() != $controllerAction->getRequest()->getActionName() + ) { + return; + } + + $this->messageManager->addNotice(__('To check out, please log in using your email address.')); + $customerBeforeAuthUrl = $this->_url->getUrl('persistent/index/expressCheckout'); + + $this->_expressRedirectHelper->redirectLogin($controllerAction, $customerBeforeAuthUrl); + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/RemovePersistentCookie.php b/app/code/Magento/Persistent/Model/Observer/RemovePersistentCookie.php new file mode 100644 index 0000000000000000000000000000000000000000..991d60c1e4736fe46efec167c7277f1f1c07d452 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/RemovePersistentCookie.php @@ -0,0 +1,93 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class RemovePersistentCookie +{ + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * @var \Magento\Persistent\Model\QuoteManager + */ + protected $quoteManager; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Persistent\Model\QuoteManager $quoteManager + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Customer\Model\Session $customerSession, + \Magento\Persistent\Model\QuoteManager $quoteManager + ) { + $this->quoteManager = $quoteManager; + $this->_persistentSession = $persistentSession; + $this->_persistentData = $persistentData; + $this->_customerSession = $customerSession; + } + + /** + * Unset persistent cookie and make customer's quote as a guest + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + if (!$this->_persistentData->canProcess($observer) || !$this->_persistentSession->isPersistent()) { + return; + } + + $this->_persistentSession->getSession()->removePersistentCookie(); + + if (!$this->_customerSession->isLoggedIn()) { + $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null); + } + + $this->quoteManager->setGuest(); + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/SetLoadPersistentQuote.php b/app/code/Magento/Persistent/Model/Observer/SetLoadPersistentQuote.php new file mode 100644 index 0000000000000000000000000000000000000000..c3c9220a6fa9c7282d2f2df1550bb192135b8e2a --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/SetLoadPersistentQuote.php @@ -0,0 +1,95 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class SetLoadPersistentQuote +{ + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Checkout session + * + * @var \Magento\Checkout\Model\Session + */ + protected $_checkoutSession; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Customer\Model\Session $customerSession, + \Magento\Checkout\Model\Session $checkoutSession + ) { + $this->_persistentSession = $persistentSession; + $this->_customerSession = $customerSession; + $this->_checkoutSession = $checkoutSession; + $this->_persistentData = $persistentData; + } + + + /** + * Set quote to be loaded even if not active + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + if (!(($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) + && !$this->_persistentData->isShoppingCartPersist() + )) { + return; + } + + if ($this->_checkoutSession) { + $this->_checkoutSession->setLoadInactive(); + } + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/SetQuotePersistentData.php b/app/code/Magento/Persistent/Model/Observer/SetQuotePersistentData.php new file mode 100644 index 0000000000000000000000000000000000000000..f6981b729ca090ece3cacb067f93b469bfd3fcf3 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/SetQuotePersistentData.php @@ -0,0 +1,101 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class SetQuotePersistentData +{ + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $_persistentData = null; + + /** + * @var \Magento\Persistent\Model\QuoteManager + */ + protected $quoteManager; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Persistent\Model\QuoteManager $quoteManager + * @param \Magento\Customer\Model\Session $customerSession + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Persistent\Model\QuoteManager $quoteManager, + \Magento\Customer\Model\Session $customerSession + ) { + $this->_persistentSession = $persistentSession; + $this->quoteManager = $quoteManager; + $this->_customerSession = $customerSession; + $this->_persistentData = $persistentData; + } + + /** + * Set persistent data into quote + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + if (!$this->_persistentSession->isPersistent()) { + return; + } + + /** @var $quote \Magento\Sales\Model\Quote */ + $quote = $observer->getEvent()->getQuote(); + if (!$quote) { + return; + } + + if (( + ($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) + && !$this->_persistentData->isShoppingCartPersist() + ) + && $this->quoteManager->isPersistent() + ) { + //Quote is not actual customer's quote, just persistent + $quote->setIsActive(false)->setIsPersistent(true); + } + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/UpdateCustomerCookies.php b/app/code/Magento/Persistent/Model/Observer/UpdateCustomerCookies.php new file mode 100644 index 0000000000000000000000000000000000000000..cb3faa984191d7bb2f2d402363dcb5175bb9cb1f --- /dev/null +++ b/app/code/Magento/Persistent/Model/Observer/UpdateCustomerCookies.php @@ -0,0 +1,76 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class UpdateCustomerCookies +{ + /** + * Customer account service + * + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $_customerAccountService; + + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSession = null; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService + ) { + $this->_persistentSession = $persistentSession; + $this->_customerAccountService = $customerAccountService; + } + + /** + * Update customer id and customer group id if user is in persistent session + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + if (!$this->_persistentSession->isPersistent()) { + return; + } + + $customerCookies = $observer->getEvent()->getCustomerCookies(); + if ($customerCookies instanceof \Magento\Framework\Object) { + $persistentCustomer = $this->_customerAccountService->getCustomer( + $this->_persistentSession->getSession()->getCustomerId() + ); + $customerCookies->setCustomerId($persistentCustomer->getId()); + $customerCookies->setCustomerGroupId($persistentCustomer->getGroupId()); + } + } +} diff --git a/app/code/Magento/Persistent/Model/QuoteManager.php b/app/code/Magento/Persistent/Model/QuoteManager.php new file mode 100644 index 0000000000000000000000000000000000000000..1fb194c1305c2c4c167a3c3947336ba2b0a92858 --- /dev/null +++ b/app/code/Magento/Persistent/Model/QuoteManager.php @@ -0,0 +1,143 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model; + +class QuoteManager +{ + /** + * Persistent session + * + * @var \Magento\Persistent\Helper\Session + */ + protected $persistentSession = null; + + /** + * Checkout session + * + * @var \Magento\Checkout\Model\Session + */ + protected $checkoutSession; + + /** + * Persistent data + * + * @var \Magento\Persistent\Helper\Data + */ + protected $persistentData = null; + + /** + * Whether set quote to be persistent in workflow + * + * @var bool + */ + protected $_setQuotePersistent = true; + + /** + * @param \Magento\Persistent\Helper\Session $persistentSession + * @param \Magento\Persistent\Helper\Data $persistentData + * @param \Magento\Checkout\Model\Session $checkoutSession + */ + public function __construct( + \Magento\Persistent\Helper\Session $persistentSession, + \Magento\Persistent\Helper\Data $persistentData, + \Magento\Checkout\Model\Session $checkoutSession + ) { + $this->persistentSession = $persistentSession; + $this->persistentData = $persistentData; + $this->checkoutSession = $checkoutSession; + } + + /** + * Make quote to be guest + * + * @param bool $checkQuote Check quote to be persistent (not stolen) + * @return void + */ + public function setGuest($checkQuote = false) + { + /** @var $quote \Magento\Sales\Model\Quote */ + $quote = $this->checkoutSession->getQuote(); + if ($quote && $quote->getId()) { + if ($checkQuote && !$this->persistentData->isShoppingCartPersist() && !$quote->getIsPersistent()) { + $this->checkoutSession->clearQuote()->clearStorage(); + return; + } + + $quote->getPaymentsCollection()->walk('delete'); + $quote->getAddressesCollection()->walk('delete'); + $this->_setQuotePersistent = false; + $quote->setIsActive( + true + )->setCustomerId( + null + )->setCustomerEmail( + null + )->setCustomerFirstname( + null + )->setCustomerLastname( + null + )->setCustomerGroupId( + \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID + )->setIsPersistent( + false + )->removeAllAddresses(); + //Create guest addresses + $quote->getShippingAddress(); + $quote->getBillingAddress(); + $quote->collectTotals()->save(); + } + + $this->persistentSession->getSession()->removePersistentCookie(); + } + + /** + * Expire persistent quote + * + * @return void + */ + public function expire() + { + $quote = $this->checkoutSession->setLoadInactive()->getQuote(); + if ($quote->getIsActive() && $quote->getCustomerId()) { + $this->checkoutSession->setCustomerData(null)->clearQuote()->clearStorage(); + } else { + $quote + ->setIsActive(true) + ->setIsPersistent(false) + ->setCustomerId(null) + ->setCustomerGroupId(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID); + } + } + + /** + * Is quote persistent + * + * @return bool + */ + public function isPersistent() + { + return $this->_setQuotePersistent; + } +} diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index b9a46d4c5abfe18a25b4e028e1f8f66f2ea8acfd..b7beeaf0dbaa97ccdbfaba4777f73be90cb355e0 100644 --- a/app/code/Magento/Persistent/composer.json +++ b/app/code/Magento/Persistent/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-cron": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-cron": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Persistent/etc/crontab.xml b/app/code/Magento/Persistent/etc/crontab.xml index fea50f853a6361a36688632d686f36c325daff60..c710c817f296236827e8464fd22ab7ddb7075fad 100644 --- a/app/code/Magento/Persistent/etc/crontab.xml +++ b/app/code/Magento/Persistent/etc/crontab.xml @@ -25,7 +25,7 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Cron/etc/crontab.xsd"> <group id="default"> - <job name="persistent_clear_expired" instance="Magento\Persistent\Model\Observer" method="clearExpiredCronJob"> + <job name="persistent_clear_expired" instance="Magento\Persistent\Model\Observer\ClearExpiredCronJob" method="execute"> <schedule>0 0 * * *</schedule> </job> </group> diff --git a/app/code/Magento/Persistent/etc/frontend/events.xml b/app/code/Magento/Persistent/etc/frontend/events.xml index a5d1e80835f697d53525380134dc533cb0950593..9a62adb6b13de82ab3e692f6db4810dce70e60f9 100644 --- a/app/code/Magento/Persistent/etc/frontend/events.xml +++ b/app/code/Magento/Persistent/etc/frontend/events.xml @@ -38,46 +38,46 @@ </event> <event name="controller_action_predispatch_customer_account_createpost"> <observer name="persistent" instance="Magento\Persistent\Model\Observer\Session" method="setRememberMeCheckedStatus" /> - <observer name="persistent_authenticate" instance="Magento\Persistent\Model\Observer" method="customerAuthenticatedEvent" /> + <observer name="persistent_authenticate" instance="Magento\Persistent\Model\Observer\CustomerAuthenticatedEvent" method="execute" /> + </event> + <event name="controller_action_postdispatch_checkout_onepage_saveBilling"> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\Session" method="setRememberMeCheckedStatus" /> </event> <event name="controller_action_layout_generate_blocks_after"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="applyPersistentData" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\ApplyPersistentData" method="execute" /> </event> <event name="controller_action_predispatch"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="emulateQuote" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\EmulateQuote" method="execute" /> <observer name="persistent_session" instance="Magento\Persistent\Model\Observer\Session" method="renewCookie" /> - <observer name="persistent_quote" instance="Magento\Persistent\Model\Observer" method="checkExpirePersistentQuote" /> - <observer name="persistent_customer" instance="Magento\Persistent\Model\Observer" method="emulateCustomer" /> - <observer name="persistent_checkout" instance="Magento\Persistent\Model\Observer" method="preventExpressCheckout" /> + <observer name="persistent_quote" instance="Magento\Persistent\Model\Observer\CheckExpirePersistentQuote" method="execute" /> + <observer name="persistent_customer" instance="Magento\Persistent\Model\Observer\EmulateCustomer" method="execute" /> + <observer name="persistent_checkout" instance="Magento\Persistent\Model\Observer\PreventExpressCheckout" method="execute" /> </event> <event name="checkout_allow_guest"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="disableGuestCheckout" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\DisableGuestCheckout" method="execute" /> </event> <event name="customer_customer_authenticated"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="customerAuthenticatedEvent" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\CustomerAuthenticatedEvent" method="execute" /> </event> <event name="controller_action_predispatch_persistent_index_unsetCookie"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="preventClearCheckoutSession" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\PreventClearCheckoutSession" method="execute" /> </event> <event name="controller_action_postdispatch_persistent_index_unsetCookie"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="makePersistentQuoteGuest" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\MakePersistentQuoteGuest" method="execute" /> </event> <event name="sales_quote_save_before"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="setQuotePersistentData" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\SetQuotePersistentData" method="execute" /> </event> <event name="custom_quote_process"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="setLoadPersistentQuote" /> - </event> - <event name="controller_action_postdispatch_checkout_onepage_saveBilling"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer\Session" method="setRememberMeCheckedStatus" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\SetLoadPersistentQuote" method="execute" /> </event> <event name="customer_register_success"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="removePersistentCookie" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\RemovePersistentCookie" method="execute" /> </event> <event name="render_block"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="applyBlockPersistentData" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\ApplyBlockPersistentData" method="execute" /> </event> <event name="update_customer_cookies"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="updateCustomerCookies" /> + <observer name="persistent" instance="Magento\Persistent\Model\Observer\UpdateCustomerCookies" method="execute" /> </event> </config> diff --git a/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php b/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php index a72226942f212ef2d8f9f85d896485cf55786db4..8467e51a2beefba8bf64b2992b225ab556238fc9 100644 --- a/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php +++ b/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php @@ -23,6 +23,8 @@ */ namespace Magento\ProductAlert\Block\Email; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Product Alert Abstract Email Block * @@ -49,16 +51,24 @@ abstract class AbstractEmail extends \Magento\Framework\View\Element\Template */ protected $_maliciousCode; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_maliciousCode = $maliciousCode; parent::__construct($context, $data); } @@ -117,7 +127,9 @@ abstract class AbstractEmail extends \Magento\Framework\View\Element\Template */ public function formatPrice($price, $format = true, $includeContainer = true) { - return $this->getStore()->convertPrice($price, $format, $includeContainer); + return $format + ? $this->priceCurrency->convertAndFormat($price, $includeContainer) + : $this->priceCurrency->convert($price); } /** diff --git a/app/code/Magento/ProductAlert/Block/Email/Stock.php b/app/code/Magento/ProductAlert/Block/Email/Stock.php index f7bd8da4ba51f1b88820eba703e2020aa8023706..f322ac64aa4ccb83e00106a8586fd25ccbce353a 100644 --- a/app/code/Magento/ProductAlert/Block/Email/Stock.php +++ b/app/code/Magento/ProductAlert/Block/Email/Stock.php @@ -23,6 +23,8 @@ */ namespace Magento\ProductAlert\Block\Email; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * ProductAlert email back in stock grid * @@ -42,18 +44,20 @@ class Stock extends \Magento\ProductAlert\Block\Email\AbstractEmail /** * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Catalog\Helper\Image $imageHelper * @param \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode + * @param PriceCurrencyInterface $priceCurrency + * @param \Magento\Catalog\Helper\Image $imageHelper * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode, + PriceCurrencyInterface $priceCurrency, \Magento\Catalog\Helper\Image $imageHelper, array $data = array() ) { $this->_imageHelper = $imageHelper; - parent::__construct($context, $maliciousCode, $data); + parent::__construct($context, $maliciousCode, $priceCurrency, $data); } /** diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 6649bbd012abf5f4639d804a1a48607819c087f2..601bf0613c8a6152539d28fdd39fd9ad9c6e61f0 100644 --- a/app/code/Magento/ProductAlert/composer.json +++ b/app/code/Magento/ProductAlert/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/Block/Adminhtml/Payment/View/Items.php b/app/code/Magento/RecurringPayment/Block/Adminhtml/Payment/View/Items.php index b6a979ea3ce17b0a8fcf5c9e9c0510caa36f476d..c156de1c8b700216fdf18abd8f69d52d23f9fd71 100644 --- a/app/code/Magento/RecurringPayment/Block/Adminhtml/Payment/View/Items.php +++ b/app/code/Magento/RecurringPayment/Block/Adminhtml/Payment/View/Items.php @@ -23,11 +23,37 @@ */ namespace Magento\RecurringPayment\Block\Adminhtml\Payment\View; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml recurring payment items grid */ class Items extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems { + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService + * @param \Magento\Framework\Registry $registry + * @param PriceCurrencyInterface $priceCurrency + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, + \Magento\Framework\Registry $registry, + PriceCurrencyInterface $priceCurrency, + array $data = array() + ) { + $this->priceCurrency = $priceCurrency; + parent::__construct($context, $stockItemService, $registry, $data); + } + + /** * Retrieve required options from parent * @@ -71,6 +97,11 @@ class Items extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems public function formatPrice($value) { $store = $this->_storeManager->getStore($this->_getRecurringPayment()->getStore()); - return $store->formatPrice($value); + return $this->priceCurrency->format( + $value, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $store + ); } } diff --git a/app/code/Magento/RecurringPayment/Model/Observer/AddFormExcludedAttribute.php b/app/code/Magento/RecurringPayment/Model/Observer/AddFormExcludedAttribute.php new file mode 100644 index 0000000000000000000000000000000000000000..c86150cdafcf97c154390130396d3a67c7c20182 --- /dev/null +++ b/app/code/Magento/RecurringPayment/Model/Observer/AddFormExcludedAttribute.php @@ -0,0 +1,41 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\RecurringPayment\Model\Observer; + +class AddFormExcludedAttribute +{ + /** + * Add recurring payment field to excluded list + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + $block = $observer->getEvent()->getObject(); + + $block->setFormExcludedFieldList(array_merge($block->getFormExcludedFieldList(), array('recurring_payment'))); + } +} diff --git a/app/code/Magento/RecurringPayment/Model/Observer.php b/app/code/Magento/RecurringPayment/Model/Observer/PrepareProductRecurringPaymentOptions.php similarity index 64% rename from app/code/Magento/RecurringPayment/Model/Observer.php rename to app/code/Magento/RecurringPayment/Model/Observer/PrepareProductRecurringPaymentOptions.php index 0076a8d7200cf902cf5ba15463f0878b42d7dae4..6ab7b2335824c9490682612e792fb285158e70a8 100644 --- a/app/code/Magento/RecurringPayment/Model/Observer.php +++ b/app/code/Magento/RecurringPayment/Model/Observer/PrepareProductRecurringPaymentOptions.php @@ -1,5 +1,6 @@ <?php /** + * * Magento * * NOTICE OF LICENSE @@ -21,19 +22,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\RecurringPayment\Model; +namespace Magento\RecurringPayment\Model\Observer; -/** - * Recurring payment observer - */ -class Observer +class PrepareProductRecurringPaymentOptions { /** - * Locale model + * @var \Magento\RecurringPayment\Block\Fields + */ + protected $_fields; + + /** + * Recurring payment factory * - * @var \Magento\Framework\LocaleInterface + * @var \Magento\RecurringPayment\Model\RecurringPaymentFactory */ - protected $_locale; + protected $_recurringPaymentFactory; /** * Store manager @@ -43,16 +46,11 @@ class Observer protected $_storeManager; /** - * Recurring payment factory + * Locale model * - * @var \Magento\RecurringPayment\Model\RecurringPaymentFactory - */ - protected $_recurringPaymentFactory; - - /** - * @var \Magento\RecurringPayment\Block\Fields + * @var \Magento\Framework\LocaleInterface */ - protected $_fields; + protected $_locale; /** * @param \Magento\Framework\LocaleInterface $locale @@ -80,7 +78,7 @@ class Observer * @param \Magento\Framework\Event\Observer $observer * @return void */ - public function prepareProductRecurringPaymentOptions($observer) + public function execute($observer) { $product = $observer->getEvent()->getProduct(); $buyRequest = $observer->getEvent()->getBuyRequest(); @@ -115,68 +113,4 @@ class Observer } $product->addCustomOption('additional_options', serialize($infoOptions)); } - - /** - * Unserialize product recurring payment - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function unserializeProductRecurringPayment($observer) - { - $collection = $observer->getEvent()->getCollection(); - - foreach ($collection as $product) { - if ($product->getIsRecurring() && ($payment = $product->getRecurringPayment())) { - $product->setRecurringPayment(unserialize($payment)); - } - } - } - - /** - * Set recurring data to quote - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function setIsRecurringToQuote($observer) - { - $quote = $observer->getEvent()->getQuoteItem(); - $product = $observer->getEvent()->getProduct(); - - $quote->setIsRecurring($product->getIsRecurring()); - } - - /** - * Add recurring payment field to excluded list - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function addFormExcludedAttribute($observer) - { - $block = $observer->getEvent()->getObject(); - - $block->setFormExcludedFieldList(array_merge($block->getFormExcludedFieldList(), array('recurring_payment'))); - } - - /** - * Set recurring payment renderer - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function setFormRecurringElementRenderer($observer) - { - $form = $observer->getEvent()->getForm(); - - $recurringPaymentElement = $form->getElement('recurring_payment'); - $recurringPaymentBlock = $observer->getEvent()->getLayout()->createBlock( - 'Magento\RecurringPayment\Block\Adminhtml\Product\Edit\Tab\Price\Recurring' - ); - - if ($recurringPaymentElement) { - $recurringPaymentElement->setRenderer($recurringPaymentBlock); - } - } } diff --git a/app/code/Magento/RecurringPayment/Model/Observer/SetFormRecurringElementRenderer.php b/app/code/Magento/RecurringPayment/Model/Observer/SetFormRecurringElementRenderer.php new file mode 100644 index 0000000000000000000000000000000000000000..b6b925d4fabab74ed491e2184b82f1fccf073d73 --- /dev/null +++ b/app/code/Magento/RecurringPayment/Model/Observer/SetFormRecurringElementRenderer.php @@ -0,0 +1,48 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\RecurringPayment\Model\Observer; + +class SetFormRecurringElementRenderer +{ + /** + * Set recurring payment renderer + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + $form = $observer->getEvent()->getForm(); + + $recurringPaymentElement = $form->getElement('recurring_payment'); + $recurringPaymentBlock = $observer->getEvent()->getLayout()->createBlock( + 'Magento\RecurringPayment\Block\Adminhtml\Product\Edit\Tab\Price\Recurring' + ); + + if ($recurringPaymentElement) { + $recurringPaymentElement->setRenderer($recurringPaymentBlock); + } + } +} diff --git a/app/code/Magento/RecurringPayment/Model/Observer/SetIsRecurringToQuote.php b/app/code/Magento/RecurringPayment/Model/Observer/SetIsRecurringToQuote.php new file mode 100644 index 0000000000000000000000000000000000000000..75a41d4463edfc26549bde632b530c1211cc53bb --- /dev/null +++ b/app/code/Magento/RecurringPayment/Model/Observer/SetIsRecurringToQuote.php @@ -0,0 +1,42 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\RecurringPayment\Model\Observer; + +class SetIsRecurringToQuote +{ + /** + * Set recurring data to quote + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + $quote = $observer->getEvent()->getQuoteItem(); + $product = $observer->getEvent()->getProduct(); + + $quote->setIsRecurring($product->getIsRecurring()); + } +} diff --git a/app/code/Magento/RecurringPayment/Model/Observer/UnserializeProductRecurringPayment.php b/app/code/Magento/RecurringPayment/Model/Observer/UnserializeProductRecurringPayment.php new file mode 100644 index 0000000000000000000000000000000000000000..6e652f3805647bdc8f78f46bc0048372e2e52c2d --- /dev/null +++ b/app/code/Magento/RecurringPayment/Model/Observer/UnserializeProductRecurringPayment.php @@ -0,0 +1,46 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\RecurringPayment\Model\Observer; + +class UnserializeProductRecurringPayment +{ + /** + * Unserialize product recurring payment + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + $collection = $observer->getEvent()->getCollection(); + + foreach ($collection as $product) { + $payment = $product->getRecurringPayment(); + if ($product->getIsRecurring() && $payment) { + $product->setRecurringPayment(unserialize($payment)); + } + } + } +} diff --git a/app/code/Magento/RecurringPayment/Model/Quote/Total/AbstractRecurring.php b/app/code/Magento/RecurringPayment/Model/Quote/Total/AbstractRecurring.php index 8c79f5bb0d7bd0f8f30fab9479567e1ca6d24eb2..efa617517661887727ffa47773ad54bfe2b15be2 100644 --- a/app/code/Magento/RecurringPayment/Model/Quote/Total/AbstractRecurring.php +++ b/app/code/Magento/RecurringPayment/Model/Quote/Total/AbstractRecurring.php @@ -23,6 +23,8 @@ */ namespace Magento\RecurringPayment\Model\Quote\Total; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Total model for recurring payments */ @@ -49,6 +51,20 @@ abstract class AbstractRecurring extends \Magento\Sales\Model\Quote\Address\Tota */ protected $_paymentDataKey = null; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** + * @param PriceCurrencyInterface $priceCurrency + */ + public function __construct( + PriceCurrencyInterface $priceCurrency + ) { + $this->priceCurrency = $priceCurrency; + } + /** * Collect recurring item parameters and copy to the address items * @@ -65,7 +81,10 @@ abstract class AbstractRecurring extends \Magento\Sales\Model\Quote\Address\Tota if (!empty($paymentData[$this->_paymentDataKey])) { $item->setData( $this->_itemRowTotalKey, - $address->getQuote()->getStore()->convertPrice($paymentData[$this->_paymentDataKey]) + $this->priceCurrency->convert( + $paymentData[$this->_paymentDataKey], + $address->getQuote()->getStore() + ) ); $this->_afterCollectSuccess($address, $item); } diff --git a/app/code/Magento/RecurringPayment/composer.json b/app/code/Magento/RecurringPayment/composer.json index 8f1a7652d6427438c3c1216a031fc4ef89326d00..e582f45999e7959d77ba0689dbb6813df5ba748e 100644 --- a/app/code/Magento/RecurringPayment/composer.json +++ b/app/code/Magento/RecurringPayment/composer.json @@ -3,21 +3,22 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/etc/adminhtml/events.xml b/app/code/Magento/RecurringPayment/etc/adminhtml/events.xml index 1cc1c666f9383602fe1d60c13c9d2c0d81202007..55db7fe936fb7ebe76e8bec3311d313714dbd266 100644 --- a/app/code/Magento/RecurringPayment/etc/adminhtml/events.xml +++ b/app/code/Magento/RecurringPayment/etc/adminhtml/events.xml @@ -25,9 +25,9 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> <event name="adminhtml_catalog_product_form_prepare_excluded_field_list"> - <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer" method="addFormExcludedAttribute"/> + <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer\AddFormExcludedAttribute" method="execute"/> </event> <event name="adminhtml_catalog_product_edit_prepare_form"> - <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer" method="setFormRecurringElementRenderer"/> + <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer\SetFormRecurringElementRenderer" method="execute"/> </event> </config> diff --git a/app/code/Magento/RecurringPayment/etc/events.xml b/app/code/Magento/RecurringPayment/etc/events.xml index b907b714472bfe679b0800e6fafe25213dd45c50..64c3a48ef318f7bf4addd19ad1248ccf8cb22c47 100644 --- a/app/code/Magento/RecurringPayment/etc/events.xml +++ b/app/code/Magento/RecurringPayment/etc/events.xml @@ -37,9 +37,9 @@ <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer\PaymentAvailabilityObserver" method="observe" /> </event> <event name="catalog_product_collection_load_after"> - <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer" method="unserializeProductRecurringPayment" /> + <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer\UnserializeProductRecurringPayment" method="execute" /> </event> <event name="sales_quote_item_set_product"> - <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer" method="setIsRecurringToQuote" /> + <observer name="magento_recurringpayment" instance="Magento\RecurringPayment\Model\Observer\SetIsRecurringToQuote" method="execute" /> </event> </config> diff --git a/app/code/Magento/RecurringPayment/etc/frontend/events.xml b/app/code/Magento/RecurringPayment/etc/frontend/events.xml index 1b5eb81801a48d6c6a6aa991b614299d59bcab2f..fb67874cf53b25fa0a55311c6dd6a3fce1348bb3 100644 --- a/app/code/Magento/RecurringPayment/etc/frontend/events.xml +++ b/app/code/Magento/RecurringPayment/etc/frontend/events.xml @@ -25,6 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> <event name="catalog_product_type_prepare_full_options"> - <observer name="recurring_payment_prepare_options" instance="Magento\RecurringPayment\Model\Observer" method="prepareProductRecurringPaymentOptions" /> + <observer name="recurring_payment_prepare_options" instance="Magento\RecurringPayment\Model\Observer\PrepareProductRecurringPaymentOptions" method="execute" /> </event> </config> diff --git a/app/code/Magento/RecurringPayment/etc/module.xml b/app/code/Magento/RecurringPayment/etc/module.xml index bef5e072ef2f330f049fe50d92d96242fb3f186e..a2f6dbc541cb8b8f673948d17a1ee8650d89caef 100644 --- a/app/code/Magento/RecurringPayment/etc/module.xml +++ b/app/code/Magento/RecurringPayment/etc/module.xml @@ -40,6 +40,7 @@ <module name="Magento_Payment"/> <module name="Magento_Sales"/> <module name="Magento_Theme"/> + <module name="Magento_CatalogInventory"/> </depends> </module> </config> diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php index f7ab6b0a0d8c6bf64360eda49524f022c7ee1642..d255990093d12115c137db24af82e8e7bde72577 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php @@ -83,7 +83,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -109,7 +109,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -136,7 +136,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php index 89942c3b4cf8c4e7e2ac3e1fd7e2192103ab2140..cf11f3ba3afdb6c6a714d5439e620b6f82ebe20d 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php @@ -55,7 +55,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -79,7 +79,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -101,7 +101,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php index 072550c026ee45c3c33d650a938a36b7b70eb7c4..0085cc2ad70482a06fcb09e4a34dad5940308d03 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php @@ -67,7 +67,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -95,7 +95,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -121,7 +121,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index 4b5426fb21171895a48c7f7bc3aff786a9096647..21509183ce076fae62227d27d86f42ca006ace71 100644 --- a/app/code/Magento/Reports/composer.json +++ b/app/code/Magento/Reports/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-widget": "0.1.0-alpha95", - "magento/module-log": "0.1.0-alpha95", - "magento/module-wishlist": "0.1.0-alpha95", - "magento/module-review": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-downloadable": "0.1.0-alpha95", - "magento/module-sales-rule": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-widget": "0.1.0-alpha96", + "magento/module-log": "0.1.0-alpha96", + "magento/module-wishlist": "0.1.0-alpha96", + "magento/module-review": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-downloadable": "0.1.0-alpha96", + "magento/module-sales-rule": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index 6c2d254e4602f3e2df9ba207cbed0078789ea13b..7f4749db302ce3bd5f12a6422aef2d75b165ea1b 100644 --- a/app/code/Magento/RequireJs/composer.json +++ b/app/code/Magento/RequireJs/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php index fd288835d291c1bc2d2de963f6a69ffc3ca1412f..c536ba4ac4c25743f1852ae56dd5f014506d0e51 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php @@ -85,7 +85,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Helper\Data $catalogData + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -110,7 +110,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Catalog\Helper\Data $catalogData, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -135,7 +135,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $resourceHelper, $universalFactory, $storeManager, - $catalogData, + $moduleManager, $catalogProductFlatState, $scopeConfig, $productOptionFactory, diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index e5f0c67753d353a30a411614f310a7eecf6f81f5..68fbc4e7a88c966f0f96a254b371acf12bc690e1 100644 --- a/app/code/Magento/Review/composer.json +++ b/app/code/Magento/Review/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-newsletter": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-newsletter": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index 23a776ea84a18d048c9ad8ad9d7b9b9e8c0cce56..cfe36e2b75e07ec158e8ac2390d163df248bb252 100644 --- a/app/code/Magento/Rss/composer.json +++ b/app/code/Magento/Rss/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-sales-rule": "0.1.0-alpha95", - "magento/module-review": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-gift-message": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-sales-rule": "0.1.0-alpha96", + "magento/module-review": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-gift-message": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index ad76ec72f5298e9a4aa5f27b15dfd32b54ff2923..e39949448c98f97a99829645daf2d8c1958e994d 100644 --- a/app/code/Magento/Rule/composer.json +++ b/app/code/Magento/Rule/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php index febf4d8ef246e64272f786abca8c596ed7962e7a..4aa78d6149e806b406a3c9cfb6afcd849b639147 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Address; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml sales order address block */ @@ -46,6 +48,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Data\FormFactory $formFactory * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder @@ -61,6 +64,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Core\Helper\Data $coreData, \Magento\Framework\Json\EncoderInterface $jsonEncoder, @@ -76,6 +80,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address $context, $sessionQuote, $orderCreate, + $priceCurrency, $formFactory, $coreData, $jsonEncoder, diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php index 8a441818a05c27014f201dd9eee9baa379023581..73c782850187f8221f923a301e689a7fb6d40fca 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml sales order create abstract block * @@ -44,18 +46,26 @@ abstract class AbstractCreate extends \Magento\Backend\Block\Widget */ protected $_orderCreate; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_sessionQuote = $sessionQuote; $this->_orderCreate = $orderCreate; parent::__construct($context, $data); @@ -124,12 +134,17 @@ abstract class AbstractCreate extends \Magento\Backend\Block\Widget /** * Retrieve formated price * - * @param decimal $value + * @param float $value * @return string */ public function formatPrice($value) { - return $this->getStore()->formatPrice($value); + return $this->priceCurrency->format( + $value, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $this->getStore() + ); } /** @@ -141,6 +156,13 @@ abstract class AbstractCreate extends \Magento\Backend\Block\Widget */ public function convertPrice($value, $format = true) { - return $this->getStore()->convertPrice($value, $format); + return $format + ? $this->priceCurrency->convertAndFormat( + $value, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $this->getStore() + ) + : $this->priceCurrency->convert($value, $this->getStore()); } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Data.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Data.php index 587edfd2b11003fafc03cc04f1d05961d1f56346..416cb72e4c4678ba38d7e6a7cd160f52928ca254 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Data.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Data.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Order create data * @@ -46,6 +48,7 @@ class Data extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency * @param array $data @@ -54,13 +57,14 @@ class Data extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, array $data = array() ) { $this->_currencyFactory = $currencyFactory; $this->_localeCurrency = $localeCurrency; - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php index c189536d5ca244db1a04f58f5543ec1e1ce5bf32..67af3c233e4c94f48f4438eb75b4c6686ab9f9c5 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php @@ -24,6 +24,7 @@ namespace Magento\Sales\Block\Adminhtml\Order\Create; use Magento\Customer\Service\V1\Data\AddressConverter; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Adminhtml sales order create form block @@ -60,6 +61,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService @@ -70,6 +72,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory, \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, @@ -80,7 +83,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate $this->_customerFormFactory = $customerFormFactory; $this->_addressService = $addressService; $this->_localeCurrency = $localeCurrency; - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php index b54d0c37362d006ded24f2ce50840aca66be8cab..4be492dfaff0f8d92808511b1831758d0d9bf69e 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Form; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Sales Order Create Form Abstract Block * @@ -48,6 +50,7 @@ abstract class AbstractForm extends \Magento\Sales\Block\Adminhtml\Order\Create\ * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Data\FormFactory $formFactory * @param array $data */ @@ -55,11 +58,12 @@ abstract class AbstractForm extends \Magento\Sales\Block\Adminhtml\Order\Create\ \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\FormFactory $formFactory, array $data = array() ) { $this->_formFactory = $formFactory; - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php index 92c7c721dce5b7522593645ef85a5fa2c6a0a7e7..928a84110c7e97a0379504a376735253034d5975 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php @@ -25,6 +25,7 @@ namespace Magento\Sales\Block\Adminhtml\Order\Create\Form; use Magento\Framework\Data\Form\Element\AbstractElement; use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Framework\Service\ExtensibleDataObjectConverter; /** @@ -48,6 +49,7 @@ class Account extends AbstractForm * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Data\FormFactory $formFactory * @param \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory * @param CustomerAccountServiceInterface $customerAccountService @@ -57,6 +59,7 @@ class Account extends AbstractForm \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory, CustomerAccountServiceInterface $customerAccountService, @@ -64,7 +67,7 @@ class Account extends AbstractForm ) { $this->_metadataFormFactory = $metadataFormFactory; $this->_customerAccountService = $customerAccountService; - parent::__construct($context, $sessionQuote, $orderCreate, $formFactory, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $formFactory, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php index 3662e8b79ccca517377336fb24242aa2d9619c40..14b5fbbfb83b879d79efb506aae524a2e70a8e1f 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php @@ -25,6 +25,7 @@ namespace Magento\Sales\Block\Adminhtml\Order\Create\Form; use Magento\Framework\Data\Form\Element\AbstractElement; use Magento\Customer\Service\V1\Data\AddressConverter; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Order create address form @@ -77,6 +78,7 @@ class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Data\FormFactory $formFactory * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder @@ -92,6 +94,7 @@ class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Core\Helper\Data $coreData, \Magento\Framework\Json\EncoderInterface $jsonEncoder, @@ -107,7 +110,7 @@ class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF $this->_customerFormFactory = $customerFormFactory; $this->_addressService = $addressService; $this->_addressHelper = $addressHelper; - parent::__construct($context, $sessionQuote, $orderCreate, $formFactory, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $formFactory, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Giftmessage.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Giftmessage.php index eff52afbfc0c727baacef7af701b2c77bf0b7108..be381e3b7b2b4d9fcf4c3718f41218fb515a955b 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Giftmessage.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Giftmessage.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml order create gift message block * @@ -48,6 +50,7 @@ class Giftmessage extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCr * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\GiftMessage\Model\Save $giftMessageSave * @param \Magento\GiftMessage\Helper\Message $messageHelper * @param array $data @@ -56,13 +59,14 @@ class Giftmessage extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCr \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\GiftMessage\Model\Save $giftMessageSave, \Magento\GiftMessage\Helper\Message $messageHelper, array $data = array() ) { $this->_messageHelper = $messageHelper; $this->_giftMessageSave = $giftMessageSave; - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php index 956c6572c2c65a1841bd0fc82a5fe4e8886c7af1..988a7fc7ef2f037a1ed66d748be875910f8d0d0c 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php @@ -24,6 +24,7 @@ namespace Magento\Sales\Block\Adminhtml\Order\Create; use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Create order form header @@ -41,11 +42,10 @@ class Header extends AbstractCreate protected $_customerViewHelper; /** - * Initialize dependencies. - * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Helper\View $customerViewHelper * @param array $data @@ -54,13 +54,14 @@ class Header extends AbstractCreate \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Helper\View $customerViewHelper, array $data = array() ) { $this->_customerAccountService = $customerAccountService; $this->_customerViewHelper = $customerViewHelper; - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php index 2e2063909941b998b206bfe7854cdd31ac4679ff..06091d60c6257fc9f0124e7ec9f8f01c8968d56c 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php @@ -24,6 +24,7 @@ namespace Magento\Sales\Block\Adminhtml\Order\Create\Items; use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Quote\Item; use Magento\Framework\Session\SessionManagerInterface; @@ -83,6 +84,7 @@ class Grid extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory * @param \Magento\GiftMessage\Model\Save $giftMessageSave * @param \Magento\Tax\Model\Config $taxConfig @@ -95,6 +97,7 @@ class Grid extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, \Magento\GiftMessage\Model\Save $giftMessageSave, \Magento\Tax\Model\Config $taxConfig, @@ -109,7 +112,7 @@ class Grid extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate $this->_taxConfig = $taxConfig; $this->_taxData = $taxData; $this->stockItemService = $stockItemService; - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Method/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Method/Form.php index af541c33a076630363d862e1dd0a7de62de2a9d6..09e4c7970d8d26f02de9fe5937a1c854c03254ff 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Method/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Method/Form.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Method; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml sales order create shipping method form block * @@ -44,22 +46,32 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate */ protected $_taxData = null; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Tax\Helper\Data $taxData + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Tax\Helper\Data $taxData, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_taxData = $taxData; - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** @@ -175,7 +187,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate */ public function getShippingPrice($price, $flag) { - return $this->getQuote()->getStore()->convertPrice( + return $this->priceCurrency->convertAndFormat( $this->_taxData->getShippingPrice( $price, $flag, @@ -183,7 +195,9 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate null, $this->getAddress()->getQuote()->getStore() ), - true + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $this->getQuote()->getStore() ); } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php index 9f99d53280c5bb268a2c00bc269ebccf5a411dca..191e3ba7e4efd882b1be6df05f17b481c17ccf7d 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml sales order create sidebar block * @@ -48,6 +50,7 @@ class AbstractSidebar extends \Magento\Sales\Block\Adminhtml\Order\Create\Abstra * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Sales\Model\Config $salesConfig * @param array $data */ @@ -55,10 +58,11 @@ class AbstractSidebar extends \Magento\Sales\Block\Adminhtml\Order\Create\Abstra \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Model\Config $salesConfig, array $data = array() ) { - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); $this->_salesConfig = $salesConfig; } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Pcompared.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Pcompared.php index 40f0e8ebd89364d92ca63d73f482ff62a21f8724..addf10525ac5e2a6a11bd44d44ddac77bdbd9883 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Pcompared.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Pcompared.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml sales order create sidebar recently compared block * @@ -48,6 +50,7 @@ class Pcompared extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Abst * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Sales\Model\Config $salesConfig * @param \Magento\Reports\Model\Resource\Event $event * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -57,6 +60,7 @@ class Pcompared extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Abst \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Model\Config $salesConfig, \Magento\Reports\Model\Resource\Event $event, \Magento\Catalog\Model\ProductFactory $productFactory, @@ -64,7 +68,7 @@ class Pcompared extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Abst ) { $this->_event = $event; $this->_productFactory = $productFactory; - parent::__construct($context, $sessionQuote, $orderCreate, $salesConfig, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $salesConfig, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Pviewed.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Pviewed.php index 5128e0d1745fd0afc5083a78893a8b219b620095..c6c5648e5a7098acec5ddf57c30cf8be74ba97a7 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Pviewed.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Pviewed.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml sales order create sidebar recently view block * @@ -48,6 +50,7 @@ class Pviewed extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Abstra * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Sales\Model\Config $salesConfig * @param \Magento\Reports\Model\EventFactory $eventFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -57,6 +60,7 @@ class Pviewed extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Abstra \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Model\Config $salesConfig, \Magento\Reports\Model\EventFactory $eventFactory, \Magento\Catalog\Model\ProductFactory $productFactory, @@ -64,7 +68,7 @@ class Pviewed extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Abstra ) { $this->_eventFactory = $eventFactory; $this->_productFactory = $productFactory; - parent::__construct($context, $sessionQuote, $orderCreate, $salesConfig, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $salesConfig, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Reorder.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Reorder.php index 038644a4a14dbd54dc6a6f0485bbcdd6f080cdd0..9fffe8eaca8e8bcc9ea39543b391890baaa2c7dd 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Reorder.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Reorder.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml sales order create sidebar cart block * @@ -48,6 +50,7 @@ class Reorder extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Abstra * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Sales\Model\Config $salesConfig * @param \Magento\Sales\Model\Resource\Order\CollectionFactory $ordersFactory * @param array $data @@ -56,12 +59,13 @@ class Reorder extends \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Abstra \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Model\Config $salesConfig, \Magento\Sales\Model\Resource\Order\CollectionFactory $ordersFactory, array $data = array() ) { $this->_ordersFactory = $ordersFactory; - parent::__construct($context, $sessionQuote, $orderCreate, $salesConfig, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $salesConfig, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php index 5ad933d04f8f71b97ffe344692845e39d2cf01dd..691242e174f6d5414b3a73738dc5b0d74c9ea9d9 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Adminhtml sales order create totals block * @@ -62,6 +64,7 @@ class Totals extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Sales\Model\Config $salesConfig * @param array $data @@ -70,13 +73,14 @@ class Totals extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Helper\Data $salesData, \Magento\Sales\Model\Config $salesConfig, array $data = array() ) { $this->_salesData = $salesData; $this->_salesConfig = $salesConfig; - parent::__construct($context, $sessionQuote, $orderCreate, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/DefaultTotals.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/DefaultTotals.php index cd296b90bbc0d330d0ee5c7f0cdd9f62c4671545..3789bc305215843abadaae3e4b4cfda8ff1e8f21 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/DefaultTotals.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/DefaultTotals.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Totals; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Default Total Row Renderer * @@ -37,6 +39,12 @@ class DefaultTotals extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals */ protected $_template = 'Magento_Sales::order/create/totals/default.phtml'; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** * Retrieve quote session object * @@ -65,6 +73,11 @@ class DefaultTotals extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals */ public function formatPrice($value) { - return $this->getStore()->formatPrice($value); + return $this->priceCurrency->format( + $value, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $this->getStore() + ); } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Discount.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Discount.php index cd6fdbec247bc63694059c04a2dbc4e03878099c..5d6e41acfead432130fdaee33eb7784854b35a31 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Discount.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Discount.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Totals; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Subtotal Total Row Renderer * @@ -45,6 +47,7 @@ class Discount extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\Defaul * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Sales\Model\Config $salesConfig + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Tax\Model\Config $taxConfig * @param array $data */ @@ -52,13 +55,14 @@ class Discount extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\Defaul \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Helper\Data $salesData, \Magento\Sales\Model\Config $salesConfig, \Magento\Tax\Model\Config $taxConfig, array $data = array() ) { $this->_taxConfig = $taxConfig; - parent::__construct($context, $sessionQuote, $orderCreate, $salesData, $salesConfig, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $salesData, $salesConfig, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Grandtotal.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Grandtotal.php index f8fdcbd119e37e13828e1ef786005fd0bd517f16..0d45b2addbfb7f99ff7efba28a178e5165af88e7 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Grandtotal.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Grandtotal.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Totals; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Subtotal Total Row Renderer * @@ -50,6 +52,7 @@ class Grandtotal extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\Defa * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Sales\Model\Config $salesConfig + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Tax\Model\Config $taxConfig * @param array $data */ @@ -57,13 +60,14 @@ class Grandtotal extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\Defa \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Helper\Data $salesData, \Magento\Sales\Model\Config $salesConfig, \Magento\Tax\Model\Config $taxConfig, array $data = array() ) { $this->_taxConfig = $taxConfig; - parent::__construct($context, $sessionQuote, $orderCreate, $salesData, $salesConfig, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $salesData, $salesConfig, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Shipping.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Shipping.php index 778e7362be5229ee48055f762f009a3b90515d77..338111539942571ae5c7ef1468da21fddf74c9b5 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Shipping.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Shipping.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Totals; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Subtotal Total Row Renderer * @@ -50,6 +52,7 @@ class Shipping extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\Defaul * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Sales\Model\Config $salesConfig + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Tax\Model\Config $taxConfig * @param array $data */ @@ -57,13 +60,14 @@ class Shipping extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\Defaul \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Helper\Data $salesData, \Magento\Sales\Model\Config $salesConfig, \Magento\Tax\Model\Config $taxConfig, array $data = array() ) { $this->_taxConfig = $taxConfig; - parent::__construct($context, $sessionQuote, $orderCreate, $salesData, $salesConfig, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $salesData, $salesConfig, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Subtotal.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Subtotal.php index 8e44c9f74e073bee461ba6c163862ee018fb9bf4..116509106d2852714e1fd20c9cad69306f67205a 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Subtotal.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals/Subtotal.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Totals; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Subtotal Total Row Renderer * @@ -50,6 +52,7 @@ class Subtotal extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\Defaul * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Sales\Model\Config $salesConfig + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Tax\Model\Config $taxConfig * @param array $data */ @@ -57,13 +60,14 @@ class Subtotal extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\Defaul \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, + PriceCurrencyInterface $priceCurrency, \Magento\Sales\Helper\Data $salesData, \Magento\Sales\Model\Config $salesConfig, \Magento\Tax\Model\Config $taxConfig, array $data = array() ) { $this->_taxConfig = $taxConfig; - parent::__construct($context, $sessionQuote, $orderCreate, $salesData, $salesConfig, $data); + parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $salesData, $salesConfig, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php index 04f20dfabe920a5961f055219d2b39680349e53d..49be9bdceaccafed29b3baeb840e9f3a743b962b 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create; +use Magento\Framework\Pricing\PriceCurrencyInterface; + class Adjustments extends \Magento\Backend\Block\Template { /** @@ -39,17 +41,25 @@ class Adjustments extends \Magento\Backend\Block\Template */ protected $_taxConfig; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Tax\Model\Config $taxConfig + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Tax\Model\Config $taxConfig, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { $this->_taxConfig = $taxConfig; + $this->priceCurrency = $priceCurrency; parent::__construct($context, $data); } @@ -93,7 +103,7 @@ class Adjustments extends \Magento\Backend\Block\Template } else { $shipping = $source->getBaseShippingAmount(); } - return $this->_storeManager->getStore()->roundPrice($shipping) * 1; + return $this->priceCurrency->round($shipping) * 1; } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php index c3f346bd6a0f87606aef8b74c73fa0faf0f7398f..9ce8319710b23a979e3487da6549667277f9cc1c 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php @@ -95,8 +95,6 @@ class Tax extends \Magento\Tax\Block\Sales\Order\Tax $taxClassAmount = array(); if ($source instanceof \Magento\Sales\Model\Order) { $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($source); - $shippingTax = $this->_taxHelper->getShippingTax($source); - $taxClassAmount = array_merge($taxClassAmount, $shippingTax); if (empty($taxClassAmount)) { $rates = $this->_taxOrderFactory->create()->getCollection()->loadByOrder($source)->toArray(); $taxClassAmount = $this->_taxCalculation->reproduceProcess($rates['items']); diff --git a/app/code/Magento/Sales/Helper/Admin.php b/app/code/Magento/Sales/Helper/Admin.php index 0b8975bdb46da27280a3635abd8c6c472797ec4b..2b38d4a0f9e6572a65c0570096b5e3388cf7a998 100644 --- a/app/code/Magento/Sales/Helper/Admin.php +++ b/app/code/Magento/Sales/Helper/Admin.php @@ -35,16 +35,24 @@ class Admin extends \Magento\Framework\App\Helper\AbstractHelper */ protected $_storeManager; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Config $salesConfig + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\StoreManagerInterface $storeManager, - \Magento\Sales\Model\Config $salesConfig + \Magento\Sales\Model\Config $salesConfig, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency ) { + $this->priceCurrency = $priceCurrency; $this->_storeManager = $storeManager; $this->_salesConfig = $salesConfig; parent::__construct($context); @@ -100,7 +108,7 @@ class Admin extends \Magento\Framework\App\Helper\AbstractHelper $res = '<strong>' . $res . '</strong>'; } } else { - $res = $this->_storeManager->getStore()->formatPrice($price); + $res = $this->priceCurrency->format($price); if ($strong) { $res = '<strong>' . $res . '</strong>'; } diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 6097c84f3a3c714b1c707fffb033485cb4b38783..6287f080a61bfbf6c27d0f3b1d7c4b0e11ae560e 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -24,6 +24,7 @@ namespace Magento\Sales\Model; use Magento\Directory\Model\Currency; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Order\Payment; use Magento\Sales\Model\Resource\Order\Address\Collection; use Magento\Sales\Model\Resource\Order\Creditmemo\Collection as CreditmemoCollection; @@ -546,6 +547,11 @@ class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterfac */ protected $_trackCollectionFactory; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -569,6 +575,7 @@ class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterfac * @param Resource\Order\Shipment\CollectionFactory $shipmentCollectionFactory * @param Resource\Order\Creditmemo\CollectionFactory $memoCollectionFactory * @param Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -596,6 +603,7 @@ class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterfac \Magento\Sales\Model\Resource\Order\Shipment\CollectionFactory $shipmentCollectionFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\CollectionFactory $memoCollectionFactory, \Magento\Sales\Model\Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -619,6 +627,7 @@ class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterfac $this->_shipmentCollectionFactory = $shipmentCollectionFactory; $this->_memoCollectionFactory = $memoCollectionFactory; $this->_trackCollectionFactory = $trackCollectionFactory; + $this->priceCurrency = $priceCurrency; parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } @@ -847,7 +856,7 @@ class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterfac * for this we have additional diapason for 0 * TotalPaid - contains amount, that were not rounded. */ - if (abs($this->getStore()->roundPrice($this->getTotalPaid()) - $this->getTotalRefunded()) < .0001) { + if (abs($this->priceCurrency->round($this->getTotalPaid()) - $this->getTotalRefunded()) < .0001) { return false; } @@ -1590,7 +1599,7 @@ class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterfac } /** - * @return array + * @return \Magento\Sales\Model\Order\Item[] */ public function getAllItems() { @@ -1945,7 +1954,7 @@ class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterfac public function getTotalDue() { $total = $this->getGrandTotal() - $this->getTotalPaid(); - $total = $this->_storeManager->getStore($this->getStoreId())->roundPrice($total); + $total = $this->priceCurrency->round($total); return max($total, 0); } @@ -1957,7 +1966,7 @@ class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterfac public function getBaseTotalDue() { $total = $this->getBaseGrandTotal() - $this->getBaseTotalPaid(); - $total = $this->_storeManager->getStore($this->getStoreId())->roundPrice($total); + $total = $this->priceCurrency->round($total); return max($total, 0); } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index 5ac213c6df2e8f8f4985d58c5cdddf6d67d9ba41..1b8ff49df01381ef4cf01c69e29bcdab7cebf084 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -24,6 +24,7 @@ namespace Magento\Sales\Model\Order; use Magento\Framework\Model\Exception; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\EntityInterface; /** @@ -211,6 +212,11 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInt */ protected $_commentCollectionFactory; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -223,6 +229,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInt * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Creditmemo\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -239,6 +246,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInt \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Creditmemo\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -250,6 +258,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInt $this->_storeManager = $storeManager; $this->_commentFactory = $commentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; + $this->priceCurrency = $priceCurrency; parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } @@ -503,14 +512,14 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInt public function refund() { $this->setState(self::STATE_REFUNDED); - $orderRefund = $this->_storeManager->getStore()->roundPrice( + $orderRefund = $this->priceCurrency->round( $this->getOrder()->getTotalRefunded() + $this->getGrandTotal() ); - $baseOrderRefund = $this->_storeManager->getStore()->roundPrice( + $baseOrderRefund = $this->priceCurrency->round( $this->getOrder()->getBaseTotalRefunded() + $this->getBaseGrandTotal() ); - if ($baseOrderRefund > $this->_storeManager->getStore()->roundPrice($this->getOrder()->getBaseTotalPaid())) { + if ($baseOrderRefund > $this->priceCurrency->round($this->getOrder()->getBaseTotalPaid())) { $baseAvailableRefund = $this->getOrder()->getBaseTotalPaid() - $this->getOrder()->getBaseTotalRefunded(); @@ -710,10 +719,10 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInt public function setShippingAmount($amount) { // base shipping amount calculated in total model - // $amount = $this->getStore()->roundPrice($amount); + // $amount = $this->getStore()->round($amount); // $this->setData('base_shipping_amount', $amount); // - // $amount = $this->getStore()->roundPrice( + // $amount = $this->getStore()->round( // $amount*$this->getOrder()->getStoreToOrderRate() // ); $this->setData('shipping_amount', $amount); @@ -732,10 +741,10 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInt $amount = $this->getOrder()->getGrandTotal() * $amount / 100; } - $amount = $this->getStore()->roundPrice($amount); + $amount = $this->priceCurrency->round($amount); $this->setData('base_adjustment_positive', $amount); - $amount = $this->getStore()->roundPrice($amount * $this->getOrder()->getBaseToOrderRate()); + $amount = $this->priceCurrency->round($amount * $this->getOrder()->getBaseToOrderRate()); $this->setData('adjustment_positive', $amount); return $this; } @@ -752,10 +761,10 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInt $amount = $this->getOrder()->getGrandTotal() * $amount / 100; } - $amount = $this->getStore()->roundPrice($amount); + $amount = $this->priceCurrency->round($amount); $this->setData('base_adjustment_negative', $amount); - $amount = $this->getStore()->roundPrice($amount * $this->getOrder()->getBaseToOrderRate()); + $amount = $this->priceCurrency->round($amount * $this->getOrder()->getBaseToOrderRate()); $this->setData('adjustment_negative', $amount); return $this; } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php index 61e6b2dbb9721fbddf4646d88faef948627ca1ec..1d0fe73ea866bd688d18aca445d050430eb1a7de 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Order\Creditmemo\Total; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Order creditmemo shipping total calculation model */ @@ -38,17 +40,25 @@ class Shipping extends AbstractTotal */ protected $_taxConfig; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Tax\Model\Config $taxConfig + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Tax\Model\Config $taxConfig, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { parent::__construct($data); + $this->priceCurrency = $priceCurrency; $this->_storeManager = $storeManager; $this->_taxConfig = $taxConfig; } @@ -76,19 +86,19 @@ class Shipping extends AbstractTotal * Using has magic method to allow setting 0 as shipping amount. */ if ($creditmemo->hasBaseShippingAmount()) { - $baseShippingAmount = $this->_storeManager->getStore()->roundPrice($creditmemo->getBaseShippingAmount()); + $baseShippingAmount = $this->priceCurrency->round($creditmemo->getBaseShippingAmount()); if ($isShippingInclTax && $baseShippingInclTax != 0) { $part = $baseShippingAmount / $baseShippingInclTax; - $shippingInclTax = $this->_storeManager->getStore()->roundPrice($shippingInclTax * $part); + $shippingInclTax = $this->priceCurrency->round($shippingInclTax * $part); $baseShippingInclTax = $baseShippingAmount; - $baseShippingAmount = $this->_storeManager->getStore()->roundPrice($baseShipping * $part); + $baseShippingAmount = $this->priceCurrency->round($baseShipping * $part); } /* * Rounded allowed shipping refund amount is the highest acceptable shipping refund amount. * Shipping refund amount shouldn't cause errors, if it doesn't exceed that limit. * Note: ($x < $y + 0.0001) means ($x <= $y) for floats */ - if ($baseShippingAmount < $this->_storeManager->getStore()->roundPrice($baseAllowedAmount) + 0.0001) { + if ($baseShippingAmount < $this->priceCurrency->round($baseAllowedAmount) + 0.0001) { /* * Shipping refund amount should be equated to allowed refund amount, * if it exceeds that limit. @@ -101,7 +111,7 @@ class Shipping extends AbstractTotal if ($baseShipping != 0) { $shipping = $shipping * $baseShippingAmount / $baseShipping; } - $shipping = $this->_storeManager->getStore()->roundPrice($shipping); + $shipping = $this->priceCurrency->round($shipping); $baseShipping = $baseShippingAmount; } } else { @@ -115,8 +125,8 @@ class Shipping extends AbstractTotal $allowedTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded(); $baseAllowedTaxAmount = $order->getBaseShippingTaxAmount() - $order->getBaseShippingTaxRefunded(); - $shippingInclTax = $this->_storeManager->getStore()->roundPrice($allowedAmount + $allowedTaxAmount); - $baseShippingInclTax = $this->_storeManager->getStore()->roundPrice( + $shippingInclTax = $this->priceCurrency->round($allowedAmount + $allowedTaxAmount); + $baseShippingInclTax = $this->priceCurrency->round( $baseAllowedAmount + $baseAllowedTaxAmount ); } diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 3421b7680f591e89d13252d9522030ec83886f29..f0bc9f0f151f70bb94f4cb8a90e08c560e9adff8 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Order; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Order payment information * @@ -204,15 +206,21 @@ class Payment extends \Magento\Payment\Model\Info */ protected $_storeManager; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory - * @param \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory + * @param Payment\TransactionFactory $transactionFactory * @param \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -226,10 +234,12 @@ class Payment extends \Magento\Payment\Model\Info \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory, \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory, \Magento\Framework\StoreManagerInterface $storeManager, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->_serviceOrderFactory = $serviceOrderFactory; $this->_transactionFactory = $transactionFactory; $this->_transactionCollectionFactory = $transactionCollectionFactory; @@ -1513,7 +1523,7 @@ class Payment extends \Magento\Payment\Model\Info */ protected function _formatAmount($amount, $asFloat = false) { - $amount = $this->_storeManager->getStore()->roundPrice($amount); + $amount = $this->priceCurrency->round($amount); return !$asFloat ? (string)$amount : $amount; } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Total/DefaultTotal.php b/app/code/Magento/Sales/Model/Order/Pdf/Total/DefaultTotal.php index 451b429481ed39d7c06d21a6183f5f8c0b9c9fbb..218b81a2412b611b315f6975e81606f58c5e594d 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Total/DefaultTotal.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Total/DefaultTotal.php @@ -112,9 +112,6 @@ class DefaultTotal extends \Magento\Framework\Object { $fontSize = $this->getFontSize() ? $this->getFontSize() : 7; $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($this->getOrder()); - $shippingTax = $this->_taxHelper->getShippingTax($this->getOrder()); - $taxClassAmount = array_merge($shippingTax, $taxClassAmount); - if (!empty($taxClassAmount)) { foreach ($taxClassAmount as &$tax) { $percent = $tax['percent'] ? ' (' . $tax['percent'] . '%)' : ''; diff --git a/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php b/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php index 14f1a9b598dff6e8dc8db523550bfb502ef3e3ea..7968f21d0f5323e97f4f8dd9330bce98ad0b0065 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php +++ b/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php @@ -35,17 +35,19 @@ namespace Magento\Sales\Model\Quote\Address\RateResult; class Method extends AbstractResult { /** - * @var \Magento\Framework\StoreManagerInterface + * @var \Magento\Framework\Pricing\PriceCurrencyInterface */ - protected $_storeManager; + protected $priceCurrency; /** - * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param array $data */ - public function __construct(\Magento\Framework\StoreManagerInterface $storeManager, array $data = array()) - { - $this->_storeManager = $storeManager; + public function __construct( + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, + array $data = array() + ) { + $this->priceCurrency = $priceCurrency; parent::__construct($data); } @@ -57,7 +59,7 @@ class Method extends AbstractResult */ public function setPrice($price) { - $this->setData('price', $this->_storeManager->getStore()->roundPrice($price)); + $this->setData('price', $this->priceCurrency->round($price)); return $this; } } diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Shipping.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Shipping.php index 9a7c67fca05e90b78c3584c9da76a3a582272e61..df22e3f9e1e3b7c99c2840c42dd6e214c2f723e0 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Shipping.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Shipping.php @@ -79,7 +79,9 @@ class Shipping extends \Magento\Sales\Model\Quote\Address\Total\Shipping $address->requestShippingRates($item); $baseAmount = $item->getBaseShippingAmount(); if ($baseAmount) { - $item->setShippingAmount($address->getQuote()->getStore()->convertPrice($baseAmount, false)); + $item->setShippingAmount( + $this->priceCurrency->convert($baseAmount, $address->getQuote()->getStore()) + ); } } } diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Shipping.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Shipping.php index 7f8b03da39fcbbbe4084bcf0287fdd028f43b0e4..fd9e45e674eb680dc0a51de9ae3bc82f4bed4b75 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Shipping.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/Shipping.php @@ -23,13 +23,22 @@ */ namespace Magento\Sales\Model\Quote\Address\Total; +use Magento\Framework\Pricing\PriceCurrencyInterface; + class Shipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal { /** - * Set shipping code + * @var PriceCurrencyInterface */ - public function __construct() - { + protected $priceCurrency; + + /** + * @param PriceCurrencyInterface $priceCurrency + */ + public function __construct( + PriceCurrencyInterface $priceCurrency + ) { + $this->priceCurrency = $priceCurrency; $this->setCode('shipping'); } @@ -153,7 +162,7 @@ class Shipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal if ($method) { foreach ($address->getAllShippingRates() as $rate) { if ($rate->getCode() == $method) { - $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false); + $amountPrice = $this->priceCurrency->convert($rate->getPrice(), $address->getQuote()->getStore()); $this->_setAmount($amountPrice); $this->_setBaseAmount($rate->getPrice()); $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle(); diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Tax.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Tax.php index aaee1b77b0cc22a5ef15c80f65a04e74b7fea7b9..abcf1fc956119866b3fcc4ea07766186ab4a76a6 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Tax.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/Tax.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Quote\Address\Total; +use Magento\Framework\Pricing\PriceCurrencyInterface; + class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal { /** @@ -49,19 +51,27 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal */ protected $_calculation; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Tax\Model\Calculation $calculation + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\Tax\Helper\Data $taxData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Tax\Model\Calculation $calculation + \Magento\Tax\Model\Calculation $calculation, + PriceCurrencyInterface $priceCurrency ) { $this->_taxData = $taxData; $this->_scopeConfig = $scopeConfig; $this->_calculation = $calculation; + $this->priceCurrency = $priceCurrency; $this->setCode('tax'); } @@ -200,8 +210,8 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal $shippingBaseTax = $address->getBaseShippingTaxAmount(); } - $shippingTax = $store->roundPrice($shippingTax); - $shippingBaseTax = $store->roundPrice($shippingBaseTax); + $shippingTax = $this->priceCurrency->round($shippingTax); + $shippingBaseTax = $this->priceCurrency->round($shippingBaseTax); $address->setTaxAmount($address->getTaxAmount() + $shippingTax); $address->setBaseTaxAmount($address->getBaseTaxAmount() + $shippingBaseTax); diff --git a/app/code/Magento/Sales/Model/Quote/Item.php b/app/code/Magento/Sales/Model/Quote/Item.php index 9c9af503c914deeb34570945eb6c4881a0b16a4b..ce285efe13a3927b84980b259bfda8064330dbcb 100644 --- a/app/code/Magento/Sales/Model/Quote/Item.php +++ b/app/code/Magento/Sales/Model/Quote/Item.php @@ -199,6 +199,7 @@ class Item extends \Magento\Sales\Model\Quote\Item\AbstractItem * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Catalog\Model\ProductFactory $productFactory + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Sales\Model\Status\ListFactory $statusListFactory * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param Item\OptionFactory $itemOptionFactory @@ -214,6 +215,7 @@ class Item extends \Magento\Sales\Model\Quote\Item\AbstractItem \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Catalog\Model\ProductFactory $productFactory, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Sales\Model\Status\ListFactory $statusListFactory, \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Sales\Model\Quote\Item\OptionFactory $itemOptionFactory, @@ -228,7 +230,15 @@ class Item extends \Magento\Sales\Model\Quote\Item\AbstractItem $this->_itemOptionFactory = $itemOptionFactory; $this->_compareHelper = $compareHelper; $this->stockItemService = $stockItemService; - parent::__construct($context, $registry, $productFactory, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $productFactory, + $priceCurrency, + $resource, + $resourceCollection, + $data + ); } /** diff --git a/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php b/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php index b37c9dd59c850edc5160e304249e3c500e90e3f1..6b0a1b12fcdad890d4a9d37e3af6025568d5eafd 100644 --- a/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php +++ b/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php @@ -91,10 +91,16 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple */ protected $_productFactory; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Catalog\Model\ProductFactory $productFactory + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -103,12 +109,14 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Catalog\Model\ProductFactory $productFactory, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->_productFactory = $productFactory; + $this->priceCurrency = $priceCurrency; } /** @@ -402,11 +410,11 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple { $qty = $this->getTotalQty(); // Round unit price before multiplying to prevent losing 1 cent on subtotal - $total = $this->getStore()->roundPrice($this->getCalculationPriceOriginal()) * $qty; - $baseTotal = $this->getStore()->roundPrice($this->getBaseCalculationPriceOriginal()) * $qty; + $total = $this->priceCurrency->round($this->getCalculationPriceOriginal()) * $qty; + $baseTotal = $this->priceCurrency->round($this->getBaseCalculationPriceOriginal()) * $qty; - $this->setRowTotal($this->getStore()->roundPrice($total)); - $this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal)); + $this->setRowTotal($this->priceCurrency->round($total)); + $this->setBaseRowTotal($this->priceCurrency->round($baseTotal)); return $this; } @@ -461,7 +469,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple if ($this->hasCustomPrice()) { $price = (double)$this->getCustomPrice(); if ($price) { - $rate = $this->getStore()->convertPrice($price) / $price; + $rate = $this->priceCurrency->convert($price, $this->getStore()) / $price; $price = $price / $rate; } } else { @@ -483,7 +491,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple if ($this->hasOriginalCustomPrice()) { $price = (double)$this->getOriginalCustomPrice(); if ($price) { - $rate = $this->getStore()->convertPrice($price) / $price; + $rate = $this->priceCurrency->convert($price, $this->getStore()) / $price; $price = $price / $rate; } } else { @@ -529,7 +537,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple { $price = $this->_getData('original_price'); if (is_null($price)) { - $price = $this->getStore()->convertPrice($this->getBaseOriginalPrice()); + $price = $this->priceCurrency->convert($this->getBaseOriginalPrice(), $this->getStore()); $this->setData('original_price', $price); } return $price; @@ -600,7 +608,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractModel imple { $price = $this->_getData('converted_price'); if (is_null($price)) { - $price = $this->getStore()->convertPrice($this->getPrice()); + $price = $this->priceCurrency->convert($this->getPrice(), $this->getStore()); $this->setData('converted_price', $price); } return $price; diff --git a/app/code/Magento/Sales/Model/QuoteRepository.php b/app/code/Magento/Sales/Model/QuoteRepository.php index eb05fbc9e8dae64571990a9ad1d15e77da68de44..7783f27f6001d161f883b31267cde356abd11d22 100644 --- a/app/code/Magento/Sales/Model/QuoteRepository.php +++ b/app/code/Magento/Sales/Model/QuoteRepository.php @@ -50,18 +50,45 @@ class QuoteRepository } /** - * Get cart by id + * Get quote by id * * @param int $cartId * @return Quote * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function get($cartId) + { + return $this->loadQuote('load', 'cartId', $cartId); + } + + + /** + * Get quote by customer Id + * + * @param int $customerId + * @return Quote + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getForCustomer($customerId) + { + return $this->loadQuote('loadByCustomer', 'customerId', $customerId); + } + + /** + * Load quote with different methods + * + * @param string $loadMethod + * @param string $loadField + * @param int $identifier + * @return Quote + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + protected function loadQuote($loadMethod, $loadField, $identifier) { $quote = $this->quoteFactory->create(); - $quote->setStoreId($this->storeManager->getStore()->getId())->load($cartId); + $quote->setStoreId($this->storeManager->getStore()->getId())->$loadMethod($identifier); if (!$quote->getId() || !$quote->getIsActive()) { - throw NoSuchEntityException::singleField('cartId', $cartId); + throw NoSuchEntityException::singleField($loadField, $identifier); } return $quote; } diff --git a/app/code/Magento/Sales/Model/QuoteRepository/Plugin/Authorization.php b/app/code/Magento/Sales/Model/QuoteRepository/Plugin/Authorization.php new file mode 100644 index 0000000000000000000000000000000000000000..75912f1d9cbe3297c2a4a5dea7e15532f559e461 --- /dev/null +++ b/app/code/Magento/Sales/Model/QuoteRepository/Plugin/Authorization.php @@ -0,0 +1,94 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\QuoteRepository\Plugin; + +use \Magento\Authorization\Model\UserContextInterface; +use \Magento\Framework\Exception\NoSuchEntityException; + +class Authorization +{ + /** + * @var \Magento\Authorization\Model\UserContextInterface + */ + protected $userContext; + + /** + * @param \Magento\Authorization\Model\UserContextInterface $userContext + */ + public function __construct( + \Magento\Authorization\Model\UserContextInterface $userContext + ) { + $this->userContext = $userContext; + } + + /** + * Check if quote is allowed + * + * @param \Magento\Sales\Model\QuoteRepository $subject + * @param \Magento\Sales\Model\Quote $quote + * @return \Magento\Sales\Model\Quote + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function afterGet( + \Magento\Sales\Model\QuoteRepository $subject, + \Magento\Sales\Model\Quote $quote + ) { + if (!$this->isAllowed($quote)) { + throw NoSuchEntityException::singleField('cartId', $quote->getId()); + } + return $quote; + } + + /** + * Check if quote is allowed + * + * @param \Magento\Sales\Model\QuoteRepository $subject + * @param \Magento\Sales\Model\Quote $quote + * @return \Magento\Sales\Model\Quote + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function afterGetForCustomer( + \Magento\Sales\Model\QuoteRepository $subject, + \Magento\Sales\Model\Quote $quote + ) { + if (!$this->isAllowed($quote)) { + throw NoSuchEntityException::singleField('cartId', $quote->getId()); + } + return $quote; + } + + /** + * Check whether quote is allowed for current user context + * + * @param \Magento\Sales\Model\Quote $quote + * @return bool + */ + protected function isAllowed(\Magento\Sales\Model\Quote $quote) + { + return $this->userContext->getUserType() == UserContextInterface::USER_TYPE_CUSTOMER + ? $quote->getCustomerId() == $this->userContext->getUserId() + : true; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status.php b/app/code/Magento/Sales/Model/Resource/Order/Status.php index aad433b96f4bad415fd9ff6b66964b33aca81f62..b0839240f62fe44acd6750e8966b82709a24b375 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status.php @@ -25,7 +25,7 @@ namespace Magento\Sales\Model\Resource\Order; use Magento\Framework\Model\Exception; use Magento\Framework\App\Resource; -use Magento\Framework\Logger; +use Magento\Framework\Logger as LogWriter; /** * Order status resource model @@ -57,11 +57,11 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb * Class constructor * * @param \Magento\Framework\App\Resource $resource - * @param Logger $logger + * @param LogWriter $logger */ public function __construct( Resource $resource, - Logger $logger + LogWriter $logger ) { $this->logger = $logger; parent::__construct($resource); diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index e2eb6a964c7b242a9f6a3d7ebdd12c9e0b55f2a5..11a1592eeeb1587bc429a0bc688d6f45101e4d14 100644 --- a/app/code/Magento/Sales/composer.json +++ b/app/code/Magento/Sales/composer.json @@ -3,30 +3,31 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-sales-rule": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-widget": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-gift-message": "0.1.0-alpha95", - "magento/module-reports": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-wishlist": "0.1.0-alpha95", - "magento/module-email": "0.1.0-alpha95", - "magento/module-shipping": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-authorization": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-sales-rule": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-widget": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-gift-message": "0.1.0-alpha96", + "magento/module-reports": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-wishlist": "0.1.0-alpha96", + "magento/module-email": "0.1.0-alpha96", + "magento/module-shipping": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 71b2dec406eaf19ee8b99caba97d8a6fb7d9fe12..8e4b14a1f75d23a5fc11095ce378051731e8780c 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -88,6 +88,11 @@ </argument> </arguments> </type> + <type name="Magento\Sales\Model\Config\Data"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Sales\Model\Config\Reader\Proxy</argument> + </arguments> + </type> <type name="Magento\Sales\Controller\OrderInterface"> <plugin name="authentication" type="\Magento\Sales\Controller\Order\Plugin\Authentication"/> </type> diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml index 60586c7d3b538a2a103121b08ff659efd87530c1..685910b9267a9c0212732f6f815951ba9ba5dc05 100644 --- a/app/code/Magento/Sales/etc/module.xml +++ b/app/code/Magento/Sales/etc/module.xml @@ -51,6 +51,7 @@ <module name="Magento_Wishlist"/> <module name="Magento_Email"/> <module name="Magento_Shipping"/> + <module name="Magento_Authorization"/> </depends> </module> </config> diff --git a/app/code/Magento/Sales/etc/webapi_rest/di.xml b/app/code/Magento/Sales/etc/webapi_rest/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..278cf9830261bb4573047ae3eb095253a5b0ea32 --- /dev/null +++ b/app/code/Magento/Sales/etc/webapi_rest/di.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Sales\Model\QuoteRepository"> + <plugin name="authorization" type="\Magento\Sales\Model\QuoteRepository\Plugin\Authorization" /> + </type> +</config> diff --git a/app/code/Magento/Sales/etc/webapi_soap/di.xml b/app/code/Magento/Sales/etc/webapi_soap/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..278cf9830261bb4573047ae3eb095253a5b0ea32 --- /dev/null +++ b/app/code/Magento/Sales/etc/webapi_soap/di.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Sales\Model\QuoteRepository"> + <plugin name="authorization" type="\Magento\Sales\Model\QuoteRepository\Plugin\Authorization" /> + </type> +</config> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml index 92beeaf1a0686c32aa2a54d05865d59448f3ea95..2677ee2b0fea04d74978306aebd52df729196ef5 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml @@ -104,12 +104,4 @@ $_item = $this->getItem(); <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> <?php echo $this->getItemRowTotalHtml(); ?> </td> - - <?php /* if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <th class="a-right"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?></th> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <th class="a-right"><?php echo $this->getOrder()->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem())); ?></th> - <?php endif; */ ?> - </tr> diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/AbstractDiscount.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/AbstractDiscount.php index 3684703e3a3cfc59b840191ccea4a1c2c17a33a8..4228c2fcfa349f54cbcd370cb1391ff842a136a3 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/AbstractDiscount.php +++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/AbstractDiscount.php @@ -35,16 +35,24 @@ abstract class AbstractDiscount implements DiscountInterface */ protected $validator; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\SalesRule\Model\Validator $validator - * @param \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory $discountDataFactory + * @param DataFactory $discountDataFactory + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\SalesRule\Model\Validator $validator, - \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory $discountDataFactory + \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory $discountDataFactory, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency ) { $this->validator = $validator; $this->discountFactory = $discountDataFactory; + $this->priceCurrency = $priceCurrency; } /** diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/ByFixed.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/ByFixed.php index c1659e3ea0bd23cb48ff2837302a4c0776e13490..72452ef42276d537705638a63be130c220387d81 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/ByFixed.php +++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/ByFixed.php @@ -36,7 +36,7 @@ class ByFixed extends AbstractDiscount /** @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */ $discountData = $this->discountFactory->create(); - $quoteAmount = $item->getQuote()->getStore()->convertPrice($rule->getDiscountAmount()); + $quoteAmount = $this->priceCurrency->convert($rule->getDiscountAmount(), $item->getQuote()->getStore()); $discountData->setAmount($qty * $quoteAmount); $discountData->setBaseAmount($qty * $rule->getDiscountAmount()); diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/CartFixed.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/CartFixed.php index 55b0304770160c2b1e765819375c588baa45f540..1287886de23ec5b1c4b8ffa9a0f00e662694ee6b 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/CartFixed.php +++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/CartFixed.php @@ -72,25 +72,25 @@ class CartFixed extends AbstractDiscount if ($cartRules[$rule->getId()] > 0) { $store = $quote->getStore(); if ($ruleTotals['items_count'] <= 1) { - $quoteAmount = $store->convertPrice($cartRules[$rule->getId()]); + $quoteAmount = $this->priceCurrency->convert($cartRules[$rule->getId()], $store); $baseDiscountAmount = min($baseItemPrice * $qty, $cartRules[$rule->getId()]); } else { $discountRate = $baseItemPrice * $qty / $ruleTotals['base_items_price']; $maximumItemDiscount = $rule->getDiscountAmount() * $discountRate; - $quoteAmount = $store->convertPrice($maximumItemDiscount); + $quoteAmount = $this->priceCurrency->convert($maximumItemDiscount, $store); $baseDiscountAmount = min($baseItemPrice * $qty, $maximumItemDiscount); $this->validator->decrementRuleItemTotalsCount($rule->getId()); } - $baseDiscountAmount = $store->roundPrice($baseDiscountAmount); + $baseDiscountAmount = $this->priceCurrency->round($baseDiscountAmount); $cartRules[$rule->getId()] -= $baseDiscountAmount; - $discountData->setAmount($store->roundPrice(min($itemPrice * $qty, $quoteAmount))); + $discountData->setAmount($this->priceCurrency->round(min($itemPrice * $qty, $quoteAmount))); $discountData->setBaseAmount($baseDiscountAmount); $discountData->setOriginalAmount(min($itemOriginalPrice * $qty, $quoteAmount)); - $discountData->setBaseOriginalAmount($store->roundPrice($baseItemOriginalPrice)); + $discountData->setBaseOriginalAmount($this->priceCurrency->round($baseItemOriginalPrice)); } $address->setCartFixedRules($cartRules); diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/ToFixed.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/ToFixed.php index 4869bc19850bc186fb660873cca3faaf2ee5f78a..ad3c98ca5a0a086c742c159c4badcbde169bb4a0 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/ToFixed.php +++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/ToFixed.php @@ -43,7 +43,7 @@ class ToFixed extends AbstractDiscount $itemOriginalPrice = $this->validator->getItemOriginalPrice($item); $baseItemOriginalPrice = $this->validator->getItemBaseOriginalPrice($item); - $quoteAmount = $store->convertPrice($rule->getDiscountAmount()); + $quoteAmount = $this->priceCurrency->convert($rule->getDiscountAmount(), $store); $discountData->setAmount($qty * ($itemPrice - $quoteAmount)); $discountData->setBaseAmount($qty * ($baseItemPrice - $rule->getDiscountAmount())); diff --git a/app/code/Magento/SalesRule/Model/Utility.php b/app/code/Magento/SalesRule/Model/Utility.php index 341fbcf82ae1520d629eab0aa904ea6058b95fd1..02a5a5046a4c92aa20c82236e4a6bc5682acee14 100644 --- a/app/code/Magento/SalesRule/Model/Utility.php +++ b/app/code/Magento/SalesRule/Model/Utility.php @@ -24,6 +24,8 @@ namespace Magento\SalesRule\Model; +use Magento\Framework\Pricing\PriceCurrencyInterface; + /** * Class Utility * @@ -61,22 +63,30 @@ class Utility */ protected $objectFactory; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param Resource\Coupon\UsageFactory $usageFactory * @param CouponFactory $couponFactory * @param Rule\CustomerFactory $customerFactory * @param \Magento\Framework\ObjectFactory $objectFactory + * @param PriceCurrencyInterface $priceCurrency */ public function __construct ( \Magento\SalesRule\Model\Resource\Coupon\UsageFactory $usageFactory, \Magento\SalesRule\Model\CouponFactory $couponFactory, \Magento\SalesRule\Model\Rule\CustomerFactory $customerFactory, - \Magento\Framework\ObjectFactory $objectFactory + \Magento\Framework\ObjectFactory $objectFactory, + PriceCurrencyInterface $priceCurrency ) { $this->couponFactory = $couponFactory; $this->customerFactory = $customerFactory; $this->usageFactory = $usageFactory; $this->objectFactory = $objectFactory; + $this->priceCurrency = $priceCurrency; } /** @@ -207,12 +217,13 @@ class Utility $discountAmount += $delta; $baseDiscountAmount += $baseDelta; - $this->_roundingDeltas[$percentKey] = $discountAmount - $store->roundPrice($discountAmount); - $this->_baseRoundingDeltas[$percentKey] = $baseDiscountAmount - $store->roundPrice($baseDiscountAmount); + $this->_roundingDeltas[$percentKey] = $discountAmount - $this->priceCurrency->round($discountAmount); + $this->_baseRoundingDeltas[$percentKey] = $baseDiscountAmount + - $this->priceCurrency->round($baseDiscountAmount); } - $discountData->setAmount($store->roundPrice($discountAmount)); - $discountData->setBaseAmount($store->roundPrice($baseDiscountAmount)); + $discountData->setAmount($this->priceCurrency->round($discountAmount)); + $discountData->setBaseAmount($this->priceCurrency->round($baseDiscountAmount)); return $this; } diff --git a/app/code/Magento/SalesRule/Model/Validator.php b/app/code/Magento/SalesRule/Model/Validator.php index 58192b28fdc1bcd78dff0f26a2df73ff628546b2..4727977c6bbd1b0b740c1f8582c75d09e7835957 100644 --- a/app/code/Magento/SalesRule/Model/Validator.php +++ b/app/code/Magento/SalesRule/Model/Validator.php @@ -91,6 +91,11 @@ class Validator extends \Magento\Framework\Model\AbstractModel */ protected $rulesApplier; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @var Validator\Pool */ @@ -108,6 +113,7 @@ class Validator extends \Magento\Framework\Model\AbstractModel * @param \Magento\Catalog\Helper\Data $catalogData * @param Utility $utility * @param RulesApplier $rulesApplier + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param Validator\Pool $validators * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -121,6 +127,7 @@ class Validator extends \Magento\Framework\Model\AbstractModel \Magento\Catalog\Helper\Data $catalogData, \Magento\SalesRule\Model\Utility $utility, \Magento\SalesRule\Model\RulesApplier $rulesApplier, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\SalesRule\Model\Validator\Pool $validators, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -131,6 +138,7 @@ class Validator extends \Magento\Framework\Model\AbstractModel $this->_catalogData = $catalogData; $this->validatorUtility = $utility; $this->rulesApplier = $rulesApplier; + $this->priceCurrency = $priceCurrency; $this->validators = $validators; $this->messageManager = $messageManager; parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -289,12 +297,12 @@ class Validator extends \Magento\Framework\Model\AbstractModel $address->setShippingDiscountPercent($discountPercent); break; case \Magento\SalesRule\Model\Rule::TO_FIXED_ACTION: - $quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount()); + $quoteAmount = $this->priceCurrency->convert($rule->getDiscountAmount(), $quote->getStore()); $discountAmount = $shippingAmount - $quoteAmount; $baseDiscountAmount = $baseShippingAmount - $rule->getDiscountAmount(); break; case \Magento\SalesRule\Model\Rule::BY_FIXED_ACTION: - $quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount()); + $quoteAmount = $this->priceCurrency->convert($rule->getDiscountAmount(), $quote->getStore()); $discountAmount = $quoteAmount; $baseDiscountAmount = $rule->getDiscountAmount(); break; @@ -304,7 +312,7 @@ class Validator extends \Magento\Framework\Model\AbstractModel $cartRules[$rule->getId()] = $rule->getDiscountAmount(); } if ($cartRules[$rule->getId()] > 0) { - $quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]); + $quoteAmount = $this->priceCurrency->convert($cartRules[$rule->getId()], $quote->getStore()); $discountAmount = min($shippingAmount - $address->getShippingDiscountAmount(), $quoteAmount); $baseDiscountAmount = min( $baseShippingAmount - $address->getBaseShippingDiscountAmount(), diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index 1617a87e5c922036e8e76f464a0a2878166c7318..3b59c828b0b60c5c21143a93f583b0195b046f6b 100644 --- a/app/code/Magento/SalesRule/composer.json +++ b/app/code/Magento/SalesRule/composer.json @@ -3,26 +3,26 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-rule": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-shipping": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-reports": "0.1.0-alpha95", - "magento/module-catalog-rule": "0.1.0-alpha95", - "magento/module-widget": "0.1.0-alpha95", - "magento/module-cron": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-rule": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-shipping": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-reports": "0.1.0-alpha96", + "magento/module-catalog-rule": "0.1.0-alpha96", + "magento/module-widget": "0.1.0-alpha96", + "magento/module-cron": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index 8d37dfba3c1b2340a2e150778bbb34d39dc187a1..8cf61460aab4528485d3809f806fde9e534cc917 100644 --- a/app/code/Magento/Sendfriend/composer.json +++ b/app/code/Magento/Sendfriend/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Shipping/Model/Rate/Result.php b/app/code/Magento/Shipping/Model/Rate/Result.php index e90993ec3ecc957d833e24bb0de012f0be6fbc98..6856cfdc707a4fb8d2c6f3d4258a07beb76f5931 100644 --- a/app/code/Magento/Shipping/Model/Rate/Result.php +++ b/app/code/Magento/Shipping/Model/Rate/Result.php @@ -151,7 +151,20 @@ class Result */ public function asArray() { - $currencyFilter = $this->_storeManager->getStore()->getPriceFilter(); + if ($this->_storeManager->getStore()->getBaseCurrency() + && $this->_storeManager->getStore()->getCurrentCurrency() + ) { + $currencyFilter = $this->_storeManager->getStore()->getCurrentCurrency()->getFilter(); + $currencyFilter->setRate( + $this->_storeManager->getStore()->getBaseCurrency()->getRate( + $this->_storeManager->getStore()->getCurrentCurrency() + ) + ); + } elseif ($this->_storeManager->getStore()->getDefaultCurrency()) { + $currencyFilter = $this->_storeManager->getStore()->getDefaultCurrency()->getFilter(); + } else { + $currencyFilter = new \Magento\Framework\Filter\Sprintf('%s', 2); + } $rates = array(); $allRates = $this->getAllRates(); foreach ($allRates as $rate) { diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 24b19f4e421fb73efdfc3c72a1a6c280cc5a16e9..c5b41daf74231c034f21a2daf9efc12e29ffadf3 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-contact": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-payment": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-contact": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-payment": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 4e6ebf4ade31b9f3d873166334ac7e447ff67f46..dd6a0d896461c4c30422ff54048de331ffcfa31b 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/Model/Group.php b/app/code/Magento/Store/Model/Group.php index 9972fec515f6e5eb3df72cdc605b759d57e4eebc..f0e625fa8ab942ea7befb2a8166a6f66eebf8441 100644 --- a/app/code/Magento/Store/Model/Group.php +++ b/app/code/Magento/Store/Model/Group.php @@ -106,7 +106,7 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F /** * @var \Magento\Store\Model\Store */ - protected $_store; + protected $_storeListFactory; /** * @var \Magento\Framework\StoreManagerInterface @@ -127,14 +127,14 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Core\Model\Resource\Config\Data $configDataResource, - \Magento\Store\Model\Store $store, + \Magento\Store\Model\Resource\Store\CollectionFactory $storeListFactory, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->_configDataResource = $configDataResource; - $this->_store = $store; + $this->_storeListFactory = $storeListFactory; $this->_storeManager = $storeManager; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -197,7 +197,7 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F */ public function getStoreCollection() { - return $this->_store->getCollection()->addGroupFilter($this->getId()); + return $this->_storeListFactory->create()->addGroupFilter($this->getId()); } /** diff --git a/app/code/Magento/Store/Model/StorageFactory.php b/app/code/Magento/Store/Model/StorageFactory.php index 35e6b1331d78a47efa6f40dc3ec44e5ddd9829e9..200629e0aac06b367deb13e638ef5ab76634e2f3 100644 --- a/app/code/Magento/Store/Model/StorageFactory.php +++ b/app/code/Magento/Store/Model/StorageFactory.php @@ -24,8 +24,6 @@ namespace Magento\Store\Model; use Magento\Framework\Profiler; -use Magento\Store\Model\Store; -use Magento\Framework\StoreManagerInterface; class StorageFactory { diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index 8bba65ab3f4ec9ee8053aebcf60a210c7efcf2f5..9d10c2a019cf4d6eebd4b36c997db7afabf983fd 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -954,74 +954,6 @@ class Store extends AbstractModel implements return $this->getBaseCurrency()->getRate($this->getCurrentCurrency()); } - /** - * Convert price from default currency to current currency - * - * @param float $price - * @param bool $format Format price to currency format - * @param bool $includeContainer Enclose into <span class="price"><span> - * @return float - */ - public function convertPrice($price, $format = false, $includeContainer = true) - { - if ($this->getCurrentCurrency() && $this->getBaseCurrency()) { - $value = $this->getBaseCurrency()->convert($price, $this->getCurrentCurrency()); - } else { - $value = $price; - } - - if ($this->getCurrentCurrency() && $format) { - $value = $this->formatPrice($value, $includeContainer); - } - return $value; - } - - /** - * Round price - * - * @param float $price - * @return float - */ - public function roundPrice($price) - { - return round($price, 2); - } - - /** - * Format price with currency filter (taking rate into consideration) - * - * @param float $price - * @param bool $includeContainer - * @return string - */ - public function formatPrice($price, $includeContainer = true) - { - if ($this->getCurrentCurrency()) { - return $this->getCurrentCurrency()->format($price, array(), $includeContainer); - } - return $price; - } - - /** - * Get store price filter - * - * @return Filter|\Magento\Framework\Filter\Sprintf - */ - public function getPriceFilter() - { - if (!$this->_priceFilter) { - if ($this->getBaseCurrency() && $this->getCurrentCurrency()) { - $this->_priceFilter = $this->getCurrentCurrency()->getFilter(); - $this->_priceFilter->setRate($this->getBaseCurrency()->getRate($this->getCurrentCurrency())); - } elseif ($this->getDefaultCurrency()) { - $this->_priceFilter = $this->getDefaultCurrency()->getFilter(); - } else { - $this->_priceFilter = new \Magento\Framework\Filter\Sprintf('%s', 2); - } - } - return $this->_priceFilter; - } - /** * Retrieve root category identifier * diff --git a/app/code/Magento/Store/Model/StoresConfig.php b/app/code/Magento/Store/Model/StoresConfig.php index 57936d4cceffd5f5ea56aecf81cbd6d05968a4e3..22b34528a1b01b9742b566b650183550bdb94dd6 100644 --- a/app/code/Magento/Store/Model/StoresConfig.php +++ b/app/code/Magento/Store/Model/StoresConfig.php @@ -25,7 +25,6 @@ namespace Magento\Store\Model; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\StoreManagerInterface; class StoresConfig { diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index 193b79e5e6b6103bc4de36d16a9f4c1144857a17..0e66134e8ad7638fa1bc001b87b1f5ec84bdf901 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-index": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-index": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index 97cd42b2070d5a1cf861d45066ad5b482213330b..bf31fba8752ece47964cda7b5705e1cded51e1bb 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -31,6 +31,11 @@ </argument> </arguments> </type> + <type name="Magento\Framework\App\Config\ScopePool"> + <arguments> + <argument name="readerPool" xsi:type="object">Magento\Store\Model\Config\Reader\ReaderPool\Proxy</argument> + </arguments> + </type> <type name="Magento\Store\Model\Config\Reader\Website"> <arguments> <argument name="scopePool" xsi:type="object">Magento\Framework\App\Config\ScopePool\Proxy</argument> diff --git a/app/code/Magento/Tax/Block/Checkout/Shipping/Price.php b/app/code/Magento/Tax/Block/Checkout/Shipping/Price.php index 10d61a940b67eb69ce5bcf42c6f1d6ec152fb48c..aa3985569f2a00827a537ee2d9d84d7f11d07c0d 100644 --- a/app/code/Magento/Tax/Block/Checkout/Shipping/Price.php +++ b/app/code/Magento/Tax/Block/Checkout/Shipping/Price.php @@ -23,8 +23,7 @@ */ namespace Magento\Tax\Block\Checkout\Shipping; -use Magento\Sales\Model\Quote\Address\Rate; -use Magento\Checkout\Block\Cart\AbstractCart; +use Magento\Framework\Pricing\PriceCurrencyInterface; class Price extends \Magento\Checkout\Block\Shipping\Price { @@ -38,6 +37,7 @@ class Price extends \Magento\Checkout\Block\Shipping\Price * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Checkout\Model\Session $checkoutSession + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Tax\Helper\Data $taxHelper * @param array $data */ @@ -46,6 +46,7 @@ class Price extends \Magento\Checkout\Block\Shipping\Price \Magento\Catalog\Helper\Data $catalogData, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, + PriceCurrencyInterface $priceCurrency, \Magento\Tax\Helper\Data $taxHelper, array $data = array() ) { @@ -55,6 +56,7 @@ class Price extends \Magento\Checkout\Block\Shipping\Price $catalogData, $customerSession, $checkoutSession, + $priceCurrency, $data ); } @@ -74,7 +76,12 @@ class Price extends \Magento\Checkout\Block\Shipping\Price $this->getQuote()->getCustomerTaxClassId() ); - return $this->getQuote()->getStore()->convertPrice($price, true); + return $this->priceCurrency->convertAndFormat( + $price, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $this->getQuote()->getStore() + ); } /** diff --git a/app/code/Magento/Tax/Block/Item/Price/Renderer.php b/app/code/Magento/Tax/Block/Item/Price/Renderer.php index 1fb40e7d982da65c8d6a04ac1fc6bebbb8dde7b7..10543ff3a44b56dc1caff9fe58035957d4ca047c 100644 --- a/app/code/Magento/Tax/Block/Item/Price/Renderer.php +++ b/app/code/Magento/Tax/Block/Item/Price/Renderer.php @@ -23,6 +23,7 @@ */ namespace Magento\Tax\Block\Item\Price; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Tax\Helper\Data as TaxHelper; use Magento\Framework\View\Element\Template\Context; use Magento\Framework\Object as MagentoObject; @@ -62,17 +63,23 @@ class Renderer extends \Magento\Framework\View\Element\Template protected $zone = null; /** - * Constructor - * + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** * @param Context $context * @param TaxHelper $taxHelper + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( Context $context, TaxHelper $taxHelper, + PriceCurrencyInterface $priceCurrency, array $data = array() ) { + $this->priceCurrency = $priceCurrency; $this->taxHelper = $taxHelper; if (isset($data['zone'])) { $this->zone = $data['zone']; @@ -196,7 +203,12 @@ class Renderer extends \Magento\Framework\View\Element\Template { $item = $this->getItem(); if ($item instanceof QuoteItem) { - return $item->getStore()->formatPrice($price); + return $this->priceCurrency->format( + $price, + true, + PriceCurrencyInterface::DEFAULT_PRECISION, + $item->getStore() + ); } elseif ($item instanceof OrderItem) { return $item->getOrder()->formatPrice($price); } else { diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php index dfa139f1b814d5d8bdfffed705e7a4766539aaa6..748cc3ed8d462087cad17f2c0d4c9d32bed1c705 100644 --- a/app/code/Magento/Tax/Helper/Data.php +++ b/app/code/Magento/Tax/Helper/Data.php @@ -23,12 +23,12 @@ */ namespace Magento\Tax\Helper; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Store\Model\Store; use Magento\Customer\Model\Address; use Magento\Tax\Model\Config; use Magento\Tax\Service\V1\Data\QuoteDetailsBuilder; use Magento\Tax\Service\V1\Data\QuoteDetails\ItemBuilder as QuoteDetailsItemBuilder; -use Magento\Tax\Service\V1\Data\TaxClassKey; use Magento\Tax\Service\V1\Data\TaxClassKeyBuilder; use Magento\Tax\Service\V1\TaxCalculationServiceInterface; use Magento\Customer\Model\Address\Converter as AddressConverter; @@ -166,6 +166,12 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @var \Magento\Tax\Service\V1\OrderTaxServiceInterface */ protected $orderTaxService; + + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Core\Helper\Data $coreData @@ -186,6 +192,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param AddressConverter $addressConverter * @param \Magento\Catalog\Helper\Data $catalogHelper * @param OrderTaxServiceInterface $orderTaxService + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( \Magento\Framework\App\Helper\Context $context, @@ -206,9 +213,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper CustomerSession $customerSession, AddressConverter $addressConverter, \Magento\Catalog\Helper\Data $catalogHelper, - OrderTaxServiceInterface $orderTaxService + OrderTaxServiceInterface $orderTaxService, + PriceCurrencyInterface $priceCurrency ) { parent::__construct($context); + $this->priceCurrency = $priceCurrency; $this->_scopeConfig = $scopeConfig; $this->_config = $taxConfig; $this->_coreData = $coreData; @@ -265,7 +274,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper { try { $value = $product->getPrice(); - $value = $this->_storeManager->getStore()->convertPrice($value, $format); + $value = $format ? $this->priceCurrency->convertAndFormat($value) : $this->priceCurrency->convert($value); } catch (\Exception $e) { $value = $e->getMessage(); } @@ -707,7 +716,6 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * $index => array( * 'tax_amount' => $taxAmount, * 'base_tax_amount' => $baseTaxAmount, - * 'hidden_tax_amount' => $hiddenTaxAmount, * 'title' => $title, * 'percent' => $percent * ) @@ -740,13 +748,24 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper } } else { $orderTaxDetails = $this->orderTaxService->getOrderTaxDetails($source->getId()); - // Calculate taxes for shipping + + // Apply any taxes for shipping $shippingTaxAmount = $current->getShippingTaxAmount(); - if ($shippingTaxAmount) { - $shippingTax = $this->getShippingTax($current); - $taxClassAmount = array_merge($taxClassAmount, $shippingTax); + $originalShippingTaxAmount = $source->getShippingTaxAmount(); + if ($shippingTaxAmount && $originalShippingTaxAmount && + $shippingTaxAmount != 0 && $originalShippingTaxAmount != 0) { + //An invoice or credit memo can have a different qty than its order + $shippingRatio = $shippingTaxAmount / $originalShippingTaxAmount; + $itemTaxDetails = $orderTaxDetails->getItems(); + foreach ($itemTaxDetails as $itemTaxDetail) { + //Aggregate taxable items associated with shipping + if ($itemTaxDetail->getType() == \Magento\Sales\Model\Quote\Address::TYPE_SHIPPING) { + $taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio); + } + } } + // Apply any taxes for the items /** @var $item \Magento\Sales\Model\Order\Invoice\Item|\Magento\Sales\Model\Order\Creditmemo\Item */ foreach ($current->getItemsCollection() as $item) { $orderItem = $item->getOrderItem(); @@ -756,39 +775,26 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper if (!$itemTax || !$orderItemTax) { continue; } - //In the case that invoiced item or creditmemo item qty is different from order item qty - $ratio = $itemTax / $orderItemTax; + //An invoiced item or credit memo item can have a different qty than its order item qty + $itemRatio = $itemTax / $orderItemTax; $itemTaxDetails = $orderTaxDetails->getItems(); foreach ($itemTaxDetails as $itemTaxDetail) { //Aggregate taxable items associated with an item if ($itemTaxDetail->getItemId() == $orderItemId || $itemTaxDetail->getAssociatedItemId() == $orderItemId) { - $itemAppliedTaxes = $itemTaxDetail->getAppliedTaxes(); - foreach ($itemAppliedTaxes as $itemAppliedTax) { - $taxCode = $itemAppliedTax->getCode(); - if (!isset($taxClassAmount[$taxCode])) { - $taxClassAmount[$taxCode]['title'] = $itemAppliedTax->getTitle(); - $taxClassAmount[$taxCode]['percent'] = $itemAppliedTax->getPercent(); - $taxClassAmount[$taxCode]['tax_amount'] = $itemAppliedTax->getAmount() * $ratio; - $taxClassAmount[$taxCode]['base_tax_amount'] = - $itemAppliedTax->getBaseAmount() * $ratio; - } else { - $taxClassAmount[$taxCode]['tax_amount'] += $itemAppliedTax->getAmount() * $ratio; - $taxClassAmount[$taxCode]['base_tax_amount'] += - $itemAppliedTax->getBaseAmount() * $ratio; - } - } + $taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $itemRatio); } } } } + // Finish foreach ($taxClassAmount as $key => $tax) { if ($tax['tax_amount'] == 0 && $tax['base_tax_amount'] == 0) { unset($taxClassAmount[$key]); } else { - $taxClassAmount[$key]['tax_amount'] = $source->getStore()->roundPrice($tax['tax_amount']); - $taxClassAmount[$key]['base_tax_amount'] = $source->getStore()->roundPrice($tax['base_tax_amount']); + $taxClassAmount[$key]['tax_amount'] = $this->priceCurrency->round($tax['tax_amount']); + $taxClassAmount[$key]['base_tax_amount'] = $this->priceCurrency->round($tax['base_tax_amount']); } } @@ -799,58 +805,52 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper } /** - * Returns the array of tax rates for the order + * Accumulates the pre-calculated taxes for each tax class * - * @param \Magento\Sales\Model\Order $order - * @return array - */ - protected function _getTaxRateSubtotals($order) - { - return $this->_orderTaxCollectionFactory->create()->loadByOrder($order)->toArray(); - } - - /** - * Get calculated Shipping & Handling Tax - * - * This method returns array with format: + * This method accepts and returns the 'taxClassAmount' array with format: * array( * $index => array( * 'tax_amount' => $taxAmount, * 'base_tax_amount' => $baseTaxAmount, - * 'hidden_tax_amount' => $hiddenTaxAmount - * 'title' => $title + * 'title' => $title, * 'percent' => $percent * ) * ) * - * @param \Magento\Sales\Model\Order $source + * @param array $taxClassAmount + * @param array $itemTaxDetail + * @param float $ratio * @return array */ - public function getShippingTax($source) + private function _aggregateTaxes($taxClassAmount, $itemTaxDetail, $ratio) { - if ($this->_coreRegistry->registry('current_invoice')) { - $current = $this->_coreRegistry->registry('current_invoice'); - } elseif ($this->_coreRegistry->registry('current_creditmemo')) { - $current = $this->_coreRegistry->registry('current_creditmemo'); - } else { - $current = $source; - } - - $taxClassAmount = array(); - if ($current && $source) { - if ($current->getShippingTaxAmount() != 0 && $current->getBaseShippingTaxAmount() != 0) { - $taxClassAmount[0]['tax_amount'] = $current->getShippingTaxAmount(); - $taxClassAmount[0]['base_tax_amount'] = $current->getBaseShippingTaxAmount(); - if ($current->getShippingHiddenTaxAmount() > 0) { - $taxClassAmount[0]['hidden_tax_amount'] = $current->getShippingHiddenTaxAmount(); - } - $taxClassAmount[0]['title'] = __('Shipping & Handling Tax'); - $taxClassAmount[0]['percent'] = null; + $itemAppliedTaxes = $itemTaxDetail->getAppliedTaxes(); + foreach ($itemAppliedTaxes as $itemAppliedTax) { + $taxCode = $itemAppliedTax->getCode(); + if (!isset($taxClassAmount[$taxCode])) { + $taxClassAmount[$taxCode]['title'] = $itemAppliedTax->getTitle(); + $taxClassAmount[$taxCode]['percent'] = $itemAppliedTax->getPercent(); + $taxClassAmount[$taxCode]['tax_amount'] = $itemAppliedTax->getAmount() * $ratio; + $taxClassAmount[$taxCode]['base_tax_amount'] = $itemAppliedTax->getBaseAmount() * $ratio; + } else { + $taxClassAmount[$taxCode]['tax_amount'] += $itemAppliedTax->getAmount() * $ratio; + $taxClassAmount[$taxCode]['base_tax_amount'] += $itemAppliedTax->getBaseAmount() * $ratio; } } return $taxClassAmount; } + /** + * Returns the array of tax rates for the order + * + * @param \Magento\Sales\Model\Order $order + * @return array + */ + protected function _getTaxRateSubtotals($order) + { + return $this->_orderTaxCollectionFactory->create()->loadByOrder($order)->toArray(); + } + /** * Retrieve default customer tax class from config * diff --git a/app/code/Magento/Tax/Model/Calculation.php b/app/code/Magento/Tax/Model/Calculation.php index 1f60094b60970ba37364995ca008db4fac54f880..860e2b4a1c265ebb9f3bf426f296db5025b5f0f5 100644 --- a/app/code/Magento/Tax/Model/Calculation.php +++ b/app/code/Magento/Tax/Model/Calculation.php @@ -23,6 +23,7 @@ */ namespace Magento\Tax\Model; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Store\Model\Store; use Magento\Customer\Service\V1\Data\Customer as CustomerDataObject; use Magento\Customer\Service\V1\Data\CustomerBuilder; @@ -169,6 +170,11 @@ class Calculation extends \Magento\Framework\Model\AbstractModel */ protected $customerBuilder; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -177,15 +183,15 @@ class Calculation extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\CustomerFactory $customerFactory - * @param \Magento\Tax\Model\Resource\TaxClass\CollectionFactory $classesFactory - * @param \Magento\Tax\Model\Resource\Calculation $resource + * @param Resource\TaxClass\CollectionFactory $classesFactory + * @param Resource\Calculation $resource * @param AddressServiceInterface $addressService * @param GroupServiceInterface $groupService * @param CustomerAccountServiceInterface $customerAccount * @param CustomerBuilder $customerBuilder + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data - * @internal param \Magento\Customer\Model\Converter $converter */ public function __construct( \Magento\Framework\Model\Context $context, @@ -201,6 +207,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel GroupServiceInterface $groupService, CustomerAccountServiceInterface $customerAccount, CustomerBuilder $customerBuilder, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -214,6 +221,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel $this->_groupService = $groupService; $this->customerAccountService = $customerAccount; $this->customerBuilder = $customerBuilder; + $this->priceCurrency = $priceCurrency; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -262,7 +270,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel public function getRates($ruleId) { if (!isset($this->_rates[$ruleId])) { - $this->_rates[$ruleId] = $this->_getResource()->getDistinct('tax_calculation_rate_id', $ruleId); + $this->_rates[$ruleId] = $this->_getResource()->getCalculationsById('tax_calculation_rate_id', $ruleId); } return $this->_rates[$ruleId]; } @@ -276,7 +284,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel public function getCustomerTaxClasses($ruleId) { if (!isset($this->_ctc[$ruleId])) { - $this->_ctc[$ruleId] = $this->_getResource()->getDistinct('customer_tax_class_id', $ruleId); + $this->_ctc[$ruleId] = $this->_getResource()->getCalculationsById('customer_tax_class_id', $ruleId); } return $this->_ctc[$ruleId]; } @@ -290,7 +298,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel public function getProductTaxClasses($ruleId) { if (!isset($this->_ptc[$ruleId])) { - $this->_ptc[$ruleId] = $this->getResource()->getDistinct('product_tax_class_id', $ruleId); + $this->_ptc[$ruleId] = $this->getResource()->getCalculationsById('product_tax_class_id', $ruleId); } return $this->_ptc[$ruleId]; } @@ -743,7 +751,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel */ public function round($price) { - return $this->_storeManager->getStore()->roundPrice($price); + return $this->priceCurrency->round($price); } /** diff --git a/app/code/Magento/Tax/Model/Resource/Calculation.php b/app/code/Magento/Tax/Model/Resource/Calculation.php index 3dc1a5b623f8047e8db00f7e97d43ee5a386c845..1796f9130fb652b9f3c91f4345b878fbca85eae4 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation.php @@ -108,7 +108,7 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param int $ruleId * @return array */ - public function getDistinct($field, $ruleId) + public function getCalculationsById($field, $ruleId) { $select = $this->_getReadAdapter()->select(); $select->from($this->getMainTable(), $field)->where('tax_calculation_rule_id = ?', (int)$ruleId); diff --git a/app/code/Magento/Tax/Pricing/Adjustment.php b/app/code/Magento/Tax/Pricing/Adjustment.php index 4e33842f8f8fdc56bf03dd086260fb65ae02678c..b8d02cef576a7f2600b9a9dd98879e52be6b6f15 100644 --- a/app/code/Magento/Tax/Pricing/Adjustment.php +++ b/app/code/Magento/Tax/Pricing/Adjustment.php @@ -102,9 +102,10 @@ class Adjustment implements AdjustmentInterface * * @param float $amount * @param SaleableInterface $saleableItem + * @param null|array $context * @return float */ - public function extractAdjustment($amount, SaleableInterface $saleableItem) + public function extractAdjustment($amount, SaleableInterface $saleableItem, $context = []) { if ($this->taxHelper->priceIncludesTax()) { $adjustedAmount = $this->catalogHelper->getTaxPrice( @@ -130,9 +131,10 @@ class Adjustment implements AdjustmentInterface * * @param float $amount * @param SaleableInterface $saleableItem + * @param null|array $context * @return float */ - public function applyAdjustment($amount, SaleableInterface $saleableItem) + public function applyAdjustment($amount, SaleableInterface $saleableItem, $context = []) { return $this->catalogHelper->getTaxPrice( $saleableItem, diff --git a/app/code/Magento/Tax/Service/V1/Data/QuoteDetails.php b/app/code/Magento/Tax/Service/V1/Data/QuoteDetails.php index 0bf6706d9f8f125b36d68b6ab91f4b977979ec9e..960ef5d5f4f924bc5132f24781a39c95ee47b9b7 100644 --- a/app/code/Magento/Tax/Service/V1/Data/QuoteDetails.php +++ b/app/code/Magento/Tax/Service/V1/Data/QuoteDetails.php @@ -37,6 +37,8 @@ class QuoteDetails extends \Magento\Framework\Service\Data\AbstractExtensibleObj const KEY_ITEMS = 'items'; + const CUSTOMER_TAX_CLASS_ID = 'customer_tax_class_id'; + const KEY_CUSTOMER_ID = 'customer_id'; /**#@-*/ @@ -89,4 +91,14 @@ class QuoteDetails extends \Magento\Framework\Service\Data\AbstractExtensibleObj { return $this->_get(self::KEY_ITEMS); } + + /** + * Get customer tax class id + * + * @return int + */ + public function getCustomerTaxClassId() + { + return $this->_get(self::CUSTOMER_TAX_CLASS_ID); + } } diff --git a/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/Item.php b/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/Item.php index 1e6d3919a4b9ea264656d5c0fba434e6d477cce3..79ef1884876d39f7ba76b4da85c410387e7db685 100644 --- a/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/Item.php +++ b/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/Item.php @@ -47,6 +47,8 @@ class Item extends \Magento\Framework\Service\Data\AbstractExtensibleObject const KEY_PARENT_CODE = 'parent_code'; const KEY_ASSOCIATED_ITEM_CODE = 'association_code'; + + const KEY_TAX_CLASS_ID = 'tax_class_id'; /**#@-*/ /** @@ -148,4 +150,14 @@ class Item extends \Magento\Framework\Service\Data\AbstractExtensibleObject { return $this->_get(self::KEY_ASSOCIATED_ITEM_CODE); } + + /** + * Get associated item tax class id + * + * @return int + */ + public function getTaxClassId() + { + return $this->_get(self::KEY_TAX_CLASS_ID); + } } diff --git a/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilder.php b/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilder.php index 97951d0dc3d568ded74149ec3cf8f815c9ceec59..b74b0d23e660bc072f6cd7f0f8f3da3eea8631cc 100644 --- a/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilder.php @@ -178,6 +178,17 @@ class ItemBuilder extends \Magento\Framework\Service\Data\AbstractExtensibleObje return $this->_set(Item::KEY_ASSOCIATED_ITEM_CODE, $code); } + /** + * Set tax class id + * + * @param string $code + * @return $this + */ + public function setTaxClassId($code) + { + return $this->_set(Item::KEY_TAX_CLASS_ID, $code); + } + /** * {@inheritdoc} */ diff --git a/app/code/Magento/Tax/Service/V1/Data/QuoteDetailsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/QuoteDetailsBuilder.php index 5cae3d953ddb53c66b46af1cb3c99c6f5cd602d6..d571b054b23d906eb7adc2e41208be2856aa8831 100644 --- a/app/code/Magento/Tax/Service/V1/Data/QuoteDetailsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/QuoteDetailsBuilder.php @@ -163,6 +163,17 @@ class QuoteDetailsBuilder extends \Magento\Framework\Service\Data\AbstractExtens return $this->_set(QuoteDetails::KEY_ITEMS, $items); } + /** + * Set quote items + * + * @param int $customerTaxClassId + * @return $this + */ + public function setCustomerTaxClassId($customerTaxClassId) + { + return $this->_set(QuoteDetails::CUSTOMER_TAX_CLASS_ID, $customerTaxClassId); + } + /** * {@inheritdoc} */ diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index 30d2337fc427c492abd412d80223282a49f1ed6b..4930e4c42627450b0c8935348ae23f9f5203edba 100644 --- a/app/code/Magento/Tax/composer.json +++ b/app/code/Magento/Tax/composer.json @@ -3,24 +3,24 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-shipping": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-reports": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-configurable-product": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-shipping": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-reports": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-configurable-product": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Tax/etc/di.xml b/app/code/Magento/Tax/etc/di.xml index 1a0424d10910a8ea9a9d835561996679eacb978c..d62021e65aff6ed7f19292f7b07c86d07b9202db 100644 --- a/app/code/Magento/Tax/etc/di.xml +++ b/app/code/Magento/Tax/etc/di.xml @@ -49,6 +49,13 @@ <argument name="taxData" xsi:type="object">Magento\Tax\Helper\Data\Proxy</argument> </arguments> </type> + <type name="Magento\Framework\Pricing\Adjustment\Collection"> + <arguments> + <argument name="adjustments" xsi:type="array"> + <item name="tax" xsi:type="const">Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE</item> + </argument> + </arguments> + </type> <type name="Magento\Framework\Pricing\Adjustment\Pool"> <arguments> <argument name="adjustments" xsi:type="array"> diff --git a/app/code/Magento/Tax/i18n/de_DE.csv b/app/code/Magento/Tax/i18n/de_DE.csv index e324e119a78f0eac61bbce517a86289682524583..2365399967075268f0f0216770da3295cb27bba0 100644 --- a/app/code/Magento/Tax/i18n/de_DE.csv +++ b/app/code/Magento/Tax/i18n/de_DE.csv @@ -84,7 +84,6 @@ State,Staat "Something went wrong deleting this tax rule.","Something went wrong deleting this tax rule." "Something went wrong saving this tax class.","Something went wrong saving this tax class." "Something went wrong deleting this tax class.","Something went wrong deleting this tax class." -"Shipping & Handling Tax","Versandkosten & Steuern" "Please fill all required fields with valid information.","Please fill all required fields with valid information." "Rate Percent should be a positive number.","Rate Percent should be a positive number." "Maximum zip code length is 9.","Maximum zip code length is 9." diff --git a/app/code/Magento/Tax/i18n/en_US.csv b/app/code/Magento/Tax/i18n/en_US.csv index e12e254b924ba835c1caa9f4cb4264bbdf4e6cbd..078cef5d97b22d509be9cefcd6ded7e3abd56629 100644 --- a/app/code/Magento/Tax/i18n/en_US.csv +++ b/app/code/Magento/Tax/i18n/en_US.csv @@ -84,7 +84,6 @@ State,State "Something went wrong deleting this tax rule.","Something went wrong deleting this tax rule." "Something went wrong saving this tax class.","Something went wrong saving this tax class." "Something went wrong deleting this tax class.","Something went wrong deleting this tax class." -"Shipping & Handling Tax","Shipping & Handling Tax" "Please fill all required fields with valid information.","Please fill all required fields with valid information." "Rate Percent should be a positive number.","Rate Percent should be a positive number." "Maximum zip code length is 9.","Maximum zip code length is 9." diff --git a/app/code/Magento/Tax/i18n/es_ES.csv b/app/code/Magento/Tax/i18n/es_ES.csv index 723c15cf6a26a2bada545ddc8187105fec711871..999f3930c262c6cad3e89e6d12601d8e18bbe016 100644 --- a/app/code/Magento/Tax/i18n/es_ES.csv +++ b/app/code/Magento/Tax/i18n/es_ES.csv @@ -84,7 +84,6 @@ State,Estado "Something went wrong deleting this tax rule.","Something went wrong deleting this tax rule." "Something went wrong saving this tax class.","Something went wrong saving this tax class." "Something went wrong deleting this tax class.","Something went wrong deleting this tax class." -"Shipping & Handling Tax","Impuestos de envÃo y manipulación" "Please fill all required fields with valid information.","Please fill all required fields with valid information." "Rate Percent should be a positive number.","Rate Percent should be a positive number." "Maximum zip code length is 9.","Maximum zip code length is 9." diff --git a/app/code/Magento/Tax/i18n/fr_FR.csv b/app/code/Magento/Tax/i18n/fr_FR.csv index f07a4884506f9500cb1c449a14ee1f9d9144e0ba..bf297e3d67360cb1c8bd3c8242e46fe96fbc7fb7 100644 --- a/app/code/Magento/Tax/i18n/fr_FR.csv +++ b/app/code/Magento/Tax/i18n/fr_FR.csv @@ -84,7 +84,6 @@ State,État "Something went wrong deleting this tax rule.","Something went wrong deleting this tax rule." "Something went wrong saving this tax class.","Something went wrong saving this tax class." "Something went wrong deleting this tax class.","Something went wrong deleting this tax class." -"Shipping & Handling Tax","Expédition & Frais de traitement" "Please fill all required fields with valid information.","Please fill all required fields with valid information." "Rate Percent should be a positive number.","Rate Percent should be a positive number." "Maximum zip code length is 9.","Maximum zip code length is 9." diff --git a/app/code/Magento/Tax/i18n/nl_NL.csv b/app/code/Magento/Tax/i18n/nl_NL.csv index dc5ec7e7ccf1410cba8ae4088cd6086806101616..ac644e6510cc1478a1b7a9b1b6a780e80cf8888c 100644 --- a/app/code/Magento/Tax/i18n/nl_NL.csv +++ b/app/code/Magento/Tax/i18n/nl_NL.csv @@ -84,7 +84,6 @@ State,Provincie "Something went wrong deleting this tax rule.","Something went wrong deleting this tax rule." "Something went wrong saving this tax class.","Something went wrong saving this tax class." "Something went wrong deleting this tax class.","Something went wrong deleting this tax class." -"Shipping & Handling Tax","Verzending - en verwerkingstax" "Please fill all required fields with valid information.","Please fill all required fields with valid information." "Rate Percent should be a positive number.","Rate Percent should be a positive number." "Maximum zip code length is 9.","Maximum zip code length is 9." diff --git a/app/code/Magento/Tax/i18n/pt_BR.csv b/app/code/Magento/Tax/i18n/pt_BR.csv index f1955d8bfca35ca1b29924503b04fdd84c9db905..2c52eee8e592aaebe71c3cfc598032cf2257c7e1 100644 --- a/app/code/Magento/Tax/i18n/pt_BR.csv +++ b/app/code/Magento/Tax/i18n/pt_BR.csv @@ -84,7 +84,6 @@ State,Estado "Something went wrong deleting this tax rule.","Something went wrong deleting this tax rule." "Something went wrong saving this tax class.","Something went wrong saving this tax class." "Something went wrong deleting this tax class.","Something went wrong deleting this tax class." -"Shipping & Handling Tax","Taxa de Envio & Manuseio" "Please fill all required fields with valid information.","Please fill all required fields with valid information." "Rate Percent should be a positive number.","Rate Percent should be a positive number." "Maximum zip code length is 9.","Maximum zip code length is 9." diff --git a/app/code/Magento/Tax/i18n/zh_CN.csv b/app/code/Magento/Tax/i18n/zh_CN.csv index 4952571d102d65ed899e3c7bcd693960ccc3eb36..d47d26b939bd199abc6c46c2e69e7dad6edaff95 100644 --- a/app/code/Magento/Tax/i18n/zh_CN.csv +++ b/app/code/Magento/Tax/i18n/zh_CN.csv @@ -84,7 +84,6 @@ State,å·ž "Something went wrong deleting this tax rule.","Something went wrong deleting this tax rule." "Something went wrong saving this tax class.","Something went wrong saving this tax class." "Something went wrong deleting this tax class.","Something went wrong deleting this tax class." -"Shipping & Handling Tax",处ç†ã€è¿é€åŠç¨Žé‡‘费用 "Please fill all required fields with valid information.","Please fill all required fields with valid information." "Rate Percent should be a positive number.","Rate Percent should be a positive number." "Maximum zip code length is 9.","Maximum zip code length is 9." diff --git a/app/code/Magento/TaxImportExport/composer.json b/app/code/Magento/TaxImportExport/composer.json index 3beada316bd4eb845f7ca5f5b708ec141e46db73..26f2e3476ae739723e56e11e89c118448046feb8 100644 --- a/app/code/Magento/TaxImportExport/composer.json +++ b/app/code/Magento/TaxImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-store": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-store": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 9c1cd7028adbe867f8e748efe7d253decb7860c3..7df27d08ce936ed02ae97e6a59f434dd7fc0edaf 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-translation": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-translation": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Theme/etc/di.xml b/app/code/Magento/Theme/etc/di.xml index ef96fbd1caf631259dc112b48ec7b20707c82374..8d9285d8e08cbbde365222991b50c42360de2963 100644 --- a/app/code/Magento/Theme/etc/di.xml +++ b/app/code/Magento/Theme/etc/di.xml @@ -47,7 +47,7 @@ </type> <virtualType name="Magento\Theme\Model\Layout\Config\Data" type="Magento\Framework\Config\Data"> <arguments> - <argument name="reader" xsi:type="object">Magento\Theme\Model\Layout\Config\Reader</argument> + <argument name="reader" xsi:type="object">Magento\Theme\Model\Layout\Config\Reader\Proxy</argument> <argument name="cacheId" xsi:type="string">page_layouts_config</argument> </arguments> </virtualType> diff --git a/app/code/Magento/Translation/composer.json b/app/code/Magento/Translation/composer.json index 69638e1b2fffadeef154950794d3bd52ca9b5501..57882625cfc1152ce9a6a8e29e5fe57e947302b4 100644 --- a/app/code/Magento/Translation/composer.json +++ b/app/code/Magento/Translation/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha95", - "magento/module-store": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha96", + "magento/module-store": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index 93639fbc240f50219a84b8cc14ce1969f49f3e9c..feba73b5d7f05e0d44c9079cba92abefb3da9d1f 100644 --- a/app/code/Magento/Ups/composer.json +++ b/app/code/Magento/Ups/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-shipping": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-shipping": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRedirect/composer.json b/app/code/Magento/UrlRedirect/composer.json index ebfb97ff4fe85224c5a403e7ec73054462445c7b..97c616314a13b00300fa3209556548416e570d07 100644 --- a/app/code/Magento/UrlRedirect/composer.json +++ b/app/code/Magento/UrlRedirect/composer.json @@ -3,15 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-store": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95" + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-store": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", + "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRewrite/composer.json b/app/code/Magento/UrlRewrite/composer.json index 93f34470c00b3735664e70f66fb6e094e818ab4e..37851b263624247640c92166c252642b454d4e41 100644 --- a/app/code/Magento/UrlRewrite/composer.json +++ b/app/code/Magento/UrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-store": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-store": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/User/composer.json b/app/code/Magento/User/composer.json index bb64e5f3972b8b5f11ea165efe4195bc78969994..bac3f0ebb18f442bfc99b8ac1202c3f88879faa4 100644 --- a/app/code/Magento/User/composer.json +++ b/app/code/Magento/User/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-authorization": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-integration": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-authorization": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-integration": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index 84261a44ba4dd485bc162e4b305b8dd13155a085..995cb00ac7a8ddb8164e90db24de9b4db9309bca 100644 --- a/app/code/Magento/Usps/composer.json +++ b/app/code/Magento/Usps/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-shipping": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-shipping": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Webapi/composer.json b/app/code/Magento/Webapi/composer.json index ea3af99e71e6709489f1b83541fb079b7888ce37..b0b40a27d9ee9079dc50dbd368c44c2053525ccd 100644 --- a/app/code/Magento/Webapi/composer.json +++ b/app/code/Magento/Webapi/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-authorization": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-integration": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-user": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-authorization": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-integration": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-user": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Weee/Block/Item/Price/Renderer.php b/app/code/Magento/Weee/Block/Item/Price/Renderer.php index e9ec8e1f3860294837fced0ec108548a131427ee..d3ace4045b0e8fae19d429db26f52bf128159d21 100644 --- a/app/code/Magento/Weee/Block/Item/Price/Renderer.php +++ b/app/code/Magento/Weee/Block/Item/Price/Renderer.php @@ -27,6 +27,7 @@ use Magento\Weee\Model\Tax as WeeeDisplayConfig; use Magento\Sales\Model\Order\Item as OrderItem; use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; use Magento\Sales\Model\Order\CreditMemo\Item as CreditMemoItem; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Item price render block @@ -43,17 +44,19 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Tax\Helper\Data $taxHelper + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Weee\Helper\Data $weeeHelper * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Tax\Helper\Data $taxHelper, + PriceCurrencyInterface $priceCurrency, \Magento\Weee\Helper\Data $weeeHelper, array $data = array() ) { $this->weeeHelper = $weeeHelper; - parent::__construct($context, $taxHelper, $data); + parent::__construct($context, $taxHelper, $priceCurrency, $data); $this->_isScopePrivate = true; } diff --git a/app/code/Magento/Weee/Model/Tax.php b/app/code/Magento/Weee/Model/Tax.php index cd2f168d5e5cda7466d8fe255d91d816b39ad386..a523978089febcebd32d1e79d86e35f45c9b3904 100644 --- a/app/code/Magento/Weee/Model/Tax.php +++ b/app/code/Magento/Weee/Model/Tax.php @@ -24,6 +24,7 @@ namespace Magento\Weee\Model; use Magento\Catalog\Model\Product; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Store\Model\Website; use Magento\Customer\Model\Converter as CustomerConverter; use Magento\Tax\Model\Calculation; @@ -99,6 +100,11 @@ class Tax extends \Magento\Framework\Model\AbstractModel */ protected $weeeConfig; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -107,9 +113,10 @@ class Tax extends \Magento\Framework\Model\AbstractModel * @param \Magento\Tax\Model\CalculationFactory $calculationFactory * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Weee\Model\Resource\Tax $resource + * @param Resource\Tax $resource * @param CustomerConverter $customerConverter - * @param \Magento\Weee\Model\Config $weeeConfig + * @param Config $weeeConfig + * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data */ @@ -124,6 +131,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel \Magento\Weee\Model\Resource\Tax $resource, CustomerConverter $customerConverter, \Magento\Weee\Model\Config $weeeConfig, + PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { @@ -134,6 +142,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel $this->_taxData = $taxData; $this->customerConverter = $customerConverter; $this->weeeConfig = $weeeConfig; + $this->priceCurrency = $priceCurrency; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -289,7 +298,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel $value = $this->getResource()->getReadConnection()->fetchOne($attributeSelect); if ($value) { if ($discountPercent) { - $value = $this->_storeManager->getStore()->roundPrice( + $value = $this->priceCurrency->round( $value - $value * $discountPercent / 100 ); } @@ -307,23 +316,23 @@ class Tax extends \Magento\Framework\Model\AbstractModel if ($this->_taxData->priceIncludesTax($store)) { $amountInclTax = $value / (100 + $defaultPercent) * (100 + $currentPercent); //round the "golden price" - $amountInclTax = $store->roundPrice($amountInclTax); + $amountInclTax = $this->priceCurrency->round($amountInclTax); $taxAmount = $amountInclTax - $amountInclTax / (100 + $currentPercent) * 100; - $taxAmount = $store->roundPrice($taxAmount); + $taxAmount = $this->priceCurrency->round($taxAmount); } else { $appliedRates = $this->_calculationFactory->create()->getAppliedRates($rateRequest); if (count($appliedRates) > 1) { $taxAmount = 0; foreach ($appliedRates as $appliedRate) { $taxRate = $appliedRate['percent']; - $taxAmount += $this->_storeManager->getStore()->roundPrice($value * $taxRate / 100); + $taxAmount += $this->priceCurrency->round($value * $taxRate / 100); } } else { - $taxAmount = $this->_storeManager->getStore()->roundPrice( + $taxAmount = $this->priceCurrency->round( $value * $currentPercent / 100 ); } - $taxAmount = $store->roundPrice($value * $currentPercent / 100); + $taxAmount = $this->priceCurrency->round($value * $currentPercent / 100); } } diff --git a/app/code/Magento/Weee/Model/Total/Quote/Weee.php b/app/code/Magento/Weee/Model/Total/Quote/Weee.php index 5ce63520fbcd5c5e900da2f616ff467543b320ef..b2b5a9857474da6062fba4ae10a9defe1af22abe 100644 --- a/app/code/Magento/Weee/Model/Total/Quote/Weee.php +++ b/app/code/Magento/Weee/Model/Total/Quote/Weee.php @@ -23,6 +23,7 @@ */ namespace Magento\Weee\Model\Total\Quote; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Store\Model\Store; use Magento\Tax\Model\Calculation; use Magento\Sales\Model\Quote\Address\Total\AbstractTotal; @@ -77,12 +78,20 @@ class Weee extends AbstractTotal */ protected $weeeBaseTotalExclTax; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + /** * @param \Magento\Weee\Helper\Data $weeeData + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( - \Magento\Weee\Helper\Data $weeeData + \Magento\Weee\Helper\Data $weeeData, + PriceCurrencyInterface $priceCurrency ) { + $this->priceCurrency = $priceCurrency; $this->weeeData = $weeeData; $this->setCode('weee'); $this->weeeCodeToItemMap = []; @@ -166,10 +175,12 @@ class Weee extends AbstractTotal $title = $attribute->getName(); $baseValueExclTax = $baseValueInclTax = $attribute->getAmount(); - $valueExclTax = $valueInclTax = $this->_store->roundPrice($this->_store->convertPrice($baseValueExclTax)); + $valueExclTax = $valueInclTax = $this->priceCurrency->round( + $this->priceCurrency->convert($baseValueExclTax, $this->_store) + ); - $rowValueInclTax = $rowValueExclTax = $this->_store->roundPrice($valueInclTax * $item->getTotalQty()); - $baseRowValueInclTax = $this->_store->roundPrice($baseValueInclTax * $item->getTotalQty()); + $rowValueInclTax = $rowValueExclTax = $this->priceCurrency->round($valueInclTax * $item->getTotalQty()); + $baseRowValueInclTax = $this->priceCurrency->round($baseValueInclTax * $item->getTotalQty()); $baseRowValueExclTax = $baseRowValueInclTax; $totalValueInclTax += $valueInclTax; @@ -246,16 +257,16 @@ class Weee extends AbstractTotal { if (!$this->weeeData->isTaxable($this->_store)) { //Accumulate the values. Will be used later in the 'weee tax' collector - $this->weeeTotalExclTax += $this->_store->roundPrice($rowValueExclTax); - $this->weeeBaseTotalExclTax += $this->_store->roundPrice($baseRowValueExclTax); + $this->weeeTotalExclTax += $this->priceCurrency->round($rowValueExclTax); + $this->weeeBaseTotalExclTax += $this->priceCurrency->round($baseRowValueExclTax); } //This value is used to calculate shipping cost; it will be overridden by tax collector $address->setSubtotalInclTax( - $address->getSubtotalInclTax() + $this->_store->roundPrice($rowValueInclTax) + $address->getSubtotalInclTax() + $this->priceCurrency->round($rowValueInclTax) ); $address->setBaseSubtotalInclTax( - $address->getBaseSubtotalInclTax() + $this->_store->roundPrice($baseRowValueInclTax) + $address->getBaseSubtotalInclTax() + $this->priceCurrency->round($baseRowValueInclTax) ); return $this; } diff --git a/app/code/Magento/Weee/Pricing/Adjustment.php b/app/code/Magento/Weee/Pricing/Adjustment.php index afeef5022d16065715d993671b2974a23a224a23..f3f7de8d7fd7a0fd14fe0977890520d462ff794e 100644 --- a/app/code/Magento/Weee/Pricing/Adjustment.php +++ b/app/code/Magento/Weee/Pricing/Adjustment.php @@ -28,6 +28,7 @@ use Magento\Framework\Pricing\Adjustment\AdjustmentInterface; use Magento\Framework\Pricing\Object\SaleableInterface; use Magento\Weee\Helper\Data as WeeeHelper; use Magento\Tax\Pricing\Adjustment as TaxAdjustment; +use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface; /** * Weee pricing adjustment @@ -107,10 +108,14 @@ class Adjustment implements AdjustmentInterface * * @param float $amount * @param SaleableInterface $saleableItem + * @param null|array $context * @return float */ - public function extractAdjustment($amount, SaleableInterface $saleableItem) + public function extractAdjustment($amount, SaleableInterface $saleableItem, $context = []) { + if (isset($context[CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG])) { + return 0; + } return $this->getAmount($saleableItem); } @@ -119,10 +124,14 @@ class Adjustment implements AdjustmentInterface * * @param float $amount * @param SaleableInterface $saleableItem + * @param null|array $context * @return float */ - public function applyAdjustment($amount, SaleableInterface $saleableItem) + public function applyAdjustment($amount, SaleableInterface $saleableItem, $context = []) { + if (isset($context[CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG])) { + return $amount; + } return $amount + $this->getAmount($saleableItem); } diff --git a/app/code/Magento/Weee/composer.json b/app/code/Magento/Weee/composer.json index 52b372e515ad8b8bb57f5b83b3dedd45b72725fe..22f3c292be762ad7a122e4dda0fbe481d5ac6a79 100644 --- a/app/code/Magento/Weee/composer.json +++ b/app/code/Magento/Weee/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-tax": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-directory": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-eav": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-bundle": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-tax": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-directory": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-eav": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-bundle": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Weee/etc/di.xml b/app/code/Magento/Weee/etc/di.xml index 00efd9736abc41471ad2603907b60c28c9ea3038..b5b06db9ee7a8da072aa77a17a24589788adfdaf 100644 --- a/app/code/Magento/Weee/etc/di.xml +++ b/app/code/Magento/Weee/etc/di.xml @@ -44,6 +44,14 @@ </arguments> </type> + <type name="Magento\Framework\Pricing\Adjustment\Collection"> + <arguments> + <argument name="adjustments" xsi:type="array"> + <item name="weee" xsi:type="const">Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE</item> + </argument> + </arguments> + </type> + <type name="Magento\Framework\Pricing\Adjustment\Pool"> <arguments> <argument name="adjustments" xsi:type="array"> diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index 786d83ac56949096bd0a062e9a69288a8ef995f6..722dfd41368b70fb27aa0225b4d48340663c8020 100644 --- a/app/code/Magento/Widget/composer.json +++ b/app/code/Magento/Widget/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-cms": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-cms": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Widget/etc/di.xml b/app/code/Magento/Widget/etc/di.xml index 965d8ecb82ad081b2c5639337b7cef45c284060e..080a700077e603225efa0fc2e29165267dc9e16d 100644 --- a/app/code/Magento/Widget/etc/di.xml +++ b/app/code/Magento/Widget/etc/di.xml @@ -33,7 +33,7 @@ </type> <type name="Magento\Widget\Model\Config\Data"> <arguments> - <argument name="reader" xsi:type="object">Magento\Widget\Model\Config\Reader</argument> + <argument name="reader" xsi:type="object">Magento\Widget\Model\Config\Reader\Proxy</argument> <argument name="cacheId" xsi:type="string">widget_config</argument> </arguments> </type> diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index cbad874b331c3da1dff7bdc0e509e7858b37fec6..0b81bceb49b109b441cecdb49733e8acebb3a383 100644 --- a/app/code/Magento/Wishlist/composer.json +++ b/app/code/Magento/Wishlist/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha95", - "magento/module-customer": "0.1.0-alpha95", - "magento/module-catalog": "0.1.0-alpha95", - "magento/module-core": "0.1.0-alpha95", - "magento/module-checkout": "0.1.0-alpha95", - "magento/module-theme": "0.1.0-alpha95", - "magento/module-catalog-inventory": "0.1.0-alpha95", - "magento/module-rss": "0.1.0-alpha95", - "magento/module-backend": "0.1.0-alpha95", - "magento/module-bundle": "0.1.0-alpha95", - "magento/module-sales": "0.1.0-alpha95", - "magento/module-grouped-product": "0.1.0-alpha95", - "magento/module-configurable-product": "0.1.0-alpha95", - "magento/module-downloadable": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha96", + "magento/module-customer": "0.1.0-alpha96", + "magento/module-catalog": "0.1.0-alpha96", + "magento/module-core": "0.1.0-alpha96", + "magento/module-checkout": "0.1.0-alpha96", + "magento/module-theme": "0.1.0-alpha96", + "magento/module-catalog-inventory": "0.1.0-alpha96", + "magento/module-rss": "0.1.0-alpha96", + "magento/module-backend": "0.1.0-alpha96", + "magento/module-bundle": "0.1.0-alpha96", + "magento/module-sales": "0.1.0-alpha96", + "magento/module-grouped-product": "0.1.0-alpha96", + "magento/module-configurable-product": "0.1.0-alpha96", + "magento/module-downloadable": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/code/Magento/Wishlist/view/frontend/templates/render/item/price_msrp_item.phtml b/app/code/Magento/Wishlist/view/frontend/templates/render/item/price_msrp_item.phtml index f37f68a1237b8e21f874d8667bf19b6182d1d554..f36db4e8b83a0b229da25abe3b3ef46f0f8ce1cf 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/render/item/price_msrp_item.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/render/item/price_msrp_item.phtml @@ -42,7 +42,6 @@ $_msrpPrice = ''; ?> <div class="price-box msrp"> - <?php $_price = $this->helper('Magento\Catalog\Helper\Data')->getTaxPrice($_product, $_product->getMsrp()) ?> <?php if($_product->getMsrp()): ?> <?php $_msrpPrice = $_coreHelper->currency($_product->getMsrp(),true,false) ?> <span class="old-price" ><?php echo $_msrpPrice ?></span> diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index 711429eb7ef3b609d34d5ace36d1a498d973675d..b3e1efa2b7b1bc7fc45932b19318d6cd8e5d66d3 100644 --- a/app/design/adminhtml/Magento/backend/composer.json +++ b/app/design/adminhtml/Magento/backend/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/design/adminhtml/Magento/backend/theme.xml b/app/design/adminhtml/Magento/backend/theme.xml index 6b53d84f0ecb1d5a8b127023edd32f0c198ae975..02d98da6145f6168764ba1313501fb55df9f1cef 100644 --- a/app/design/adminhtml/Magento/backend/theme.xml +++ b/app/design/adminhtml/Magento/backend/theme.xml @@ -24,5 +24,5 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento 2 backend</title> - <version>0.1.0-alpha95</version> + <version>0.1.0-alpha96</version> </theme> diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index 32dc1d66d139dd251022295f23c7f35094ecf7fd..936d524e03f2c39851ec8a0896a1a963bbbb470b 100644 --- a/app/design/frontend/Magento/blank/composer.json +++ b/app/design/frontend/Magento/blank/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/blank/theme.xml b/app/design/frontend/Magento/blank/theme.xml index bce93110a1a69c67b7ce4153ef0b9ba433a1e2db..e19bb77aa439153d246275713cd1371cbc898c23 100644 --- a/app/design/frontend/Magento/blank/theme.xml +++ b/app/design/frontend/Magento/blank/theme.xml @@ -24,7 +24,7 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Blank</title> - <version>0.1.0-alpha95</version> + <version>0.1.0-alpha96</version> <media> <preview_image>media/preview.jpg</preview_image> </media> diff --git a/app/design/frontend/Magento/plushe/composer.json b/app/design/frontend/Magento/plushe/composer.json index ae10f5ca67eb765d22c503124fd3fbde575886ad..f5a727c0ef4acf14d843d1d6508f785ce50a84b0 100644 --- a/app/design/frontend/Magento/plushe/composer.json +++ b/app/design/frontend/Magento/plushe/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/theme-frontend-blank": "0.1.0-alpha95", - "magento/framework": "0.1.0-alpha95", + "magento/theme-frontend-blank": "0.1.0-alpha96", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/plushe/theme.xml b/app/design/frontend/Magento/plushe/theme.xml index b88603c9db483061be0779f68fe60fc644c8fe1e..1182853d1d6e6aa585ecac1b8a091e9101006ce0 100644 --- a/app/design/frontend/Magento/plushe/theme.xml +++ b/app/design/frontend/Magento/plushe/theme.xml @@ -24,7 +24,7 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Plushe</title> - <version>0.1.0-alpha95</version> + <version>0.1.0-alpha96</version> <parent>Magento/blank</parent> <media> <preview_image>media/preview.jpg</preview_image> diff --git a/app/design/install/Magento/basic/theme.xml b/app/design/install/Magento/basic/theme.xml index abefe60889376b1dcc381d2ad32a12713ab88f58..5fcbf8bc81b4e817f9317aa3cbd19139296a0b2b 100644 --- a/app/design/install/Magento/basic/theme.xml +++ b/app/design/install/Magento/basic/theme.xml @@ -24,5 +24,5 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Basic</title> - <version>0.1.0-alpha95</version> + <version>0.1.0-alpha96</version> </theme> diff --git a/app/etc/di.xml b/app/etc/di.xml index 1ad347d47eb5c880df3af932c385da5bb0a9ee1f..b78142a765598ef0c3029ec2440bff1695af26ed 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -135,11 +135,6 @@ <argument name="mode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument> </arguments> </type> - <type name="Magento\Framework\Module\Plugin\DbStatusValidator"> - <arguments> - <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> - </arguments> - </type> <type name="Magento\Framework\App\Arguments\ValidationState"> <arguments> <argument name="appMode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument> @@ -208,6 +203,7 @@ <type name="Magento\Framework\App\ObjectManager\ConfigLoader"> <arguments> <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> + <argument name="reader" xsi:type="object">Magento\Framework\ObjectManager\Config\Reader\Dom\Proxy</argument> </arguments> </type> <type name="Magento\Framework\App\ObjectManager\ConfigCache"> @@ -223,19 +219,20 @@ <type name="Magento\Framework\Cache\Config\Data"> <arguments> <argument name="cacheId" xsi:type="string">config_cache</argument> + <argument name="reader" xsi:type="object">Magento\Framework\Cache\Config\Reader\Proxy</argument> </arguments> </type> <type name="Magento\Framework\Interception\Config\Config"> <arguments> <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> - <argument name="reader" xsi:type="object">Magento\Framework\ObjectManager\Config\Reader\Dom</argument> + <argument name="reader" xsi:type="object">Magento\Framework\ObjectManager\Config\Reader\Dom\Proxy</argument> <argument name="cacheId" xsi:type="string">interception</argument> </arguments> </type> <type name="Magento\Framework\Interception\PluginList\PluginList"> <arguments> <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> - <argument name="reader" xsi:type="object">Magento\Framework\ObjectManager\Config\Reader\Dom</argument> + <argument name="reader" xsi:type="object">Magento\Framework\ObjectManager\Config\Reader\Dom\Proxy</argument> <argument name="cacheId" xsi:type="string">plugin-list</argument> <argument name="scopePriorityScheme" xsi:type="array"> <item name="first" xsi:type="string">global</item> @@ -249,6 +246,7 @@ </type> <type name="Magento\Framework\App\Resource\Config"> <arguments> + <argument name="reader" xsi:type="object">Magento\Framework\App\Resource\Config\Reader\Proxy</argument> <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config\Proxy</argument> <argument name="initialResources" xsi:type="init_parameter">Magento\Framework\App\Resource\Config::PARAM_INITIAL_RESOURCES</argument> </arguments> @@ -389,6 +387,7 @@ <item name="proxy" xsi:type="string">\Magento\Framework\ObjectManager\Code\Generator\Proxy</item> <item name="interceptor" xsi:type="string">\Magento\Framework\Interception\Code\Generator\Interceptor</item> <item name="decorator" xsi:type="string">\Magento\Framework\Interception\Code\Generator\Decorator</item> + <item name="logger" xsi:type="string">\Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger</item> </argument> </arguments> </type> @@ -431,10 +430,14 @@ </argument> </arguments> </virtualType> - <type name="Magento\Framework\Search\Request\Config"> <arguments> <argument name="reader" xsi:type="object">Magento\Framework\Search\Config\Reader\Filesystem</argument> </arguments> </type> + <type name="Magento\Framework\Module\ModuleList"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Framework\Module\Declaration\Reader\Filesystem\Proxy</argument> + </arguments> + </type> </config> diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index d9943b55b49fc9df2a58302634e11634278d3e15..7799d47a4b114c850903de2c8a166a6358fd1a48 100644 --- a/app/i18n/magento/de_de/composer.json +++ b/app/i18n/magento/de_de/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-de_de", "description": "German (Germany) language", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "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 02f6f7dbd8f1c603c16054d191212987694c48f4..9e84730bff0d046a12adbca914b09abef08093b8 100644 --- a/app/i18n/magento/en_us/composer.json +++ b/app/i18n/magento/en_us/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-en_us", "description": "English (United States) language", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "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 d1b456a5710018d8c90700a41e8395090b51d7f9..1de56573c19c6a0565b292cfe437855e484f520d 100644 --- a/app/i18n/magento/es_es/composer.json +++ b/app/i18n/magento/es_es/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-es_es", "description": "Spanish (Spain) language", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "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 481e9f18dc1d6b65e47aa9fbe6e6b2fbfd6fcf12..89bbe3f6460b8343b4d426804a79fc3f8128c630 100644 --- a/app/i18n/magento/fr_fr/composer.json +++ b/app/i18n/magento/fr_fr/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-fr_fr", "description": "French (France) language", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "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 d11fccd5ddda7378d14ca97d9986f3683b78bd5e..8a4d86ec40ca95be42d45a7e9547eb7f0fa14ab2 100644 --- a/app/i18n/magento/nl_nl/composer.json +++ b/app/i18n/magento/nl_nl/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-nl_nl", "description": "Dutch (Netherlands) language", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "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 9d356d9c58965e43bde93fffce713fbe265e397f..03c2a3959d6038c35eb70ae1e08ff30ff5270a80 100644 --- a/app/i18n/magento/pt_br/composer.json +++ b/app/i18n/magento/pt_br/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-pt_br", "description": "Portuguese (Brazil) language", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "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 a7b59b219c7fa288091e4c855791ac58e1003f80..bb4c25950d386b52100400a5f2e65ac427bb7b85 100644 --- a/app/i18n/magento/zh_cn/composer.json +++ b/app/i18n/magento/zh_cn/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-zh_cn", "description": "Chinese (China) language", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { - "magento/framework": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha96", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index c96c089d47cd44318e1d057599245bb0388d6ab2..e30435820aac390535d0c97899514a95fd7c3c27 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/project-community-edition", "description": "Magento project (Community Edition)", "type": "project", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { "php": "~5.4.11|~5.5.0" }, diff --git a/dev/tests/functional/lib/Mtf/Constraint/AbstractAssertForm.php b/dev/tests/functional/lib/Mtf/Constraint/AbstractAssertForm.php index 24d397f16cbc334ba56e307f70368a4d9b338f99..5247d1821cea585f2de55b6439d18a30fe885dcb 100755 --- a/dev/tests/functional/lib/Mtf/Constraint/AbstractAssertForm.php +++ b/dev/tests/functional/lib/Mtf/Constraint/AbstractAssertForm.php @@ -196,15 +196,19 @@ abstract class AbstractAssertForm extends AbstractConstraint * Sort multidimensional array by key * * @param array $data - * @param string $key + * @param string $orderKey * @return array */ - protected function sortMultidimensionalArray(array $data, $key) + protected function sortMultidimensionalArray(array $data, $orderKey) { $result = []; - foreach ($data as $value) { - $sortKey = is_numeric($value[$key]) ? floatval($value[$key]) : $value[$key]; - $result[$sortKey] = $value; + foreach ($data as $key => $value) { + if (isset($value[$orderKey])) { + $orderValue = is_numeric($value[$orderKey]) ? floatval($value[$orderKey]) : $value[$orderKey]; + $result[$orderValue] = $value; + } else { + $result[$key] = $value; + } } ksort($result); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php index 1dcbcaaab5bbb715d5663b531a9963dc62fb7a80..c470e783806269f1718a6b48800960ad2a971b36 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php @@ -28,7 +28,7 @@ use Mtf\Client\Element\Locator; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Bundle; use Mtf\Fixture\FixtureInterface; use Mtf\Fixture\InjectableFixture; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; +use Magento\Bundle\Test\Fixture\BundleProduct; /** * Class View @@ -100,9 +100,11 @@ class View extends \Magento\Catalog\Test\Block\Product\View public function fillOptions(FixtureInterface $product) { if ($product instanceof InjectableFixture) { - /** @var \Magento\Bundle\Test\Fixture\CatalogProductBundle $product */ + /** @var \Magento\Bundle\Test\Fixture\BundleProduct $product */ $checkoutData = $product->getCheckoutData(); - $bundleCheckoutData = isset($checkoutData['bundle_options']) ? $checkoutData['bundle_options'] : []; + $bundleCheckoutData = isset($checkoutData['options']['bundle_options']) + ? $checkoutData['options']['bundle_options'] + : []; } else { // TODO: Removed after refactoring(removed) old product fixture. /** @var \Magento\Bundle\Test\Fixture\BundleFixed $product */ diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php index ca9e34056288c336f749732d6ddf99fec0488c1b..e7d4240057d19532217caf6cfbf08c4e223b9952 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php @@ -32,7 +32,7 @@ use Magento\Catalog\Test\Page\Product\CatalogProductView; use Mtf\Fixture\FixtureInterface; use Mtf\Fixture\InjectableFixture; use Magento\Bundle\Test\Fixture\Bundle as BundleDataFixture; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; +use Magento\Bundle\Test\Fixture\BundleProduct; /** * Class Bundle @@ -73,7 +73,7 @@ class Bundle extends Block * * @var string */ - protected $optionLabel = './/div[@class="control"]//label[contains(@for, "options_")][%d]'; + protected $optionLabel = './/div[@class="control"]//label[.//*[@class="product-name"]]'; /** * Selector for option of select element @@ -92,11 +92,11 @@ class Bundle extends Block /** * Fill bundle option on frontend add click "Add to cart" button * - * @param CatalogProductBundle $product + * @param BundleProduct $product * @param CatalogProductView $catalogProductView * @return void */ - public function addToCart(CatalogProductBundle $product, CatalogProductView $catalogProductView) + public function addToCart(BundleProduct $product, CatalogProductView $catalogProductView) { $catalogProductView->getViewBlock()->fillOptions($product); $catalogProductView->getViewBlock()->clickAddToCart(); @@ -112,7 +112,7 @@ class Bundle extends Block public function getOptions(FixtureInterface $product) { if ($product instanceof InjectableFixture) { - /** @var CatalogProductBundle $product */ + /** @var BundleProduct $product */ $bundleSelections = $product->getBundleSelections(); $bundleOptions = isset($bundleSelections['bundle_options']) ? $bundleSelections['bundle_options'] : []; } else { @@ -182,7 +182,7 @@ class Bundle extends Block } /** - * Get data of "Multiple" option + * Get data of "Multiple select" option * * @param Element $option * @return array @@ -190,11 +190,18 @@ class Bundle extends Block protected function getMultipleselectData(Element $option) { $multiselect = $option->find($this->selectOption, Locator::SELECTOR_XPATH, 'multiselect'); - return $this->getSelectOptionsData($multiselect, 1); + $data = $this->getSelectOptionsData($multiselect, 1); + + foreach ($data['options'] as $key => $option) { + $option['title'] = trim(preg_replace('/^[\d]+ x/', '', $option['title'])); + $data['options'][$key] = $option; + } + + return $data; } /** - * Get data of "Radio" option + * Get data of "Radio buttons" option * * @param Element $option * @return array @@ -202,13 +209,12 @@ class Bundle extends Block protected function getRadiobuttonsData(Element $option) { $listOptions = []; + $optionLabels = $option->find($this->optionLabel, Locator::SELECTOR_XPATH)->getElements(); - $count = 1; - $option = $option->find(sprintf($this->optionLabel, $count), Locator::SELECTOR_XPATH); - while ($option->isVisible()) { - $listOptions[] = $this->parseOptionText($option->getText()); - ++$count; - $option = $option->find(sprintf($this->optionLabel, $count), Locator::SELECTOR_XPATH); + foreach ($optionLabels as $optionLabel) { + if ($optionLabel->isVisible()) { + $listOptions[] = $this->parseOptionText($optionLabel->getText()); + } } return ['options' => $listOptions]; @@ -222,7 +228,14 @@ class Bundle extends Block */ protected function getCheckboxData(Element $option) { - return $this->getRadiobuttonsData($option); + $data = $this->getRadiobuttonsData($option); + + foreach ($data['options'] as $key => $option) { + $option['title'] = trim(preg_replace('/^[\d]+ x/', '', $option['title'])); + $data['options'][$key] = $option; + } + + return $data; } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Checkbox.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Checkbox.php index a1d16d225d19a1b461d9b98e8d39f2e2cee72efc..fa66b78cefd9e7642159bb0226b4ee896dd9ee3b 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Checkbox.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Checkbox.php @@ -28,7 +28,7 @@ namespace Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; * Class Checkbox * Bundle option checkbox type */ -class Checkbox extends Radio +class Checkbox extends Radiobuttons { // Parent behavior } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radio.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radiobuttons.php similarity index 96% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radio.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radiobuttons.php index 6c44e031be0cae799a706602ba85320d76c295fb..290a28e89301e3837e5ced3720d248731c6adefb 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radio.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radiobuttons.php @@ -27,10 +27,10 @@ namespace Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; /** - * Class Radio + * Class Radiobuttons * Bundle option radio button type */ -class Radio extends Option +class Radiobuttons extends Option { /** * Set data in bundle option diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radio.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radiobuttons.xml similarity index 100% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radio.xml rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Radiobuttons.xml diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleInCategory.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleInCategory.php index c12d06ca0a0f66739612e4aa1aec5561f9e67306..70372af52924f31c9503c165cae6a6927309ddd6 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleInCategory.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleInCategory.php @@ -26,7 +26,7 @@ namespace Magento\Bundle\Test\Constraint; use Magento\Cms\Test\Page\CmsIndex; use Mtf\Constraint\AbstractConstraint; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; +use Magento\Bundle\Test\Fixture\BundleProduct; use Magento\Catalog\Test\Fixture\CatalogCategory; use Magento\Catalog\Test\Page\Category\CatalogCategoryView; @@ -47,14 +47,14 @@ class AssertBundleInCategory extends AbstractConstraint * * @param CatalogCategoryView $catalogCategoryView * @param CmsIndex $cmsIndex - * @param CatalogProductBundle $product + * @param BundleProduct $product * @param CatalogCategory $category * @return void */ public function processAssert( CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, - CatalogProductBundle $product, + BundleProduct $product, CatalogCategory $category ) { //Open category view page @@ -68,11 +68,11 @@ class AssertBundleInCategory extends AbstractConstraint /** * Verify product price on category view page * - * @param CatalogProductBundle $bundle + * @param BundleProduct $bundle * @param CatalogCategoryView $catalogCategoryView * @return void */ - protected function assertPrice(CatalogProductBundle $bundle, CatalogCategoryView $catalogCategoryView) + protected function assertPrice(BundleProduct $bundle, CatalogCategoryView $catalogCategoryView) { $priceData = $bundle->getDataFieldConfig('price')['source']->getPreset(); //Price from/to verification diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php index 8bc169f289f4a2bdfc9d176155d249768b3c3883..ed1aa93767d9fa0394f5b52eafc5187f934754b0 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php @@ -26,7 +26,7 @@ namespace Magento\Bundle\Test\Constraint; use Mtf\Client\Browser; use Mtf\Constraint\AbstractAssertForm; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; +use Magento\Bundle\Test\Fixture\BundleProduct; use Magento\Catalog\Test\Page\Product\CatalogProductView; /** @@ -46,13 +46,13 @@ class AssertBundleItemsOnProductPage extends AbstractAssertForm * Assert that displayed product bundle items data on product page equals passed from fixture preset * * @param CatalogProductView $catalogProductView - * @param CatalogProductBundle $product + * @param BundleProduct $product * @param Browser $browser * @return void */ public function processAssert( CatalogProductView $catalogProductView, - CatalogProductBundle $product, + BundleProduct $product, Browser $browser ) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); @@ -75,10 +75,10 @@ class AssertBundleItemsOnProductPage extends AbstractAssertForm /** * Prepare bundle options * - * @param CatalogProductBundle $product + * @param BundleProduct $product * @return array */ - protected function prepareBundleOptions(CatalogProductBundle $product) + protected function prepareBundleOptions(BundleProduct $product) { $bundleSelections = $product->getBundleSelections(); $bundleOptions = isset($bundleSelections['bundle_options']) ? $bundleSelections['bundle_options'] : []; diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php index 466b2c9c085672dd0e85412d30ab7d6140bad4b9..29d361b64debf390482867d7891b70b6427f427d 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php @@ -27,7 +27,7 @@ namespace Magento\Bundle\Test\Constraint; use Mtf\Client\Browser; use Mtf\Constraint\AbstractConstraint; use Magento\Checkout\Test\Page\CheckoutCart; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; +use Magento\Bundle\Test\Fixture\BundleProduct; use Magento\Catalog\Test\Page\Product\CatalogProductView; /** @@ -56,18 +56,18 @@ class AssertBundlePriceType extends AbstractConstraint * 2. Dynamic (price of bundle item) * * @param CatalogProductView $catalogProductView - * @param CatalogProductBundle $product + * @param BundleProduct $product * @param CheckoutCart $checkoutCartView * @param Browser $browser - * @param CatalogProductBundle $originalProduct [optional] + * @param BundleProduct $originalProduct [optional] * @return void */ public function processAssert( CatalogProductView $catalogProductView, - CatalogProductBundle $product, + BundleProduct $product, CheckoutCart $checkoutCartView, Browser $browser, - CatalogProductBundle $originalProduct = null + BundleProduct $originalProduct = null ) { $checkoutCartView->open()->getCartBlock()->clearShoppingCart(); //Open product view page @@ -80,19 +80,19 @@ class AssertBundlePriceType extends AbstractConstraint /** * Assert prices on the product view page and shopping cart page. * - * @param CatalogProductBundle $product + * @param BundleProduct $product * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCartView - * @param CatalogProductBundle $originalProduct [optional] + * @param BundleProduct $originalProduct [optional] * @return void * * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function assertPrice( - CatalogProductBundle $product, + BundleProduct $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCartView, - CatalogProductBundle $originalProduct = null + BundleProduct $originalProduct = null ) { $customerGroup = 'NOT LOGGED IN'; $bundleData = $product->getData(); @@ -109,7 +109,7 @@ class AssertBundlePriceType extends AbstractConstraint $optionPrice = []; $fillData = $product->getCheckoutData(); - foreach ($fillData['bundle_options'] as $key => $data) { + foreach ($fillData['options']['bundle_options'] as $key => $data) { $subProductPrice = 0; foreach ($bundleData['bundle_selections']['products'][$key] as $productKey => $itemProduct) { if (strpos($itemProduct->getName(), $data['value']['name']) !== false) { diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php index 8795fb227723c69754adb3030abab40d12f74e2c..908e14c2b6c1409a7dc76f33109233d8c234329d 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php @@ -26,7 +26,7 @@ namespace Magento\Bundle\Test\Constraint; use Mtf\Client\Browser; use Mtf\Constraint\AbstractConstraint; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; +use Magento\Bundle\Test\Fixture\BundleProduct; use Magento\Catalog\Test\Page\Product\CatalogProductView; /** @@ -46,13 +46,13 @@ class AssertBundlePriceView extends AbstractConstraint * * @param CatalogProductView $catalogProductView * @param Browser $browser - * @param CatalogProductBundle $product + * @param BundleProduct $product * @return void */ public function processAssert( CatalogProductView $catalogProductView, Browser $browser, - CatalogProductBundle $product + BundleProduct $product ) { //Open product view page $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); @@ -64,11 +64,11 @@ class AssertBundlePriceView extends AbstractConstraint /** * Assert prices on the product view Page * - * @param CatalogProductBundle $product + * @param BundleProduct $product * @param CatalogProductView $catalogProductView * @return void */ - protected function assertPrice(CatalogProductBundle $product, CatalogProductView $catalogProductView) + protected function assertPrice(BundleProduct $product, CatalogProductView $catalogProductView) { $priceData = $product->getDataFieldConfig('price')['source']->getPreset(); $priceBlock = $catalogProductView->getViewBlock()->getPriceBlock(); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertGroupedPriceOnBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertGroupedPriceOnBundleProductPage.php index 1b2369329c2b5eb46ac8d8edf80a89d15cf5b05d..dfce81cdb2d895d73afeac140856e4d37448b608 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertGroupedPriceOnBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertGroupedPriceOnBundleProductPage.php @@ -42,11 +42,17 @@ class AssertGroupedPriceOnBundleProductPage extends AssertProductGroupedPriceOnP */ protected function getGroupedPrice(View $view, FixtureInterface $product) { - $groupPrice['onPage'] = $view->getProductPrice(); + $groupPrice = [ + 'onPage' => [ + 'price_regular_price' => $view->getPriceBlock()->getPrice(), + 'price_from' => $view->getPriceBlock()->getPriceFrom(), + ], + 'fixture' => $product->getDataFieldConfig('price')['source']->getPreset()['price_from'] + ]; + $groupPrice['onPage'] = isset($groupPrice['onPage']['price_regular_price']) ? str_replace('As low as $', '', $groupPrice['onPage']['price_regular_price']) : str_replace('$', '', $groupPrice['onPage']['price_from']); - $groupPrice['fixture'] = $product->getDataFieldConfig('price')['source']->getPreset()['price_from']; return $groupPrice; } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.php similarity index 97% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.php index 42d24dc006d141f64e9516eebb7fff2356224fd5..316272a7b0b5443bda02844408ae710d17765189 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.php @@ -32,23 +32,23 @@ use Mtf\Repository\RepositoryFactory; use Mtf\System\Event\EventManagerInterface; /** - * Class CatalogProductBundle + * Class BundleProduct * Fixture for Bundle product * * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.TooManyFields) */ -class CatalogProductBundle extends InjectableFixture +class BundleProduct extends InjectableFixture { /** * @var string */ - protected $repositoryClass = 'Magento\Bundle\Test\Repository\CatalogProductBundle'; + protected $repositoryClass = 'Magento\Bundle\Test\Repository\BundleProduct'; /** * @var string */ - protected $handlerInterface = 'Magento\Bundle\Test\Handler\CatalogProductBundle\CatalogProductBundleInterface'; + protected $handlerInterface = 'Magento\Bundle\Test\Handler\BundleProduct\BundleProductInterface'; /** * Constructor @@ -358,7 +358,7 @@ class CatalogProductBundle extends InjectableFixture 'is_required' => '1', 'default_value' => '', 'input' => 'price', - 'source' => 'Magento\Bundle\Test\Fixture\CatalogProductBundle\Price', + 'source' => 'Magento\Bundle\Test\Fixture\BundleProduct\Price', 'group' => 'product-details' ]; @@ -615,7 +615,7 @@ class CatalogProductBundle extends InjectableFixture 'backend_type' => 'virtual', 'is_required' => '1', 'group' => 'bundle', - 'source' => 'Magento\Bundle\Test\Fixture\CatalogProductBundle\BundleSelections', + 'source' => 'Magento\Bundle\Test\Fixture\BundleProduct\BundleSelections', ]; protected $checkout_data = [ @@ -623,7 +623,7 @@ class CatalogProductBundle extends InjectableFixture 'backend_type' => 'virtual', 'is_required' => '1', 'group' => null, - 'source' => 'Magento\Bundle\Test\Fixture\CatalogProductBundle\CheckoutData', + 'source' => 'Magento\Bundle\Test\Fixture\BundleProduct\CheckoutData', ]; protected $custom_options = [ @@ -634,6 +634,11 @@ class CatalogProductBundle extends InjectableFixture 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\CustomOptions', ]; + protected $type_id = [ + 'attribute_code' => 'type_id', + 'backend_type' => 'virtual', + ]; + protected $new_variations_attribute_set_id = [ 'attribute_code' => 'new_variations_attribute_set_id' ]; @@ -958,4 +963,9 @@ class CatalogProductBundle extends InjectableFixture { return $this->getData('custom_options'); } + + public function getTypeId() + { + return $this->getData('type_id'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml similarity index 97% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml index dbee01e084877c8b5e4cdedd7c66f587aaab97ad..e3fc0c495c506b3aa6d581921fc4740711c4e754 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<fixture class="Magento\Bundle\Test\Fixture\CatalogProductBundle"> +<fixture class="Magento\Bundle\Test\Fixture\BundleProduct"> <module>Magento_Bundle</module> <type>eav</type> <entity_type>catalog_product</entity_type> @@ -242,7 +242,7 @@ <is_required>1</is_required> <default_value></default_value> <input>price</input> - <source>Magento\Bundle\Test\Fixture\CatalogProductBundle\Price</source> + <source>Magento\Bundle\Test\Fixture\BundleProduct\Price</source> </price> <price_type> <attribute_code>price_type</attribute_code> @@ -435,7 +435,7 @@ <attribute_code>checkout_data</attribute_code> <backend_type>virtual</backend_type> <group /> - <fixture>Magento\Bundle\Test\Fixture\CatalogProductBundle\CheckoutData</fixture> + <fixture>Magento\Bundle\Test\Fixture\BundleProduct\CheckoutData</fixture> </checkout_data> <custom_options> <attribute_code>custom_options</attribute_code> @@ -444,6 +444,10 @@ <is_required>0</is_required> <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\CustomOptions</source> </custom_options> + <type_id> + <attribute_code>type_id</attribute_code> + <backend_type>virtual</backend_type> + </type_id> </fields> <data_set> <sku></sku> @@ -464,6 +468,6 @@ </create_url_params> <input_prefix>product</input_prefix> </data_config> - <repository_class>Magento\Bundle\Test\Repository\CatalogProductBundle</repository_class> - <handler_interface>Magento\Bundle\Test\Handler\CatalogProductBundle\CatalogProductBundleInterface</handler_interface> + <repository_class>Magento\Bundle\Test\Repository\BundleProduct</repository_class> + <handler_interface>Magento\Bundle\Test\Handler\BundleProduct\BundleProductInterface</handler_interface> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/BundleSelections.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/BundleSelections.php similarity index 98% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/BundleSelections.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/BundleSelections.php index 3a48675641374a0869570e5f34211c9790e37296..df5eb27890fee9ee898118924c5d531b70d0505f 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/BundleSelections.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/BundleSelections.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Bundle\Test\Fixture\CatalogProductBundle; +namespace Magento\Bundle\Test\Fixture\BundleProduct; use Mtf\Fixture\FixtureFactory; use Mtf\Fixture\FixtureInterface; @@ -47,13 +47,6 @@ class BundleSelections implements FixtureInterface */ protected $params; - /** - * Current preset - * - * @var string - */ - protected $currentPreset; - /** * Constructor * @@ -67,8 +60,7 @@ class BundleSelections implements FixtureInterface $this->params = $params; if ($data['preset']) { - $this->currentPreset = $data['preset']; - $this->data = $this->getPreset($this->currentPreset); + $this->data = $this->getPreset($data['preset']); if (!empty($data['products'])) { $this->data['products'] = []; $this->data['products'] = explode('|', $data['products']); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/CheckoutData.php new file mode 100644 index 0000000000000000000000000000000000000000..90b511ea4a31a9fa7e164490bf2e57fd4ed90a3e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/CheckoutData.php @@ -0,0 +1,308 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Bundle\Test\Fixture\BundleProduct; + +/** + * Class CheckoutData + * Data for fill product form on frontend + * + * Data keys: + * - preset (Checkout data verification preset name) + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ +class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData +{ + /** + * Get preset array + * + * @param string $name + * @return array|null + */ + protected function getPreset($name) + { + $presets = [ + 'default' => [ + 'options' => [ + 'bundle_options' => [ + [ + 'title' => 'Drop-down Option', + 'type' => 'Drop-down', + 'value' => [ + 'name' => '100_dollar_product' + ] + ] + ] + ] + ], + 'default_dynamic' => [ + 'options' => [ + 'bundle_options' => [ + [ + 'title' => 'Drop-down Option', + 'type' => 'Drop-down', + 'value' => [ + 'name' => '100_dollar_product' + ] + ] + ], + 'qty' => 2 + ], + 'cartItem' => [ + 'price' => 100, + 'qty' => 2, + 'subtotal' => 200 + ] + ], + 'default_fixed' => [ + 'options' => [ + 'bundle_options' => [ + [ + 'title' => 'Drop-down Option', + 'type' => 'Drop-down', + 'value' => [ + 'name' => '100_dollar_product' + ] + ] + ] + ], + 'cartItem' => [ + 'price' => 756, + 'qty' => 1, + 'subtotal' => 756 + ] + ], + 'with_not_required_options' => [ + 'options' => [ + 'bundle_options' => [ + [ + 'title' => 'Drop-down Option', + 'type' => 'Drop-down', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + [ + 'title' => 'Radio Button Option', + 'type' => 'Radio Buttons', + 'value' => [ + 'name' => '100_dollar_product' + ] + ] + ] + ] + ], + 'with_custom_options_1' => [ + 'options' => [ + 'bundle_options' => [ + [ + 'title' => 'Drop-down Option', + 'type' => 'Drop-down', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + ], + 'custom_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_1', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_2', + 'value' => 'Field', + ], + [ + 'title' => 'attribute_key_3', + 'value' => 'Field', + ], + [ + 'title' => 'attribute_key_4', + 'value' => 'Area', + ], + [ + 'title' => 'attribute_key_6', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_7', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_8', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_9', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_10', + 'value' => '12/12/2014', + ], + [ + 'title' => 'attribute_key_11', + 'value' => '12/12/2014/12/30/AM', + ], + [ + 'title' => 'attribute_key_12', + 'value' => '12/12/AM', + ], + ] + ] + ], + 'with_custom_options_2' => [ + 'options' => [ + 'bundle_options' => [ + [ + 'title' => 'Drop-down Option', + 'type' => 'Drop-down', + 'value' => [ + 'name' => '100_dollar_product' + ] + ] + ], + 'custom_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0', + ] + ] + ] + ], + 'all_types_bundle_fixed_and_custom_options' => [ + 'options' => [ + 'bundle_options' => [ + [ + 'title' => 'Drop-down Option', + 'type' => 'Drop-down', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + [ + 'title' => 'Radio Button Option', + 'type' => 'Radio Buttons', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + [ + 'title' => 'Checkbox Option', + 'type' => 'Checkbox', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + [ + 'title' => 'Multiple Select Option', + 'type' => 'Multiple', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + ], + 'custom_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'Field', + ], + [ + 'title' => 'attribute_key_1', + 'value' => 'Area', + ], + [ + 'title' => 'attribute_key_3', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_4', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_5', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_6', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_7', + 'value' => '12/12/2014', + ], + [ + 'title' => 'attribute_key_8', + 'value' => '12/12/2014/12/30/AM', + ], + [ + 'title' => 'attribute_key_9', + 'value' => '12/12/AM', + ], + ] + ] + ], + 'all_types_bundle_options' => [ + 'options' => [ + 'bundle_options' => [ + [ + 'title' => 'Drop-down Option', + 'type' => 'Drop-down', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + [ + 'title' => 'Radio Button Option', + 'type' => 'Radio Buttons', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + [ + 'title' => 'Checkbox Option', + 'type' => 'Checkbox', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + [ + 'title' => 'Multiple Select Option', + 'type' => 'Multiple', + 'value' => [ + 'name' => '100_dollar_product' + ] + ], + ], + ] + ], + ]; + return isset($presets[$name]) ? $presets[$name] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/Price.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php similarity index 96% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/Price.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php index e4a01716fcabc11714d657a670f7293929810b12..ddd757646f6ea29b1c4fed984bc9289e8b2162e3 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/Price.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Bundle\Test\Fixture\CatalogProductBundle; +namespace Magento\Bundle\Test\Fixture\BundleProduct; use Mtf\Fixture\FixtureInterface; @@ -72,7 +72,7 @@ class Price implements FixtureInterface } /** - * Persist custom selections products + * Persist fixture * * @return void */ @@ -84,7 +84,7 @@ class Price implements FixtureInterface /** * Return prepared data set * - * @param $key [optional] + * @param string $key [optional] * @return mixed * * @SuppressWarnings(PHPMD.UnusedFormalParameter) @@ -112,12 +112,12 @@ class Price implements FixtureInterface public function getPreset() { $presets = [ - 'MAGETWO-23066' => [ + 'drop_down_with_one_option_fixed_price' => [ 'price_from' => '115.00', 'price_to' => '120.00', 'cart_price' => '145.00' ], - 'MAGETWO-23069' => [ + 'drop_down_with_one_option_percent_price' => [ 'price_from' => '115.00', 'price_to' => '120.00', 'cart_price' => '126.00' diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Cart/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..8a2eb10a7b3c6ec4b7f8e955d2e9633fc1bb0a3e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Cart/Item.php @@ -0,0 +1,119 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Bundle\Test\Fixture\Cart; + +use Mtf\Fixture\FixtureInterface; +use Magento\Bundle\Test\Fixture\BundleProduct; + +/** + * Class Item + * Data for verify cart item block on checkout page + * + * Data keys: + * - product (fixture data for verify) + */ +class Item extends \Magento\Catalog\Test\Fixture\Cart\Item +{ + /** + * @constructor + * @param FixtureInterface $product + */ + public function __construct(FixtureInterface $product) + { + parent::__construct($product); + + /** @var BundleProduct $product */ + $bundleSelection = $product->getBundleSelections(); + $checkoutData = $product->getCheckoutData(); + $checkoutBundleOptions = isset($checkoutData['options']['bundle_options']) + ? $checkoutData['options']['bundle_options'] + : []; + + foreach ($checkoutBundleOptions as $checkoutOptionKey => $checkoutOption) { + // Find option and value keys + $attributeKey = null; + $optionKey = null; + foreach ($bundleSelection['bundle_options'] as $key => $option) { + if ($option['title'] == $checkoutOption['title']) { + $attributeKey = $key; + + foreach ($option['assigned_products'] as $valueKey => $value) { + if (false !== strpos($value['search_data']['name'], $checkoutOption['value']['name'])) { + $optionKey = $valueKey; + } + } + } + } + + // Prepare option data + $bundleSelectionAttribute = $bundleSelection['products'][$attributeKey]; + $bundleOptions = $bundleSelection['bundle_options'][$attributeKey]; + $value = $bundleSelectionAttribute[$optionKey]->getName(); + $qty = $bundleOptions['assigned_products'][$optionKey]['data']['selection_qty']; + $price = number_format($bundleSelectionAttribute[$optionKey]->getPrice(), 2); + $optionData = [ + 'title' => $checkoutOption['title'], + 'value' => "{$qty} x {$value} {$price}" + ]; + + $checkoutBundleOptions[$checkoutOptionKey] = $optionData; + } + + $this->data['options'] += $checkoutBundleOptions; + } + + /** + * Persist fixture + * + * @return void + */ + public function persist() + { + // + } + + /** + * Return prepared data set + * + * @param string $key [optional] + * @return mixed + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getData($key = null) + { + return $this->data; + } + + /** + * Return data set configuration settings + * + * @return string + */ + public function getDataConfig() + { + // + } +} diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php deleted file mode 100644 index e53658aae9aec9daf100621b21de2a7331943217..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php +++ /dev/null @@ -1,257 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Bundle\Test\Fixture\CatalogProductBundle; - -/** - * Class CheckoutData - * Data keys: - * - preset (Checkout data verification preset name) - */ -class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData -{ - /** - * Get preset array - * - * @param string $name - * @return array|null - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function getPreset($name) - { - $presets = [ - 'default' => [ - 'bundle_options' => [ - [ - 'title' => 'Drop-down Option', - 'type' => 'Drop-down', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - ], - ], - 'with_not_required_options' => [ - 'bundle_options' => [ - [ - 'title' => 'Drop-down Option', - 'type' => 'Drop-down', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - [ - 'title' => 'Radio Button Option', - 'type' => 'Radio Buttons', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - ], - ], - 'with_custom_options_1' => [ - 'bundle_options' => [ - [ - 'title' => 'Drop-down Option', - 'type' => 'Drop-down', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - ], - 'custom_options' => [ - [ - 'title' => 0, - 'value' => 0, - ], - [ - 'title' => 1, - 'value' => 0, - ], - [ - 'title' => 2, - 'value' => 'Field', - ], - [ - 'title' => 3, - 'value' => 'Field', - ], - [ - 'title' => 4, - 'value' => 'Area', - ], - [ - 'title' => 6, - 'value' => 0, - ], - [ - 'title' => 7, - 'value' => 0, - ], - [ - 'title' => 8, - 'value' => 0, - ], - [ - 'title' => 9, - 'value' => 0, - ], - [ - 'title' => 10, - 'value' => '12/12/2014', - ], - [ - 'title' => 11, - 'value' => '12/12/2014/12/30/AM', - ], - [ - 'title' => 12, - 'value' => '12/12/AM', - ], - ] - ], - 'with_custom_options_2' => [ - 'bundle_options' => [ - [ - 'title' => 'Drop-down Option', - 'type' => 'Drop-down', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - ], - 'custom_options' => [ - [ - 'title' => 0, - 'value' => 0, - ], - ] - ], - 'all_types_bundle_fixed_and_custom_options' => [ - 'bundle_options' => [ - [ - 'title' => 'Drop-down Option', - 'type' => 'Drop-down', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - [ - 'title' => 'Radio Button Option', - 'type' => 'Radio Buttons', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - [ - 'title' => 'Checkbox Option', - 'type' => 'Checkbox', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - [ - 'title' => 'Multiple Select Option', - 'type' => 'Multiple', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - ], - 'custom_options' => [ - [ - 'title' => 0, - 'value' => 'Field', - ], - [ - 'title' => 1, - 'value' => 'Area', - ], - [ - 'title' => 3, - 'value' => 0, - ], - [ - 'title' => 4, - 'value' => 0, - ], - [ - 'title' => 5, - 'value' => 0, - ], - [ - 'title' => 6, - 'value' => 0, - ], - [ - 'title' => 7, - 'value' => '12/12/2014', - ], - [ - 'title' => 8, - 'value' => '12/12/2014/12/30/AM', - ], - [ - 'title' => 9, - 'value' => '12/12/AM', - ], - ] - ], - 'all_types_bundle_options' => [ - 'bundle_options' => [ - [ - 'title' => 'Drop-down Option', - 'type' => 'Drop-down', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - [ - 'title' => 'Radio Button Option', - 'type' => 'Radio Buttons', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - [ - 'title' => 'Checkbox Option', - 'type' => 'Checkbox', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - [ - 'title' => 'Multiple Select Option', - 'type' => 'Multiple', - 'value' => [ - 'name' => '100_dollar_product' - ] - ], - ], - ], - ]; - return isset($presets[$name]) ? $presets[$name] : null; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/CatalogProductBundle/CatalogProductBundleInterface.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/BundleProductInterface.php similarity index 85% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/CatalogProductBundle/CatalogProductBundleInterface.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/BundleProductInterface.php index 3829c810980cae2be39eda8ce9cded0dc64f1658..84ddac3b94aa2e775c60685105b5878c24562e00 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/CatalogProductBundle/CatalogProductBundleInterface.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/BundleProductInterface.php @@ -22,14 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Bundle\Test\Handler\CatalogProductBundle; +namespace Magento\Bundle\Test\Handler\BundleProduct; use Mtf\Handler\HandlerInterface; /** - * Interface CatalogProductBundleInterface + * Interface BundleProductInterface */ -interface CatalogProductBundleInterface extends HandlerInterface +interface BundleProductInterface extends HandlerInterface { // } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/CatalogProductBundle/Curl.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Curl.php similarity index 96% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/CatalogProductBundle/Curl.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Curl.php index b30592d2ce7cb6e0c892f4a6cee1fce755bc0a87..05ed1f8a4aba6fa39412a7ae41db8de6611bad1e 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/CatalogProductBundle/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Curl.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Bundle\Test\Handler\CatalogProductBundle; +namespace Magento\Bundle\Test\Handler\BundleProduct; use Mtf\System\Config; use Mtf\Fixture\FixtureInterface; @@ -32,7 +32,7 @@ use Magento\Catalog\Test\Handler\CatalogProductSimple\Curl as ProductCurl; * Class Curl * Create new bundle product via curl */ -class Curl extends ProductCurl implements CatalogProductBundleInterface +class Curl extends ProductCurl implements BundleProductInterface { /** * Constructor diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/CatalogProductBundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.php similarity index 96% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/CatalogProductBundle.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.php index 709c1f2bcfb4d97b78a1269fadb036aecedf6818..9195294fb1e55dd556a4acd99f2c453246fcc9f1 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/CatalogProductBundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.php @@ -27,10 +27,10 @@ namespace Magento\Bundle\Test\Repository; use Mtf\Repository\AbstractRepository; /** - * Class CatalogProductBundle + * Class BundleProduct * Data for creation Catalog Product Bundle */ -class CatalogProductBundle extends AbstractRepository +class BundleProduct extends AbstractRepository { /** * Constructor @@ -101,6 +101,7 @@ class CatalogProductBundle extends AbstractRepository 'visibility' => 'Catalog, Search', 'bundle_selections' => ['preset' => 'default_dynamic'], 'attribute_set_id' => 'Default', + 'checkout_data' => ['preset' => 'default_dynamic'], ]; $this->_data['bundle_fixed_product'] = [ @@ -129,6 +130,7 @@ class CatalogProductBundle extends AbstractRepository 'visibility' => 'Catalog, Search', 'bundle_selections' => ['preset' => 'default_fixed'], 'attribute_set_id' => 'Default', + 'checkout_data' => ['preset' => 'default_fixed'], ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php index 5385a4baa14f22a3e142940a28bc55801c15eb7e..da5588b335ccc246ff10c0e4b737d679573798fb 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php @@ -116,7 +116,13 @@ class BundleDynamicTest extends Functional //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertSame($product->getName(), $productViewBlock->getProductName()); - $this->assertEquals($product->getProductPrice(), $productViewBlock->getProductPrice()); + $this->assertEquals( + $product->getProductPrice(), + [ + 'price_from' => $productViewBlock->getPriceBlock()->getPriceFrom(), + 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo() + ] + ); $actualOptions = $productPage->getViewBlock()->getOptions($product)['bundle_options']; $expectedOptions = $product->getBundleOptions(); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php index 990347f630b2a3e4826861f736f0aa17fbb0eb35..11796d0e4996e4a2ab8b4c2d57dc9f6b763cacde 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php @@ -113,7 +113,13 @@ class BundleFixedTest extends Functional //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertSame($product->getName(), $productViewBlock->getProductName()); - $this->assertEquals($product->getProductPrice(), $productViewBlock->getProductPrice()); + $this->assertEquals( + $product->getProductPrice(), + [ + 'price_from' => $productViewBlock->getPriceBlock()->getPriceFrom(), + 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo() + ] + ); $actualOptions = $productPage->getViewBlock()->getOptions($product)['bundle_options']; $expectedOptions = $product->getBundleOptions(); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php index a5715f30f566ff301b4a340899fee3c5495bb754..837760c96aecd6b1ec86aab0b52f82d4e51a8034 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php @@ -26,7 +26,7 @@ namespace Magento\Bundle\Test\TestCase; use Mtf\TestCase\Injectable; use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; +use Magento\Bundle\Test\Fixture\BundleProduct; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; @@ -93,11 +93,11 @@ class CreateBundleProductEntityTest extends Injectable /** * Test create bundle product * - * @param CatalogProductBundle $product + * @param BundleProduct $product * @param CatalogCategory $category * @return void */ - public function test(CatalogProductBundle $product, CatalogCategory $category) + public function test(BundleProduct $product, CatalogCategory $category) { $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('bundle'); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest/test.csv index c5a33ebf810f7268ef09e8229d9bc9f53375c484..6a5c159441c00208e5a0cf42786cadc1f1b8d030 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest/test.csv +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest/test.csv @@ -5,11 +5,11 @@ "BundleProduct %isolation%";"Fixed";"bundle_sku_%isolation%";"-";"Fixed";"10";"fixed-15";"None";"-";"Fixed";"10";"-";"Bundle Product Fixed Required";"-";"-";"-";"-";"-";"-";"-";"-";"-";"default_fixed";"catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertBundleProductForm, assertProductSearchableBySku, assertBundleProductPage, assertBundleItemsOnProductPage";"" "BundleProduct %isolation%";"Fixed";"bundle_sku_%isolation%";"Product online";"Fixed";"100";"fixed-24";"Taxable Goods";"In Stock";"Fixed";"10";"category_%isolation%";"Bundle Product Fixed";"default";"-";"-";"-";"-";"As Low as";"-";"-";"Separately";"all_types_fixed";"catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product|catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product|catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product|catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product";"all_types_bundle_fixed_and_custom_options";"all_types";"-";"Catalog, Search";"No";"No";"assertProductSaveMessage, assertProductInGrid, assertBundleProductForm, assertProductVisibleInCategory, assertBundleProductPage, assertProductInStock, assertGroupedPriceOnBundleProductPage, assertBundleItemsOnProductPage, assertBundlePriceView, assertBundlePriceType";"Bug: MAGETWO-26969" "BundleProduct %isolation%";"Fixed";"bundle_sku_%isolation%";"Product online";"Fixed";"10";"fixed-1";"Taxable Goods";"Out of Stock";"Fixed";"10";"category_%isolation%";"-";"-";"10";"m/d/Y";"m/d/Y +3 days";"-";"Price Range";"No";"Yes";"Together";"with_not_required_options";"catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product|catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product";"with_not_required_options";"-";"-";"Catalog";"No";"No";"assertProductSaveMessage, assertProductInGrid, assertBundleProductForm, assertBundleProductPage, assertProductOutOfStock, assertBundlePriceView";"Bug: MAGETWO-26980" -"BundleProduct %isolation%";"Dynamic";"bundle_sku_%isolation%";"-";"Dynamic";"-";"dynamic-50";"-";"-";"Fixed";"10";"-";"-";"-";"-";"-";"-";"default";"As Low as";"No";"No";"Together";"default_dynamic";"catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product";"default";"-";"-";"Search";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertBundleProductForm, assertProductSearchableBySku, assertBundleProductPage, assertBundleItemsOnProductPage, assertTierPriceOnBundleProductPage";"Bug: MAGETWO-26853" +"BundleProduct %isolation%";"Dynamic";"bundle_sku_%isolation%";"-";"Dynamic";"-";"dynamic-50";"-";"-";"Fixed";"10";"-";"-";"-";"-";"-";"-";"default";"As Low as";"No";"No";"Together";"default_dynamic";"catalogProductSimple::100_dollar_product,catalogProductVirtual::50_dollar_product";"default";"-";"-";"Search";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertBundleProductForm, assertProductSearchableBySku, assertBundleProductPage, assertBundleItemsOnProductPage, assertTierPriceOnBundleProductPage";"" "Bundle Dynamic %isolation%";"Dynamic";"sku_bundle_dynamic_%isolation%";"-";"Dynamic";"-";"dynamic-8";"-";"-";"-";"-";"-";"-";"-";"20";"-";"-";"-";"-";"-";"-";"-";"default_dynamic";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertBundleInCategory";"" "Bundle Dynamic %isolation%";"Dynamic";"sku_bundle_dynamic_%isolation%";"-";"Dynamic";"-";"dynamic-32";"-";"-";"-";"-";"-";"-";"MAGETWO-23061";"-";"-";"-";"-";"-";"-";"-";"-";"default_dynamic";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertBundleInCategory, assertBundlePriceView, assertBundlePriceType";"" "Bundle Dynamic %isolation%";"Dynamic";"sku_bundle_dynamic_%isolation%";"-";"Dynamic";"-";"dynamic-40";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"default_dynamic";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertBundleInCategory, assertBundlePriceView, assertBundlePriceType";"" -"Bundle Fixed %isolation%";"Fixed";"sku_bundle_fixed_%isolation%";"-";"Fixed";"110";"fixed-115";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"second";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"with_custom_options_1";"MAGETWO-23066";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertBundleInCategory, assertBundlePriceView, assertBundlePriceType, assertProductCustomOptionsOnBundleProductPage";"" -"Bundle Fixed %isolation%";"Fixed";"sku_bundle_fixed_%isolation%";"-";"Fixed";"110";"fixed-126";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"second";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"with_custom_options_2";"MAGETWO-23069";"-";"-";"-";"-";"assertProductSaveMessage, assertBundleInCategory, assertBundlePriceView, assertBundlePriceType";"" +"Bundle Fixed %isolation%";"Fixed";"sku_bundle_fixed_%isolation%";"-";"Fixed";"110";"fixed-115";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"second";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"with_custom_options_1";"drop_down_with_one_option_fixed_price";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertBundleInCategory, assertBundlePriceView, assertBundlePriceType, assertProductCustomOptionsOnBundleProductPage";"" +"Bundle Fixed %isolation%";"Fixed";"sku_bundle_fixed_%isolation%";"-";"Fixed";"110";"fixed-126";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"second";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"with_custom_options_2";"drop_down_with_one_option_percent_price";"-";"-";"-";"-";"assertProductSaveMessage, assertBundleInCategory, assertBundlePriceView, assertBundlePriceType";"" "Bundle Dynamic %isolation%";"Dynamic";"sku_bundle_dynamic_%isolation%";"-";"Dynamic";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"default_dynamic";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage";"" "Bundle Fixed %isolation%";"Fixed";"sku_bundle_fixed_%isolation%";"-";"Fixed";"10";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"second";"catalogProductSimple::100_dollar_product,catalogProductSimple::40_dollar_product";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage";"" diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php index dceb96430dfdb5834b1435e488f63f720c7d0b85..bd41afca571e58549d4cc80c7ce71d531fef2734 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php @@ -138,6 +138,12 @@ class EditBundleTest extends Functional //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertSame($product->getName(), $productViewBlock->getProductName()); - $this->assertEquals($product->getProductPrice(), $productViewBlock->getProductPrice()); + $this->assertEquals( + $product->getProductPrice(), + [ + 'price_from' => $productViewBlock->getPriceBlock()->getPriceFrom(), + 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo() + ] + ); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php index aebdd19677df39894f82c61124f64692474388e6..f45b5bce731f62d2c7dcfc79b9faa4b37ae81cc3 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php @@ -25,7 +25,7 @@ namespace Magento\Bundle\Test\TestCase; use Mtf\TestCase\Injectable; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; +use Magento\Bundle\Test\Fixture\BundleProduct; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; @@ -84,11 +84,11 @@ class UpdateBundleProductEntityTest extends Injectable /** * Test update bundle product * - * @param CatalogProductBundle $product - * @param CatalogProductBundle $originalProduct + * @param BundleProduct $product + * @param BundleProduct $originalProduct * @return void */ - public function test(CatalogProductBundle $product, CatalogProductBundle $originalProduct) + public function test(BundleProduct $product, BundleProduct $originalProduct) { $originalProduct->persist(); $this->catalogProductIndex->open(); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/constraint.xml index db84e1416f85c9be0b1fd899c429175f0205282d..b5cd03775724c943142b29db80eeb4d56e84ff81 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/constraint.xml @@ -29,7 +29,7 @@ <require> <catalogCategoryView class="Magento\Catalog\Test\Page\Category\CatalogCategoryView" /> <cmsIndex class="Magento\Cms\Test\Page\CmsIndex" /> - <product class="Magento\Bundle\Test\Fixture\CatalogProductBundle" /> + <product class="Magento\Bundle\Test\Fixture\BundleProduct" /> <category class="Magento\Catalog\Test\Fixture\Category" /> </require> </assertBundleInCategory> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/curl/di.xml index 3d8c6b53493ed2d19d62cc9335feaef82e0fe630..ad56b769fa8cc9750f80cc257671a3106e06bb1c 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/curl/di.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/curl/di.xml @@ -24,5 +24,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Bundle\Test\Handler\CatalogProductBundle\CatalogProductBundleInterface" type="Magento\Bundle\Test\Handler\CatalogProductBundle\Curl" /> + <preference for="Magento\Bundle\Test\Handler\BundleProduct\BundleProductInterface" type="Magento\Bundle\Test\Handler\BundleProduct\Curl" /> </config> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/fixture.xml index 36e822cde00dba9e147f719d1370a964f0c14658..d85ce3e0f0c5d8bb83ea9eeae04b7e381bb7ea91 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/etc/fixture.xml @@ -24,7 +24,7 @@ */ --> <fixture> - <catalogProductBundle module="Magento_Bundle"> + <bundleProduct module="Magento_Bundle"> <type>eav</type> <entity_type>catalog_product</entity_type> <product_type>bundle</product_type> @@ -62,5 +62,5 @@ </create_url_params> <input_prefix>product</input_prefix> </data_config> - </catalogProductBundle> + </bundleProduct> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php index cc915d53a45accea0c4e183709aad8f0efc29e6f..cf7b8faf9422d8c64f95a8f78cd3dfaedde87fd0 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php @@ -36,6 +36,13 @@ use Mtf\Fixture\FixtureInterface; */ class Configure extends Form { + /** + * Selector for quantity field + * + * @var string + */ + protected $qty = '[name="qty"]'; + /** * Fill options for the product * @@ -45,11 +52,11 @@ class Configure extends Form public function fillOptions(FixtureInterface $product) { $productOptions = $product->getCheckoutData(); - if (!empty($productOptions['configurable_options'])) { + if (!empty($productOptions['options']['configurable_options'])) { $configurableAttributesData = $product->getData('fields/configurable_attributes_data/value'); $checkoutData = []; - foreach ($productOptions['configurable_options'] as $optionData) { + foreach ($productOptions['options']['configurable_options'] as $optionData) { $titleKey = $optionData['title']; $valueKey = $optionData['value']; @@ -69,7 +76,12 @@ class Configure extends Form ); $select->setValue($option['value']); } - $this->_rootElement->find('.ui-dialog-buttonset button:nth-of-type(2)')->click(); } + + if (isset($productOptions['options']['qty'])) { + $this->_rootElement->find($this->qty)->setValue($productOptions['options']['qty']); + } + + $this->_rootElement->find('.ui-dialog-buttonset button:nth-of-type(2)')->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php index 726ec183155570c7b02cb80f0f011ca27272187e..4143c18833fac50b5d0000f5c81900b9bbca01e1 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php @@ -24,6 +24,7 @@ namespace Magento\Catalog\Test\Block\Product; use Mtf\Block\Block; +use Mtf\Client\Element; use Mtf\Client\Element\Locator; /** @@ -33,108 +34,145 @@ use Mtf\Client\Element\Locator; class Price extends Block { /** - * This member holds the class name of the old price block. + * Mapping for different type of price * - * @var string + * @var array */ - protected $oldPriceClass = '.old-price'; + protected $mapTypePrices = [ + 'price' => [ + 'selector' => '.price .price' + ], + 'old_price' => [ + 'selector' => '.old-price .price' + ], + 'map_old_price' => [ + 'selector' => '.old.price .price' + ], + 'actual_price' => [ + 'selector' => '.actual.price .price' + ], + 'special_price' => [ + 'selector' => '.special-price .price' + ], + 'final_price' => [ + 'selector' => '.price-final_price .price' + ], + 'price_from' => [ + 'selector' => 'p.price-from .price' + ], + 'price_to' => [ + 'selector' => 'p.price-to .price' + ] + ]; /** - * This member holds the class name of the price block that contains the actual price value. + * 'Add to Cart' button * * @var string */ - protected $priceClass = '.price'; + protected $addToCart = '.action.tocart'; /** - * This member holds the class name of the regular price block. + * Minimum Advertised Price * * @var string */ - protected $regularPriceClass = '.price-final_price'; + protected $priceMap = '.old.price .price .price'; /** - * This member holds the class name of the special price block. + * 'Close' button * * @var string */ - protected $specialPriceClass = '.special-price'; + protected $closeMap = '//section[@class="page main"]//div[@class="ui-dialog-buttonset"]//button'; /** - * Minimum Advertised Price + * This method returns the price represented by the block * - * @var string + * @param string $currency + * @return string */ - protected $priceMap = '.old.price .price .price'; + public function getPrice($currency = '$') + { + return $this->getTypePrice('price', $currency); + } /** - * Actual Price + * Get actual Price value on frontend * - * @var string + * @param string $currency + * + * @return array|float */ - protected $actualPrice = '.actual.price .price'; + public function getActualPrice($currency = '$') + { + return $this->getTypePrice('actual_price', $currency); + } /** - * 'Add to Cart' button + * This method returns the old price represented by the block * - * @var string + * @param string $currency + * @return string */ - protected $addToCart = '.action.tocart'; + public function getOldPrice($currency = '$') + { + return $this->getTypePrice('old_price', $currency); + } /** - * 'Close' button + * This method returns the final price represented by the block * - * @var string + * @param string $currency + * @return string */ - protected $closeMap = '//section[@class="page main"]//div[@class="ui-dialog-buttonset"]//button'; + public function getFinalPrice($currency = '$') + { + return $this->getTypePrice('final_price', $currency); + } /** - * Price from selector + * This method returns the old price represented by the block * - * @var string + * @param string $currency + * @return string */ - protected $priceFromSelector = 'p.price-from span.price'; + public function getMapOldPrice($currency = '$') + { + return $this->getTypePrice('map_old_price', $currency); + } /** - * Price to selector + * This method returns the special price represented by the block * - * @var string + * @param string $currency + * @return string */ - protected $priceToSelector = 'p.price-to span.price'; + public function getSpecialPrice($currency = '$') + { + return $this->getTypePrice('special_price', $currency); + } /** - * Getting prices + * Get price from * * @param string $currency - * @return array + * @return string */ - public function getPrice($currency = '$') + public function getPriceFrom($currency = '$') { - //@TODO it have to rewrite when will be possibility to divide it to different blocks(by product type) - $prices = explode("\n", trim($this->_rootElement->getText())); - if (count($prices) === 1) { - $prices[0] = str_replace(',', '', $prices[0]); - return ['price_regular_price' => trim($prices[0], $currency)]; - } - return $this->formatPricesData($prices, $currency); + return $this->getTypePrice('price_from', $currency); } /** - * Formatting data prices + * Get price to * - * @param array $prices * @param string $currency - * @return array + * @return string */ - private function formatPricesData(array $prices, $currency = '$') + public function getPriceTo($currency = '$') { - $formatted = []; - foreach ($prices as $price) { - list($name, $price) = explode($currency, $price); - $name = str_replace(' ', '_', trim(preg_replace('#[^0-9a-z]+#i', ' ', strtolower($name)), ' ')); - $formatted['price_' . $name] = str_replace(',', '', $price); - } - return $formatted; + return $this->getTypePrice('price_to', $currency); } /** @@ -147,15 +185,15 @@ class Price extends Block public function getEffectivePrice() { // if a special price is available, then return that - $priceElement = $this->_rootElement->find($this->specialPriceClass, Locator::SELECTOR_CSS); + $priceElement = $this->getTypePriceElement('special_price'); if (!$priceElement->isVisible()) { - $priceElement = $this->_rootElement->find($this->regularPriceClass, Locator::SELECTOR_CSS); + $priceElement = $this->getTypePriceElement('price'); if (!$priceElement->isVisible()) { - $priceElement = $this->_rootElement->find($this->oldPriceClass, Locator::SELECTOR_CSS); + $priceElement = $this->getTypePriceElement('old_price'); } } // return the actual value of the price - return $priceElement->find($this->priceClass, Locator::SELECTOR_CSS)->getText(); + return $this->escape($priceElement->getText()); } /** @@ -166,26 +204,12 @@ class Price extends Block public function getRegularPrice() { // either return the old price (implies special price display or a regular price - $priceElement = $this->_rootElement->find($this->oldPriceClass, Locator::SELECTOR_CSS); + $priceElement = $this->getTypePriceElement('old_price'); if (!$priceElement->isVisible()) { - $priceElement = $this->_rootElement->find($this->regularPriceClass, Locator::SELECTOR_CSS); + $priceElement = $this->getTypePriceElement('price'); } // return the actual value of the price - $element = $priceElement->find($this->priceClass, Locator::SELECTOR_CSS); - $price = preg_replace('#[^\d\.\s]+#umis', '', $element->getText()); - return number_format(trim($price), 2); - } - - /** - * This method returns the special price represented by the block. - * - * @return string - */ - public function getSpecialPrice() - { - $element = $this->_rootElement->find($this->specialPriceClass, Locator::SELECTOR_CSS) - ->find($this->priceClass, Locator::SELECTOR_CSS); - $price = preg_replace('#[^\d\.\s]+#umis', '', $element->getText()); + $price = preg_replace('#[^\d\.\s]+#umis', '', $priceElement->getText()); return number_format(trim($price), 2); } @@ -196,7 +220,7 @@ class Price extends Block */ public function isRegularPriceVisible() { - return $this->_rootElement->find($this->regularPriceClass, Locator::SELECTOR_CSS)->isVisible(); + return $this->getTypePriceElement('price')->isVisible(); } /** @@ -206,34 +230,7 @@ class Price extends Block */ public function isSpecialPriceVisible() { - return $this->_rootElement->find($this->specialPriceClass, Locator::SELECTOR_CSS)->isVisible(); - } - - /** - * Get Minimum Advertised Price value - * - * @return array|string - */ - public function getOldPrice() - { - return $this->_rootElement->find($this->priceMap, Locator::SELECTOR_CSS)->getText(); - } - - /** - * Get actual Price value on frontend - * - * @param string $currency - * - * @return array|float - */ - public function getActualPrice($currency = '$') - { - //@TODO it have to rewrite when will be possibility to divide it to different blocks(by product type) - $prices = explode("\n", trim($this->_rootElement->find($this->actualPrice, Locator::SELECTOR_CSS)->getText())); - if (count($prices) == 1) { - return floatval(trim($prices[0], $currency)); - } - return $this->formatPricesData($prices, $currency); + return $this->getTypePriceElement('special_price')->isVisible(); } /** @@ -258,24 +255,42 @@ class Price extends Block } /** - * Get price from + * Get specify type price * - * @param string $currency - * @return string + * @param string $type + * @param string $currency [optional] + * @return string|null */ - public function getPriceFrom($currency = '$') + protected function getTypePrice($type, $currency = '$') { - return trim($this->_rootElement->find($this->priceFromSelector)->getText(), $currency); + $typePriceElement = $this->getTypePriceElement($type); + return $typePriceElement->isVisible() ? $this->escape($typePriceElement->getText(), $currency) : null; } /** - * Get price to + * Get specify type price element * + * @param string $type + * @return Element + */ + protected function getTypePriceElement($type) + { + $mapTypePrice = $this->mapTypePrices[$type]; + return $this->_rootElement->find( + $mapTypePrice['selector'], + isset($mapTypePrice['strategy']) ? $mapTypePrice['strategy'] : Locator::SELECTOR_CSS + ); + } + + /** + * Escape currency and separator for price + * + * @param string $price * @param string $currency * @return string */ - public function getPriceTo($currency = '$') + protected function escape($price, $currency = '$') { - return trim($this->_rootElement->find($this->priceToSelector)->getText(), $currency); + return str_replace([',', $currency], '', $price); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php index de14d5daef584f2b374142ff9bbe522a60fd10e7..b3dfb41ab92bfa4a7d6692f330de95ec1ca7b77c 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php @@ -29,7 +29,6 @@ use Mtf\Client\Element\Locator; use Mtf\Fixture\FixtureInterface; use Mtf\Fixture\InjectableFixture; use Magento\Catalog\Test\Fixture\CatalogProductSimple; -use Magento\Catalog\Test\Fixture\GroupedProduct; /** * Class View @@ -37,6 +36,7 @@ use Magento\Catalog\Test\Fixture\GroupedProduct; * * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @SuppressWarnings(PHPMD.NPathComplexity) */ class View extends Block { @@ -75,13 +75,6 @@ class View extends Block */ protected $paypalCheckout = '[data-action=checkout-form-submit]'; - /** - * This member holds the class name for the price block found inside the product details. - * - * @var string - */ - protected $priceBlockClass = 'price-box'; - /** * Product name element * @@ -110,13 +103,6 @@ class View extends Block */ protected $productShortDescription = '.product.attibute.overview'; - /** - * Product price element - * - * @var string - */ - protected $productPrice = '.price-box .price'; - /** * Click for Price link on Product page * @@ -200,7 +186,13 @@ class View extends Block */ public function addToCart(FixtureInterface $product) { + /** @var CatalogProductSimple $product */ + $checkoutData = $product->getCheckoutData(); + $this->fillOptions($product); + if (isset($checkoutData['qty'])) { + $this->_rootElement->find($this->qty)->setValue($checkoutData['qty']); + } $this->clickAddToCart(); } @@ -266,16 +258,6 @@ class View extends Block return $this->_rootElement->find($this->productSku, Locator::SELECTOR_CSS)->getText(); } - /** - * Return product price displayed on page - * - * @return array|string Returns arrays with keys corresponding to fixture keys - */ - public function getProductPrice() - { - return $this->getPriceBlock()->getPrice(); - } - /** * Return product short description on page * @@ -305,10 +287,10 @@ class View extends Block /** * Return product options * - * @param FixtureInterface $product [optional] + * @param FixtureInterface $product * @return array */ - public function getOptions(FixtureInterface $product = null) + public function getOptions(FixtureInterface $product) { /** @var CatalogProductSimple $product */ $dataConfig = $product->getDataConfig(); @@ -319,33 +301,6 @@ class View extends Block : $this->getCustomOptionsBlock()->getOptions($product); } - /** - * Verify product options - * - * @param FixtureInterface $product - * @return bool - */ - public function verifyProductOptions(FixtureInterface $product) - { - $attributes = $product->getConfigurableOptions(); - foreach ($attributes as $attributeName => $attribute) { - foreach ($attribute as $optionName) { - $option = $this->_rootElement->find( - '//*[*[@class="field configurable required"]//span[text()="' . - $attributeName . - '"]]//select/option[contains(text(), "' . - $optionName . - '")]', - Locator::SELECTOR_XPATH - ); - if (!$option->isVisible()) { - return false; - } - } - } - return true; - } - /** * Fill in the option specified for the product * @@ -356,26 +311,32 @@ class View extends Block { $dataConfig = $product->getDataConfig(); $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + $checkoutData = null; /** @var CatalogProductSimple $product */ if ($this->hasRender($typeId)) { $this->callRender($typeId, 'fillOptions', ['product' => $product]); } else { - $optionsCheckoutData = []; + $checkoutCustomOptions = []; if ($product instanceof InjectableFixture) { /** @var CatalogProductSimple $product */ + $checkoutData = $product->getCheckoutData(); + $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) + ? $checkoutData['options']['custom_options'] + : []; $customOptions = $product->hasData('custom_options') ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() : []; - $checkoutData = $product->getCheckoutData(); - $productCheckoutData = isset($checkoutData['custom_options']) - ? $checkoutData['custom_options'] - : []; - $optionsCheckoutData = $this->prepareCheckoutData($customOptions, $productCheckoutData); + + $checkoutCustomOptions = $this->prepareCheckoutData($customOptions, $checkoutCustomOptions); } - $this->getCustomOptionsBlock()->fillCustomOptions($optionsCheckoutData); + $this->getCustomOptionsBlock()->fillCustomOptions($checkoutCustomOptions); + } + + if (isset($checkoutData['options']['qty'])) { + $this->_rootElement->find($this->qty)->setValue($checkoutData['options']['qty']); } } @@ -391,18 +352,18 @@ class View extends Block $result = []; foreach ($checkoutData as $checkoutOption) { - $attributeKey = $checkoutOption['title']; - $optionKey = $checkoutOption['value']; + $attribute = str_replace('attribute_key_', '', $checkoutOption['title']); + $option = str_replace('option_key_', '', $checkoutOption['value']); - if (isset($options[$attributeKey])) { + if (isset($options[$attribute])) { $result[] = [ - 'type' => strtolower(preg_replace('/[^a-z]/i', '', $options[$attributeKey]['type'])), - 'title' => isset($options[$attributeKey]['title']) - ? $options[$attributeKey]['title'] - : $attributeKey, - 'value' => isset($options[$attributeKey]['options'][$optionKey]['title']) - ? $options[$attributeKey]['options'][$optionKey]['title'] - : $optionKey + 'type' => strtolower(preg_replace('/[^a-z]/i', '', $options[$attribute]['type'])), + 'title' => isset($options[$attribute]['title']) + ? $options[$attribute]['title'] + : $attribute, + 'value' => isset($options[$attribute]['options'][$option]['title']) + ? $options[$attribute]['options'][$option]['title'] + : $option ]; } } @@ -434,26 +395,6 @@ class View extends Block $this->_rootElement->find($this->addToCart, Locator::SELECTOR_CSS)->click(); } - /** - * Verification of group products - * - * @param GroupedProduct $product - * @return bool - */ - public function verifyGroupedProducts(GroupedProduct $product) - { - foreach ($product->getAssociatedProductNames() as $name) { - $option = $this->_rootElement->find( - "//*[@id='super-product-table']//tr[td/strong='{$name}']", - Locator::SELECTOR_XPATH - ); - if (!$option->isVisible()) { - return false; - } - } - return true; - } - /** * Open MAP block on Product View page * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php index 46ae945653282e5ce47c67899ab5c9e8e0847bc2..709ec32bc36aaaab10833eb59160a89466cf1b63 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php @@ -31,7 +31,7 @@ use Mtf\Fixture\FixtureInterface; use Mtf\Fixture\InjectableFixture; /** - * Class Custom Options + * Class CustomOptions * Form of custom options product */ class CustomOptions extends Form diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php index eb8c9a4e873072ce181b04ca115b55c5c6a52f9d..ad0bcb76a6a0a0298ef1c43505bc5b9475f978f9 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php @@ -111,10 +111,10 @@ class AssertProductCustomOptionsOnProductPage extends AbstractAssertForm $actualPrice = null; if ($this->isPrice) { - $prices = $catalogProductView->getViewBlock()->getPriceBlock()->getPrice(); - $actualPrice = isset($prices['price_special_price']) - ? $prices['price_special_price'] - : $prices['price_regular_price']; + $priceBlock = $catalogProductView->getViewBlock()->getPriceBlock(); + $specialPrice = $priceBlock->getSpecialPrice(); + $price = $priceBlock->getPrice(); + $actualPrice = $specialPrice ? $specialPrice : $price; } $fixtureCustomOptions = $this->prepareOptions($product, $actualPrice); $formCustomOptions = $catalogProductView->getViewBlock()->getOptions($product)['custom_options']; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductGroupedPriceOnProductPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductGroupedPriceOnProductPage.php index 788a2a3bb0b060dba1f3437ddb6976b048efab26..0ac953636b011e68b9ef55d1091488dc99add690 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductGroupedPriceOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductGroupedPriceOnProductPage.php @@ -113,10 +113,7 @@ class AssertProductGroupedPriceOnProductPage extends AbstractConstraint implemen protected function getGroupedPrice(View $view, FixtureInterface $product) { $fields = $product->getData(); - $groupPrice['onPage'] = $view->getProductPrice(); - $groupPrice['onPage'] = isset($groupPrice['onPage']['price_special_price']) - ? $groupPrice['onPage']['price_special_price'] - : null; + $groupPrice['onPage'] = $view->getPriceBlock()->getSpecialPrice(); $groupPrice['fixture'] = number_format( $fields['group_price'][array_search($this->customerGroup, $fields['group_price'])]['price'], 2 diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php index a50c602cee51b3dd7ea65f2034ac12bab8ebd577..759755e4104731521672f09b5d90d672cafd9eeb 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php @@ -29,6 +29,7 @@ use Mtf\Fixture\FixtureInterface; use Mtf\Constraint\AbstractConstraint; use Magento\Checkout\Test\Page\CheckoutCart; use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; /** * Class AssertProductInCart @@ -76,9 +77,12 @@ class AssertProductInCart extends AbstractConstraint */ protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart) { + /** @var CatalogProductSimple $product */ $customOptions = $product->getCustomOptions(); $checkoutData = $product->getCheckoutData(); - $checkoutCustomOptions = isset($checkoutData['custom_options']) ? $checkoutData['custom_options'] : []; + $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) + ? $checkoutData['options']['custom_options'] + : []; $fixturePrice = $product->getPrice(); $groupPrice = $product->getGroupPrice(); $specialPrice = $product->getSpecialPrice(); @@ -95,8 +99,8 @@ class AssertProductInCart extends AbstractConstraint $fixtureActualPrice = $fixturePrice; foreach ($checkoutCustomOptions as $checkoutOption) { - $attributeKey = $checkoutOption['title']; - $optionKey = $checkoutOption['value']; + $attributeKey = str_replace('attribute_key_', '', $checkoutOption['title']); + $optionKey = str_replace('option_key_', '', $checkoutOption['value']); $option = $customOptions[$attributeKey]['options'][$optionKey]; if ('Fixed' == $option['price_type']) { @@ -107,7 +111,7 @@ class AssertProductInCart extends AbstractConstraint } \PHPUnit_Framework_Assert::assertEquals( - number_format($fixtureActualPrice, 2), + $fixtureActualPrice, $formPrice, 'Product price in shopping cart is not correct.' ); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSpecialPriceOnProductPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSpecialPriceOnProductPage.php index 0b3a252b33077308ff4b846dbae7d03d8d5cba7f..ddf0b5357131a413b3f1eff4c9bb8640be91a3ba 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSpecialPriceOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSpecialPriceOnProductPage.php @@ -89,10 +89,7 @@ class AssertProductSpecialPriceOnProductPage extends AbstractConstraint implemen $block = '' ) { $fields = $product->getData(); - $specialPrice = $catalogProductView->{'get' . $block . 'ViewBlock'}()->getProductPrice(); - $specialPrice = (isset($specialPrice['price_special_price'])) - ? $specialPrice['price_special_price'] - : null; + $specialPrice = $catalogProductView->getViewBlock()->getPriceBlock()->getSpecialPrice(); if (isset($fields['special_price'])) { \PHPUnit_Framework_Assert::assertEquals( number_format($fields['special_price'], 2), diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Cart/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..8ce2ab916b3b07e9f30313d6d7bbff0bfe268fa2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Cart/Item.php @@ -0,0 +1,115 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Test\Fixture\Cart; + +use Magento\Bundle\Test\Fixture\BundleProduct; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Mtf\Fixture\FixtureInterface; + +/** + * Class Item + * Data for verify cart item block on checkout page + * + * Data keys: + * - product (fixture data for verify) + * + * @SuppressWarnings(PHPMD.NPathComplexity) + */ +class Item implements FixtureInterface +{ + /** + * Prepared dataSet data + * + * @var array + */ + protected $data = []; + + /** + * @constructor + * @param FixtureInterface $product + */ + public function __construct(FixtureInterface $product) + { + /** @var CatalogProductSimple $product */ + $checkoutData = $product->getCheckoutData(); + $cartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : []; + $customOptions = $product->hasData('custom_options') ? $product->getCustomOptions() : []; + $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) + ? $checkoutData['options']['custom_options'] + : []; + + foreach ($checkoutCustomOptions as $key => $checkoutCustomOption) { + $attribute = str_replace('attribute_key_', '', $checkoutCustomOption['title']); + $option = str_replace('option_key_', '', $checkoutCustomOption['value']); + + $checkoutCustomOptions[$key] = [ + 'title' => isset($customOptions[$attribute]['title']) + ? $customOptions[$attribute]['title'] + : $attribute, + 'value' => isset($customOptions[$attribute]['options'][$option]['title']) + ? $customOptions[$attribute]['options'][$option]['title'] + : $option + ]; + } + + $cartItem['options'] = isset($cartItem['options']) + ? $cartItem['options'] + $checkoutCustomOptions + : $checkoutCustomOptions; + $this->data = $cartItem; + } + + /** + * Persist fixture + * + * @return void + */ + public function persist() + { + // + } + + /** + * Return prepared data set + * + * @param string $key [optional] + * @return mixed + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getData($key = null) + { + return $this->data; + } + + /** + * Return data set configuration settings + * + * @return string + */ + public function getDataConfig() + { + // + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php index 8780e106d913a5a0779189e1d5f754899c80fe8c..5162898840fca7c5cf6ab5bfe94bbe1591dbc023 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php @@ -57,7 +57,7 @@ class CheckoutData implements FixtureInterface public function __construct(array $params, array $data = []) { $this->params = $params; - $this->data = isset($data['preset']) ? $this->getPreset($data['preset']) : []; + $this->data = isset($data['preset']) ? $this->getPreset($data['preset']) : []; if (isset($data['value'])) { $this->data = array_replace_recursive($this->data, $data['value']); @@ -77,7 +77,7 @@ class CheckoutData implements FixtureInterface /** * Return prepared data set * - * @param int $key [optional] + * @param string $key [optional] * @return mixed * * @SuppressWarnings(PHPMD.UnusedFormalParameter) @@ -106,46 +106,81 @@ class CheckoutData implements FixtureInterface protected function getPreset($name) { $presets = [ - 'MAGETWO-23062' => [ - 'custom_options' => [ - [ - 'title' => 0, - 'value' => 0 + 'with_two_custom_option' => [ + 'options' => [ + 'custom_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0' + ], + [ + 'title' => 'attribute_key_1', + 'value' => 'Content option %isolation%', + ] ] + ], + 'cartItem' => [ + 'price' => 340, + 'qty' => 1, + 'subtotal' => 340 ] ], - 'MAGETWO-23063' => [ - 'custom_options' => [ - [ - 'title' => 0, - 'value' => 0 + 'options-suite' => [ + 'options' => [ + 'custom_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'Field value 1 %isolation%' + ], + [ + 'title' => 'attribute_key_1', + 'value' => 'Field value 2 %isolation%' + ], + [ + 'title' => 'attribute_key_2', + 'value' => 'option_key_1' + ], + [ + 'title' => 'attribute_key_3', + 'value' => 'option_key_0' + ] ] ] ], - 'options-suite' => [ - 'custom_options' => [ - [ - 'title' => 0, - 'value' => 'Field value 1 %isolation%' - ], - [ - 'title' => 1, - 'value' => 'Field value 2 %isolation%' - ], - [ - 'title' => 2, - 'value' => 1 - ], - [ - 'title' => 3, - 'value' => 0 + 'drop_down_with_one_option_fixed_price' => [ + 'options' => [ + 'custom_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0' + ] + ] + ] + ], + 'drop_down_with_one_option_percent_price' => [ + 'options' => [ + 'custom_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0' + ] ] ] ], 'order_default' => [ - 'qty' => 2 + 'options' => [ + 'qty' => 1 + ] + ], + 'order_big_qty' => [ + 'options' => [ + 'qty' => 2 + ], + 'cartItem' => [ + 'qty' => 2 + ] ] ]; - return isset($presets[$name]) ? $presets[$name] : null; + return isset($presets[$name]) ? $presets[$name] : []; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CustomOptions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CustomOptions.php index 6eb83048281cec2644fca2ed27293d5fd2442b43..c4bd3cda848203df5a346ff13cc0d425a9178b55 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CustomOptions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CustomOptions.php @@ -161,7 +161,7 @@ class CustomOptions implements FixtureInterface protected function getPreset($name) { $presets = [ - 'MAGETWO-23062' => [ + 'drop_down_with_one_option_fixed_price' => [ [ 'title' => 'custom option drop down %isolation%', 'is_require' => 'Yes', @@ -176,7 +176,7 @@ class CustomOptions implements FixtureInterface ] ] ], - 'MAGETWO-23063' => [ + 'drop_down_with_one_option_percent_price' => [ [ 'title' => 'custom option drop down %isolation%', 'is_require' => 'Yes', @@ -191,36 +191,6 @@ class CustomOptions implements FixtureInterface ] ] ], - 'MAGETWO-23066' => [ - [ - 'title' => 'custom option drop down %isolation%', - 'is_require' => 'Yes', - 'type' => 'Drop-down', - 'options' => [ - [ - 'title' => '30 bucks', - 'price' => 30, - 'price_type' => 'Fixed', - 'sku' => 'sku_drop_down_row_1' - ] - ] - ] - ], - 'MAGETWO-23069' => [ - [ - 'title' => 'custom option drop down %isolation%', - 'is_require' => 'Yes', - 'type' => 'Drop-down', - 'options' => [ - [ - 'title' => '10 percent', - 'price' => 10, - 'price_type' => 'Percent', - 'sku' => 'sku_drop_down_row_1' - ] - ] - ] - ], 'options-suite' => [ [ 'title' => 'Test1 option %isolation%', @@ -416,7 +386,7 @@ class CustomOptions implements FixtureInterface 'type' => 'Radio Buttons', 'options' => [ [ - 'title' => '20 percent', + 'title' => '20 fixed', 'price' => 20, 'price_type' => 'Fixed', 'sku' => 'sku_radio_buttons_row%isolation%' @@ -429,7 +399,7 @@ class CustomOptions implements FixtureInterface 'type' => 'Checkbox', 'options' => [ [ - 'title' => '20 percent', + 'title' => '20 fixed', 'price' => 20, 'price_type' => 'Fixed', 'sku' => 'sku_checkbox_row%isolation%' @@ -442,7 +412,7 @@ class CustomOptions implements FixtureInterface 'type' => 'Multiple Select', 'options' => [ [ - 'title' => '20 percent', + 'title' => '20 fixed', 'price' => 20, 'price_type' => 'Fixed', 'sku' => 'sku_multiple_select_row%isolation%' diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/Price.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/Price.php index 7b9ddfe6c723fdb4ee72dd09f176173e14e112f2..aa37a97e490c12fc49a93d74431c7ca0f5f1c81c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/Price.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/Price.php @@ -122,12 +122,12 @@ class Price implements FixtureInterface public function getPreset() { $presets = [ - 'MAGETWO-23062' => [ + 'drop_down_with_one_option_fixed_price' => [ 'category_price' => '100.00', 'product_price' => '100.00', 'cart_price' => '130.00' ], - 'MAGETWO-23063' => [ + 'drop_down_with_one_option_percent_price' => [ 'category_price' => '100.00', 'product_price' => '100.00', 'cart_price' => '140.00' diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php index 041ae5ba6797562331dc3ddca0824b67cf715b88..a50685ccf893fbcde2a161f705f15133ba25085a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php @@ -88,6 +88,7 @@ class CatalogProductVirtual extends InjectableFixture } protected $dataConfig = [ + 'type_id' => 'virtual', 'create_url_params' => [ 'type' => 'virtual', 'set' => '4', @@ -583,6 +584,13 @@ class CatalogProductVirtual extends InjectableFixture 'group' => 'websites', ]; + protected $checkout_data = [ + 'attribute_code' => 'checkout_data', + 'backend_type' => 'virtual', + 'group' => null, + 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductVirtual\CheckoutData', + ]; + public function getCategoryIds() { return $this->getData('category_ids'); @@ -872,4 +880,9 @@ class CatalogProductVirtual extends InjectableFixture { return $this->getData('website_ids'); } + + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml index 37fb96f32497fba8bb270ecc678eb82123a00984..1a9729dd4c018de183bbd7532a6e3aaff25838eb 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml @@ -449,6 +449,12 @@ <default_value>Main Website</default_value> <group>websites</group> </website_ids> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <source>Magento\Catalog\Test\Fixture\CatalogProductVirtual\CheckoutData</source> + </checkout_data> </fields> <data_set> <sku></sku> @@ -458,6 +464,9 @@ <tax_class_id></tax_class_id> </data_set> <data_config> + <type_id> + <type>virtual</type> + </type_id> <create_url_params> <type>virtual</type> <set>4</set> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual/CheckoutData.php new file mode 100644 index 0000000000000000000000000000000000000000..fc9e2fbed900783955e8460a0bf06b3b91d14a22 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual/CheckoutData.php @@ -0,0 +1,55 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Test\Fixture\CatalogProductVirtual; + +/** + * Class CheckoutData + * Data for fill product form on frontend + * + * Data keys: + * - preset (Checkout data verification preset name) + */ +class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData +{ + /** + * Get preset array + * + * @param $name + * @return array|null + */ + protected function getPreset($name) + { + $presets = [ + '50_dollar_product' => [ + 'cartItem' => [ + 'price' => 50, + 'qty' => 1, + 'subtotal' => 50 + ] + ], + ]; + return isset($presets[$name]) ? $presets[$name] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php index daa44f210226cc50f772091fdba806218150103b..a394c45e5fab156c18f0a88fee9312040e1ca345 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php @@ -380,4 +380,14 @@ class Product extends DataFixture { return $this->getData('fields/msrp/value'); } + + /** + * Get checkout data for fill options of product + * + * @return array|null + */ + public function getCheckoutData() + { + return $this->getData('fields/checkout_data'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php index e115de5eaf6ca16e40175866209d6ea05643dbd5..73402bfe930fd486f8212d75ed65e7541fb79db4 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php @@ -59,6 +59,22 @@ class CatalogProductSimple extends AbstractRepository 'checkout_data' => ['preset' => 'order_default'], ]; + $this->_data['simple_big_qty'] = [ + 'attribute_set_id' => ['dataSet' => 'default'], + 'name' => 'Simple Product %isolation%', + 'sku' => 'sku_simple_product_%isolation%', + 'weight' => 1, + 'quantity_and_stock_status' => [ + 'qty' => 1000.0000, + 'is_in_stock' => 'In Stock', + ], + 'price' => ['value' => 560.00, 'preset' => '-'], + 'tax_class_id' => ['dataSet' => 'Taxable Goods'], + 'website_ids' => ['Main Website'], + 'visibility' => 'Catalog, Search', + 'checkout_data' => ['preset' => 'order_big_qty'], + ]; + $this->_data['100_dollar_product'] = [ 'sku' => '100_dollar_product%isolation%', 'name' => '100_dollar_product%isolation%', @@ -261,6 +277,7 @@ class CatalogProductSimple extends AbstractRepository 'price' => ['value' => 300, 'preset' => '-'], 'weight' => 1, 'custom_options' => ['preset' => 'two_options'], + 'checkout_data' => ['preset' => 'with_two_custom_option'] ]; $this->_data['with_all_custom_option'] = [ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.php index 7c43610b0d73dd3e31e08a6c22128f98a3a62d4b..5882d7f55c9c7659f795088970b1e7030c8f353a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.php @@ -56,7 +56,26 @@ class CatalogProductVirtual extends AbstractRepository 'qty' => 666.0000, 'is_in_stock' => 'In Stock', ], - 'price' => ['value' => 10.00, 'preset' => '-'] + 'price' => ['value' => 10.00, 'preset' => '-'], + 'checkout_data' => ['preset' => 'order_default'], + ]; + + $this->_data['virtual_big_qty'] = [ + 'tax_class_id' => ['dataSet' => 'Taxable Goods'], + 'status' => 'Product online', + 'website_ids' => ['Main Website'], + 'is_virtual' => 'Yes', + 'url_key' => 'virtual-product%isolation%', + 'visibility' => 'Catalog, Search', + 'attribute_set_id' => ['dataSet' => 'default'], + 'name' => 'Virtual product %isolation%', + 'sku' => 'sku_virtual_product_%isolation%', + 'quantity_and_stock_status' => [ + 'qty' => 1000.0000, + 'is_in_stock' => 'In Stock', + ], + 'price' => ['value' => 10.00, 'preset' => '-'], + 'checkout_data' => ['preset' => 'order_big_qty'], ]; $this->_data['50_dollar_product'] = [ @@ -73,7 +92,8 @@ class CatalogProductVirtual extends AbstractRepository 'qty' => 111.0000, 'is_in_stock' => 'In Stock', ], - 'price' => ['value' => 50.00, 'preset' => '-'] + 'price' => ['value' => 50.00, 'preset' => '-'], + 'checkout_data' => ['preset' => '50_dollar_product'] ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php index de826502d30a63d067371a569742d47dcdf2df40..cec15ea5a64218035be702cd2a589421ae3639f7 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php @@ -108,7 +108,7 @@ class CreateProductTest extends Functional //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); - $price = $productViewBlock->getProductPrice(); - $this->assertEquals(number_format($product->getProductPrice(), 2), $price['price_regular_price']); + $price = $productViewBlock->getPriceBlock()->getPrice(); + $this->assertEquals(number_format($product->getProductPrice(), 2), $price); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv index ea731e709c5b8aa89794b9e17ae7a93eb5a579be..bcce9e2518fcedbc7f810f79a5dc47c6e70512b4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv @@ -1,19 +1,19 @@ -"product/data/name";"product/data/sku";"product/data/tax_class_id/dataSet";"product/data/price/value";"product/data/special_price";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/qty";"product/data/quantity_and_stock_status/is_in_stock";"product/data/visibility";"product/data/custom_options/preset";"product/data/checkout_data/preset";"product/data/custom_options/import_products";"product/data/price/preset";"product/data/group_price/preset";"product/data/tier_price/preset";"constraint";"issue" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10000";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"50";"657";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23062";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10001";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"51";"658";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23063";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10002";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"52";"659";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10003";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"53";"660";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10004";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"54";"661";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10005";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"55";"662";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10006";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"56";"663";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10007";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"57";"664";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10008";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"58";"665";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductVisibleInCategory, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10009";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"59";"75";"In Stock";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInStock";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10010";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"60";"0";"Out of Stock";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductOutOfStock";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10011";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"61";"138";"-";"Search";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductSearchableBySku";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10012";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"62";"139";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductSearchableBySku, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10013";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"63";"140";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10014";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"64";"141";"-";"-";"-";"-";"-";"-";"default";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductGroupedPriceOnProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10015";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"65";"142";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductSpecialPriceOnProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"None";"10016";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"66";"143";"-";"-";"-";"-";"-";"-";"-";"default";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductTierPriceOnProductPage";"Bug: MAGETWO-26853" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10017";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"67";"144";"-";"-";"options-suite";"options-suite";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductCustomOptionsOnProductPage";"" +"product/data/name";"product/data/sku";"product/data/tax_class_id/dataSet";"product/data/price/value";"product/data/special_price";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/qty";"product/data/quantity_and_stock_status/is_in_stock";"product/data/visibility";"product/data/custom_options/preset";"product/data/checkout_data/preset";"product/data/custom_options/import_products";"product/data/price/preset";"product/data/group_price/preset";"product/data/tier_price/preset";"constraint" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10000";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"50";"657";"-";"-";"drop_down_with_one_option_fixed_price";"drop_down_with_one_option_fixed_price";"-";"drop_down_with_one_option_fixed_price";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10001";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"51";"658";"-";"-";"drop_down_with_one_option_percent_price";"drop_down_with_one_option_percent_price";"-";"drop_down_with_one_option_percent_price";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10002";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"52";"659";"-";"-";"drop_down_with_one_option_fixed_price";"drop_down_with_one_option_fixed_price";"-";"MAGETWO-23029";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10003";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"53";"660";"-";"-";"drop_down_with_one_option_percent_price";"drop_down_with_one_option_percent_price";"-";"MAGETWO-23030";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10004";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"54";"661";"-";"-";"drop_down_with_one_option_percent_price";"drop_down_with_one_option_percent_price";"-";"MAGETWO-23030";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10005";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"55";"662";"-";"-";"drop_down_with_one_option_fixed_price";"drop_down_with_one_option_fixed_price";"-";"MAGETWO-23029";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10006";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"56";"663";"-";"-";"drop_down_with_one_option_percent_price";"drop_down_with_one_option_percent_price";"-";"MAGETWO-23030";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10007";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"57";"664";"-";"-";"drop_down_with_one_option_fixed_price";"drop_down_with_one_option_fixed_price";"-";"MAGETWO-23029";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10008";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"58";"665";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductVisibleInCategory, assertProductPage" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10009";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"59";"75";"In Stock";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInStock" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10010";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"60";"0";"Out of Stock";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductOutOfStock" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10011";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"61";"138";"-";"Search";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductSearchableBySku" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10012";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"62";"139";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductSearchableBySku, assertProductPage" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10013";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"63";"140";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage" +"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10014";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"64";"141";"-";"-";"-";"-";"-";"-";"default";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductGroupedPriceOnProductPage" +"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10015";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"65";"142";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductSpecialPriceOnProductPage" +"Simple Product %isolation%";"simple_sku_%isolation%";"None";"10016";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"66";"143";"-";"-";"-";"-";"-";"-";"-";"default";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductTierPriceOnProductPage" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10017";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"67";"144";"-";"-";"options-suite";"options-suite";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductCustomOptionsOnProductPage" diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php index cd9e03f0bc6fdbfb2927137548f589e2aab6e1e8..46941390782dd5393f9ce817fa7082524be3dd7b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php @@ -123,7 +123,7 @@ class CreateSimpleWithCategoryTest extends Functional $productViewBlock = $productPage->getViewBlock(); $productListBlock->openProductViewPage($product->getName()); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); - $price = $productViewBlock->getProductPrice(); - $this->assertEquals(number_format($product->getProductPrice(), 2), $price['price_regular_price']); + $price = $productViewBlock->getPriceBlock()->getPrice(); + $this->assertEquals(number_format($product->getProductPrice(), 2), $price); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php index 9ec55181111651c0a29c2f695c27d05680c6fd52..3a5ff5ba818be6c290ed346b82ddef2e6ac1a632 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php @@ -113,8 +113,8 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); - $price = $productViewBlock->getProductPrice(); - $this->assertEquals(number_format($product->getProductPrice(), 2), $price['price_regular_price']); + $price = $productViewBlock->getPriceBlock()->getPrice(); + $this->assertEquals(number_format($product->getProductPrice(), 2), $price); $productOptionsBlock = $productPage->getViewBlock()->getCustomOptionsBlock(); $fixture = $product->getData('fields/custom_options/value'); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php index 3af413238f310c887153bbd9d0ac5cc9c63aa173..8201bf4935bbf5b1678da50f700d037ef2f8e1e2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php @@ -113,7 +113,7 @@ class CreateTest extends Functional //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); - $price = $productViewBlock->getProductPrice(); - $this->assertEquals(number_format($product->getProductPrice(), 2), $price['price_regular_price']); + $price = $productViewBlock->getPriceBlock()->getPrice(); + $this->assertEquals(number_format($product->getProductPrice(), 2), $price); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php index 1c85047b1ee25100ea29e6f946962b0d80ddc332..49e46187a420fe9636619daccca1a4291e924433 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php @@ -110,7 +110,7 @@ class CreateVirtualTest extends Functional $productPage = Factory::getPageFactory()->getCatalogProductView(); $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); - $price = $productViewBlock->getProductPrice(); - $this->assertEquals(number_format($product->getProductPrice(), 2), $price['price_regular_price']); + $price = $productViewBlock->getPriceBlock()->getPrice(); + $this->assertEquals(number_format($product->getProductPrice(), 2), $price); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php index b2fd0411a4312f80d37ab42133f692265ed1e8b0..edcfd32bd1a77eadee14dfaf40a12197d8350ebf 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php @@ -24,7 +24,6 @@ namespace Magento\Catalog\Test\TestCase\Product; -use Mtf\Client\Browser; use Mtf\Factory\Factory; use Mtf\TestCase\Functional; use Magento\Catalog\Test\Fixture\SimpleProduct; @@ -128,7 +127,7 @@ class EditSimpleProductTest extends Functional $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($productEdited->getName(), $productViewBlock->getProductName()); - $price = $productViewBlock->getProductPrice(); - $this->assertEquals(number_format($productEdited->getProductPrice(), 2), $price['price_regular_price']); + $price = $productViewBlock->getPriceBlock()->getPrice(); + $this->assertEquals(number_format($productEdited->getProductPrice(), 2), $price); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php index 90f488e4163275e8006864ddc2852ba1a655de0a..5608bd54009a22a93272ce0df156dacfaf94cf6c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php @@ -61,7 +61,6 @@ class CreateProductAttributeEntityTest extends Injectable CatalogProductAttributeNew $attributeNew, CatalogAttributeSet $productTemplate ) { - $this->markTestIncomplete('MAGETWO-27282'); //Precondition $productTemplate->persist(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php index 601cec2327ffb9327c8d66ccda6c703b840fb06e..64ad6372552f33f1490a2316b38e14b7d5affdb9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php @@ -90,7 +90,7 @@ class DeleteUsedInConfigurableProductAttributeTest extends Injectable $product->persist(); /** @var CatalogProductAttribute $attribute */ $attribute = $product->getDataFieldConfig('configurable_attributes_data')['source'] - ->getAttributes()['attribute_0']; + ->getAttributes()['attribute_key_0']; // Steps $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen(['attribute_code' => $attribute->getAttributeCode()]); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php index c3f616e28986a88b070926655758c2e826371c38..5b449eaf42e9aef8a4b0e3812d59ae93890e7b9f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php @@ -69,7 +69,6 @@ class UpdateProductAttributeEntityTest extends Injectable CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew ) { - $this->markTestIncomplete('MAGETWO-27282'); //Precondition $productTemplate->persist(); $productAttributeOriginal->persist(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml index 42c47d2b968c7c5265888d0f985515dbcdcfc61b..9a9ffe91bc4d320c3c383ac3e292d17fe3d11c6c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml @@ -94,41 +94,6 @@ <input_prefix>product</input_prefix> </data_config> </catalogProductVirtual> - <catalogProductGrouped module="Magento_Catalog"> - <type>eav</type> - <entity_type>catalog_product</entity_type> - <product_type>grouped</product_type> - <collection>Magento\Catalog\Model\Resource\Product\Collection</collection> - <identifier>sku</identifier> - <fields> - <id> - <attribute_code>id</attribute_code> - <backend_type>virtual</backend_type> - </id> - <type_id> - <attribute_code>type_id</attribute_code> - <backend_type>virtual</backend_type> - </type_id> - <attribute_set_id> - <attribute_code>attribute_set_id</attribute_code> - <backend_type>virtual</backend_type> - </attribute_set_id> - </fields> - <data_set> - <sku /> - <name /> - <short_description /> - <description /> - <tax_class_id /> - </data_set> - <data_config> - <create_url_params> - <type>grouped</type> - <set>4</set> - </create_url_params> - <input_prefix>product</input_prefix> - </data_config> - </catalogProductGrouped> <catalogCategory module="Magento_Catalog"> <type>flat</type> <entity_type>catalog_category_entity</entity_type> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php index 22278d1c4aa259c8da4e0d30302f61f095884249..58594105029499b1e62f3131f6d259a61b2976a3 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php @@ -75,14 +75,24 @@ class Cart extends Block */ public function getCartItem(FixtureInterface $product) { - $cartItem = $this->_rootElement->find( - sprintf($this->cartItemByProductName, $product->getName()), - Locator::SELECTOR_XPATH - ); - return $this->blockFactory->create( - 'Magento\Checkout\Test\Block\Cart\CartItem', - ['element' => $cartItem] - ); + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + $cartItem = null; + + if ($this->hasRender($typeId)) { + $cartItem = $this->callRender($typeId, 'getCartItem', ['product' => $product]); + } else { + $cartItemBlock = $this->_rootElement->find( + sprintf($this->cartItemByProductName, $product->getName()), + Locator::SELECTOR_XPATH + ); + $cartItem = $this->blockFactory->create( + 'Magento\Checkout\Test\Block\Cart\CartItem', + ['element' => $cartItemBlock] + ); + } + + return $cartItem; } /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/AbstractCartItem.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/AbstractCartItem.php new file mode 100644 index 0000000000000000000000000000000000000000..cd01d802c509e632b4edcac6472493cae9b2a407 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/AbstractCartItem.php @@ -0,0 +1,81 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Test\Block\Cart; + +use Mtf\Block\Block; + +/** + * Class AbstractCartItem + * Base product item block on checkout page + */ +class AbstractCartItem extends Block +{ + /** + * Selector for product name + * + * @var string + */ + protected $productName = '.product-item-name > a'; + + /** + * Selector for unit price + * + * @var string + */ + protected $price = './/td[@class="col price"]/*[@class="excl tax"]/span'; + + /** + * Quantity input selector + * + * @var string + */ + protected $qty = './/input[@type="number" and @title="Qty"]'; + + /** + * Cart item sub-total xpath selector + * + * @var string + */ + protected $subtotalPrice = './/td[@class="col subtotal"]//*[@class="excl tax"]//span[@class="price"]'; + + /** + * Selector for options block + * + * @var string + */ + protected $optionsBlock = './/dl[@class="cart-item-options"]'; + + /** + * Escape currency in price + * + * @param string $price + * @return string|null + */ + protected function escapeCurrency($price) + { + preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); + return (isset($matches[1])) ? $matches[1] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php index 6e5090d9e726b72aa1ade6adaa6a839b050c764e..e26787694f4506bc58afe524d3865a96e81419aa 100755 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php @@ -24,49 +24,30 @@ namespace Magento\Checkout\Test\Block\Cart; -use Mtf\Block\Block; use Mtf\Client\Element\Locator; /** * Class CartItem * Product item block on checkout page */ -class CartItem extends Block +class CartItem extends AbstractCartItem { /** - * Selector for options block - * - * @var string - */ - protected $optionsBlock = './/dl[@class="cart-item-options"]'; - - /** - * Selector for unit price - * - * @var string - */ - protected $price = './/td[@class="col price"]/*[@class="excl tax"]/span'; - - /** - * Quantity input selector - * - * @var string - */ - protected $qty = './/input[@type="number" and @title="Qty"]'; - - /** - * Cart item sub-total xpath selector + * Get bundle options * * @var string */ - protected $subtotalPrice = './/td[@class="col subtotal"]//*[@class="excl tax"]//span[@class="price"]'; + protected $bundleOptions = './/dl[contains(@class, "cart-item-options")]/dd[%d]/span[@class="price"][%d]'; /** - * Get bundle options + * Get product name * - * @var string + * @return string */ - protected $bundleOptions = './/dl[contains(@class, "cart-item-options")]/dd[%d]/span[@class="price"][%d]'; + protected function getProductName() + { + $this->_rootElement->find($this->productName)->getText(); + } /** * Get product price @@ -76,7 +57,7 @@ class CartItem extends Block public function getPrice() { $cartProductPrice = $this->_rootElement->find($this->price, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($cartProductPrice); + return str_replace(',', '', $this->escapeCurrency($cartProductPrice)); } /** @@ -108,19 +89,7 @@ class CartItem extends Block public function getSubtotalPrice() { $price = $this->_rootElement->find($this->subtotalPrice, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($price); - } - - /** - * Method that escapes currency symbols - * - * @param string $price - * @return string - */ - protected function escapeCurrency($price) - { - preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); - return (isset($matches[1])) ? $matches[1] : null; + return str_replace(',', '', $this->escapeCurrency($price)); } /** @@ -131,10 +100,22 @@ class CartItem extends Block public function getOptions() { $optionsBlock = $this->_rootElement->find($this->optionsBlock, Locator::SELECTOR_XPATH); - if (!$optionsBlock->isVisible()) { - return ''; + $options = []; + + if ($optionsBlock->isVisible()) { + $titles = $optionsBlock->find('./dt', Locator::SELECTOR_XPATH)->getElements(); + $values = $optionsBlock->find('./dd', Locator::SELECTOR_XPATH)->getElements(); + + foreach ($titles as $key => $title) { + $value = $values[$key]->getText(); + $options[] = [ + 'title' => $title->getText(), + 'value' => $this->escapeCurrencyForOption($value) + ]; + } } - return $optionsBlock->getText(); + + return $options; } /** @@ -178,4 +159,15 @@ class CartItem extends Block $formatPrice = sprintf($this->bundleOptions, $index, $itemIndex); return trim($this->_rootElement->find($formatPrice, Locator::SELECTOR_XPATH)->getText(), $currency); } + + /** + * Escape currency in option label + * + * @param string $label + * @return string + */ + protected function escapeCurrencyForOption($label) + { + return preg_replace('/^(\d+) x (\w+) \W([\d\.,]+)$/', '$1 x $2 $3', $label); + } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCartItemsOptions.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCartItemsOptions.php new file mode 100644 index 0000000000000000000000000000000000000000..f8406a32c9f20f18d3f5fb2018ee99a4223208e5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCartItemsOptions.php @@ -0,0 +1,158 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Test\Constraint; + +use Mtf\Constraint\AbstractAssertForm; +use Magento\Checkout\Test\Page\CheckoutCart; +use Mtf\Fixture\FixtureInterface; +use Magento\Checkout\Test\Fixture\Cart; +use Magento\Checkout\Test\Fixture\Cart\Items; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; + +/** + * Class AssertCartItemsOptions + * Assert that cart item options for product(s) display with correct information block + * + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ +class AssertCartItemsOptions extends AbstractAssertForm +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that cart item options for product(s) display with correct information block + * (custom options, variations, links, samples, bundle items etc) according to passed from dataSet + * + * @param CheckoutCart $checkoutCart + * @param Cart $cart + * @return void + */ + public function processAssert( + CheckoutCart $checkoutCart, + Cart $cart + ) { + $checkoutCart->open(); + /** @var Items $sourceProducts */ + $sourceProducts = $cart->getDataFieldConfig('items')['source']; + $products = $sourceProducts->getProducts(); + $items = $cart->getItems(); + $productsData = []; + $cartData = []; + + foreach ($items as $key => $item) { + /** @var CatalogProductSimple $product */ + $product = $products[$key]; + $productName = $product->getName(); + /** @var FixtureInterface $item */ + $checkoutItem = $item->getData(); + $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); + + $productsData[$productName] = [ + 'options' => $this->sortDataByPath($checkoutItem['options'], '::title') + ]; + $cartData[$productName] = [ + 'options' => $this->sortDataByPath($cartItem->getOptions(), '::title') + ]; + } + + $error = $this->verifyContainsData($productsData, $cartData, true); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); + } + + /** + * Verify form data contains in fixture data + * + * @param array $fixtureData + * @param array $formData + * @param bool $isStrict [optional] + * @param bool $isPrepareError [optional] + * @return array|string + */ + protected function verifyContainsData( + array $fixtureData, + array $formData, + $isStrict = false, + $isPrepareError = true + ) { + $errors = []; + + foreach ($fixtureData as $key => $value) { + if (in_array($key, $this->skippedFields)) { + continue; + } + + $formValue = isset($formData[$key]) ? $formData[$key] : null; + if (!is_array($formValue)) { + $formValue = trim($formValue, '. '); + } + + if (null === $formValue) { + $errors[] = '- field "' . $key . '" is absent in form'; + } elseif (is_array($value) && is_array($formValue)) { + $valueErrors = $this->verifyContainsData($value, $formValue, true, false); + if (!empty($valueErrors)) { + $errors[$key] = $valueErrors; + } + } elseif (null === strpos($value, $formValue)) { + if (is_array($value)) { + $value = $this->arrayToString($value); + } + if (is_array($formValue)) { + $formValue = $this->arrayToString($formValue); + } + $errors[] = sprintf('- %s: "%s" instead of "%s"', $key, $formValue, $value); + } + } + + if ($isStrict) { + $diffData = array_diff(array_keys($formData), array_keys($fixtureData)); + if ($diffData) { + $errors[] = '- fields ' . implode(', ', $diffData) . ' is absent in fixture'; + } + } + + if ($isPrepareError) { + return $this->prepareErrors($errors); + } + return $errors; + } + + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Product options on the page match.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertGrandTotalInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertGrandTotalInShoppingCart.php new file mode 100644 index 0000000000000000000000000000000000000000..2578824cf428aab024cf405592a5db25c7cbf412 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertGrandTotalInShoppingCart.php @@ -0,0 +1,74 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Test\Constraint; + +use Magento\Checkout\Test\Page\CheckoutCart; +use Mtf\Constraint\AbstractConstraint; +use Magento\Checkout\Test\Fixture\Cart; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; + +/** + * Class AssertGrandTotalInShoppingCart + * Assert that grand total is equal to expected + */ +class AssertGrandTotalInShoppingCart extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that grand total is equal to expected + * + * @param CheckoutCart $checkoutCart + * @param Cart $cart + * @return void + */ + public function processAssert(CheckoutCart $checkoutCart, Cart $cart) + { + $checkoutCart->open(); + + $fixtureGrandTotal = number_format($cart->getGrandTotal(), 2); + $pageGrandTotal = $checkoutCart->getTotalsBlock()->getGrandTotal(); + \PHPUnit_Framework_Assert::assertEquals( + $fixtureGrandTotal, + $pageGrandTotal, + 'Grand total price in the shopping cart not equals to grand total price from fixture.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Grand total price in the shopping cart equals to expected grand total price from data set.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php index 4dedaae48d82299ec614a9bac557e28504117a02..4e8518a896ea0774282a082fe37850e4511356ca 100755 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php @@ -24,15 +24,18 @@ namespace Magento\Checkout\Test\Constraint; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Checkout\Test\Page\CheckoutCart; +use Mtf\Fixture\FixtureInterface; use Magento\Checkout\Test\Fixture\Cart; +use Magento\Checkout\Test\Fixture\Cart\Items; use Magento\Catalog\Test\Fixture\CatalogProductSimple; /** * Class AssertPriceInShoppingCart + * Assert that price in the shopping cart equals to expected price from data set */ -class AssertPriceInShoppingCart extends AbstractConstraint +class AssertPriceInShoppingCart extends AbstractAssertForm { /** * Constraint severeness @@ -46,22 +49,36 @@ class AssertPriceInShoppingCart extends AbstractConstraint * * @param CheckoutCart $checkoutCart * @param Cart $cart - * @param CatalogProductSimple $product * @return void */ - public function processAssert( - CheckoutCart $checkoutCart, - Cart $cart, - CatalogProductSimple $product - ) { + public function processAssert(CheckoutCart $checkoutCart, Cart $cart) + { $checkoutCart->open(); - $cartProductPrice = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $cartProductPrice, - $cart->getPrice(), - 'Shopping cart product price: \'' . $cartProductPrice - . '\' not equals with price from data set: \'' . $cart->getPrice() . '\'' - ); + /** @var Items $sourceProducts */ + $sourceProducts = $cart->getDataFieldConfig('items')['source']; + $products = $sourceProducts->getProducts(); + $items = $cart->getItems(); + $productsData = []; + $cartData = []; + + foreach ($items as $key => $item) { + /** @var CatalogProductSimple $product */ + $product = $products[$key]; + $productName = $product->getName(); + /** @var FixtureInterface $item */ + $checkoutItem = $item->getData(); + $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); + + $productsData[$productName] = [ + 'price' => $checkoutItem['price'] + ]; + $cartData[$productName] = [ + 'price' => $cartItem->getPrice() + ]; + } + + $error = $this->verifyData($productsData, $cartData, true); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); } /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php index a2c800226f26c8a8ab9624fd94ad00e939602a85..690367d7954abca9f303e60e097ce93cda26b6c7 100755 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php @@ -24,15 +24,18 @@ namespace Magento\Checkout\Test\Constraint; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Checkout\Test\Page\CheckoutCart; +use Mtf\Fixture\FixtureInterface; use Magento\Checkout\Test\Fixture\Cart; +use Magento\Checkout\Test\Fixture\Cart\Items; use Magento\Catalog\Test\Fixture\CatalogProductSimple; /** * Class AssertProductQtyInShoppingCart + * Assert that quantity in the shopping cart is equals to expected quantity from data set */ -class AssertProductQtyInShoppingCart extends AbstractConstraint +class AssertProductQtyInShoppingCart extends AbstractAssertForm { /** * Constraint severeness @@ -46,22 +49,38 @@ class AssertProductQtyInShoppingCart extends AbstractConstraint * * @param CheckoutCart $checkoutCart * @param Cart $cart - * @param CatalogProductSimple $product * @return void */ public function processAssert( CheckoutCart $checkoutCart, - Cart $cart, - CatalogProductSimple $product + Cart $cart ) { $checkoutCart->open(); - $cartProductQty = $checkoutCart->getCartBlock()->getCartItem($product)->getQty(); - \PHPUnit_Framework_Assert::assertEquals( - $cartProductQty, - $cart->getQty(), - 'Shopping cart product qty: \'' . $cartProductQty - . '\' not equals with qty from data set: \'' . $cart->getQty() . '\'' - ); + /** @var Items $sourceProducts */ + $sourceProducts = $cart->getDataFieldConfig('items')['source']; + $products = $sourceProducts->getProducts(); + $items = $cart->getItems(); + $productsData = []; + $cartData = []; + + foreach ($items as $key => $item) { + /** @var CatalogProductSimple $product */ + $product = $products[$key]; + $productName = $product->getName(); + /** @var FixtureInterface $item */ + $checkoutItem = $item->getData(); + $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); + + $productsData[$productName] = [ + 'qty' => $checkoutItem['qty'] + ]; + $cartData[$productName] = [ + 'qty' => $cartItem->getQty() + ]; + } + + $error = $this->verifyData($productsData, $cartData, true); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); } /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php index ceb3b5f45f13908cf38c7ae4c5bd2d16523335ee..c7f09f32a8d83dd182612e47370a0a0618bee2bc 100755 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php @@ -24,15 +24,18 @@ namespace Magento\Checkout\Test\Constraint; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Checkout\Test\Page\CheckoutCart; +use Mtf\Fixture\FixtureInterface; use Magento\Checkout\Test\Fixture\Cart; +use Magento\Checkout\Test\Fixture\Cart\Items; use Magento\Catalog\Test\Fixture\CatalogProductSimple; /** * Class AssertSubtotalInShoppingCart + * Assert that subtotal total in the shopping cart is equals to expected total from data set */ -class AssertSubtotalInShoppingCart extends AbstractConstraint +class AssertSubtotalInShoppingCart extends AbstractAssertForm { /** * Constraint severeness @@ -46,22 +49,36 @@ class AssertSubtotalInShoppingCart extends AbstractConstraint * * @param CheckoutCart $checkoutCart * @param Cart $cart - * @param CatalogProductSimple $product * @return void */ - public function processAssert( - CheckoutCart $checkoutCart, - Cart $cart, - CatalogProductSimple $product - ) { + public function processAssert(CheckoutCart $checkoutCart, Cart $cart) + { $checkoutCart->open(); - $cartProductSubtotal = $checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $cartProductSubtotal, - $cart->getRowTotal(), - 'Shopping cart subtotal: \'' . $cartProductSubtotal - . '\' not equals with total from data set: \'' . $cart->getRowTotal() . '\'' - ); + /** @var Items $sourceProducts */ + $sourceProducts = $cart->getDataFieldConfig('items')['source']; + $products = $sourceProducts->getProducts(); + $items = $cart->getItems(); + $productsData = []; + $cartData = []; + + foreach ($items as $key => $item) { + /** @var CatalogProductSimple $product */ + $product = $products[$key]; + $productName = $product->getName(); + /** @var FixtureInterface $item */ + $checkoutItem = $item->getData(); + $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); + + $productsData[$productName] = [ + 'subtotal' => $checkoutItem['subtotal'] + ]; + $cartData[$productName] = [ + 'subtotal' => $cartItem->getSubtotalPrice() + ]; + } + + $error = $this->verifyData($productsData, $cartData, true); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); } /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/constraint.xml index 2af8b2a431b36c8503d2224e7774bfa2909d23bf..876ef16b5395df1e7acc7ddec558970015267882 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/constraint.xml @@ -42,4 +42,10 @@ <assertOrderTotalOnReviewPage module="Magento_Checkout"> <severeness>low</severeness> </assertOrderTotalOnReviewPage> + <assertGrandTotalInShoppingCart module="Magento_Checkout"> + <severeness>low</severeness> + </assertGrandTotalInShoppingCart> + <assertCartItemsOptions module="Magento_Checkout"> + <severeness>low</severeness> + </assertCartItemsOptions> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/fixture.xml index e9d8be3cb2647492c57ee1800402a6fbbcbc2a2e..a1a7c4ff0e0e2d983ff08927fc10d68c7d94829e 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/fixture.xml @@ -26,7 +26,7 @@ <fixture> <cart module="Magento_Checkout"> <type>flat</type> - <entity_type>sales_flat_quote_item</entity_type> + <entity_type>sales_flat_quote</entity_type> <collection>Magento\Checkout\Model\Resource\Cart</collection> </cart> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php index 4cf100c22af86b15c746698f63623933224ab766..5bf477679b26fcfab9819ddfe1c6080f5d9860d6 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php @@ -75,7 +75,9 @@ class View extends \Magento\Catalog\Test\Block\Product\View 'title' => $option['label'] ]; } + $attributesData[$attributeKey]['options'] = array_values($attributesData[$attributeKey]['options']); } + $attributesData = array_values($attributesData); } else { // TODO: Removed after refactoring(removed) old product fixture. /** @var ConfigurableProduct $product */ @@ -98,8 +100,8 @@ class View extends \Magento\Catalog\Test\Block\Product\View } } - $configurableCheckoutData = isset($checkoutData['configurable_options']) - ? $checkoutData['configurable_options'] + $configurableCheckoutData = isset($checkoutData['options']['configurable_options']) + ? $checkoutData['options']['configurable_options'] : []; $checkoutOptionsData = $this->prepareCheckoutData($attributesData, $configurableCheckoutData); $this->getCustomOptionsBlock()->fillCustomOptions($checkoutOptionsData); diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php index 16fe173d132e04859a05c45896674c5beb0c7b6c..805983a2436f08962457070ded342d0f05cf016d 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php @@ -27,7 +27,9 @@ namespace Magento\ConfigurableProduct\Test\Block\Product\View; use Mtf\Client\Element; use Mtf\Client\Element\Locator; use Magento\Catalog\Test\Block\Product\View\CustomOptions; +use Mtf\Fixture\InjectableFixture; use Mtf\Fixture\FixtureInterface; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; /** @@ -45,10 +47,22 @@ class ConfigurableOptions extends CustomOptions */ public function getOptions(FixtureInterface $product) { - /** @var ConfigurableProductInjectable $product */ - $attributesData = $product->hasData('configurable_attributes_data') - ? $product->getConfigurableAttributesData()['attributes_data'] - : []; + if ($product instanceof InjectableFixture) { + /** @var ConfigurableProductInjectable $product */ + $attributesData = $product->hasData('configurable_attributes_data') + ? $product->getConfigurableAttributesData()['attributes_data'] + : []; + } else { + /** @var ConfigurableProduct $product */ + $attributesData = $product->getConfigurableAttributes(); + foreach ($attributesData as $key => $attributeData) { + $attributeData['label'] = $attributeData['label']['value']; + $attributeData['frontend_input'] = 'dropdown'; + + $attributesData[$key] = $attributeData; + } + } + $listOptions = $this->getListOptions(); $result = []; diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php index 1db4f952d80276ac023be3272941a3982661e2e7..cd507b550ae6fcaebab6ae1e4144845dbdeca50d 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php @@ -61,6 +61,7 @@ class AssertConfigurableProductForm extends AssertProductForm * @var array */ protected $skippedOptionFields = [ + 'admin', 'id', 'is_default', ]; @@ -89,6 +90,9 @@ class AssertConfigurableProductForm extends AssertProductForm $attributeData = $data['configurable_attributes_data']['attributes_data']; foreach ($attributeData as $attributeKey => $attribute) { foreach ($attribute['options'] as $optionKey => $option) { + if (isset($option['admin'])) { + $option['label'] = $option['admin']; + } $attribute['options'][$optionKey] = array_diff_key($option, array_flip($this->skippedOptionFields)); } $attribute['options'] = $this->sortDataByPath($attribute['options'], '::label'); diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php index 95241dc236b6a62cf22cf11e27b256045cde794d..582d8295a4ff0526028c342842327023d4f02b3d 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php @@ -59,7 +59,7 @@ class AssertConfigurableProductInCart extends AbstractConstraint $checkoutData = $product->getCheckoutData(); $price = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); \PHPUnit_Framework_Assert::assertEquals( - $checkoutData['checkoutItemForm']['price'], + $checkoutData['cartItem']['price'], $price, 'Product price in shopping cart is not correct.' ); diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..2cb4596273bd1320bc65365a310c33f3997bc6e2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php @@ -0,0 +1,110 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Fixture\Cart; + +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; +use Mtf\Fixture\FixtureInterface; +use Magento\Bundle\Test\Fixture\BundleProduct; + +/** + * Class Item + * Data for verify cart item block on checkout page + * + * Data keys: + * - product (fixture data for verify) + * + * @SuppressWarnings(PHPMD.NPathComplexity) + */ +class Item extends \Magento\Catalog\Test\Fixture\Cart\Item +{ + /** + * @constructor + * @param FixtureInterface $product + */ + public function __construct(FixtureInterface $product) + { + parent::__construct($product); + + /** @var ConfigurableProductInjectable $product */ + $checkoutData = $product->getCheckoutData(); + $cartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : []; + $attributesData = $product->getConfigurableAttributesData()['attributes_data']; + $checkoutConfigurableOptions = isset($checkoutData['options']['configurable_options']) + ? $checkoutData['options']['configurable_options'] + : []; + + foreach ($checkoutConfigurableOptions as $key => $checkoutConfigurableOption) { + $attribute = $checkoutConfigurableOption['title']; + $option = $checkoutConfigurableOption['value']; + + $checkoutConfigurableOptions[$key] = [ + 'title' => isset($attributesData[$attribute]['label']) + ? $attributesData[$attribute]['label'] + : $attribute, + 'value' => isset($attributesData[$attribute]['options'][$option]['label']) + ? $attributesData[$attribute]['options'][$option]['label'] + : $option + ]; + } + + $cartItem['options'] = isset($cartItem['options']) + ? $cartItem['options'] + $checkoutConfigurableOptions + : $checkoutConfigurableOptions; + $this->data = $cartItem; + } + + /** + * Persist fixture + * + * @return void + */ + public function persist() + { + // + } + + /** + * Return prepared data set + * + * @param string $key [optional] + * @return mixed + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getData($key = null) + { + return $this->data; + } + + /** + * Return data set configuration settings + * + * @return string + */ + public function getDataConfig() + { + // + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php index fbc37084773eff0dbd2847c296d64de670b5e307..b976e61aa25130a1886e42cbe30b5b17d45075a5 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php @@ -24,10 +24,10 @@ namespace Magento\ConfigurableProduct\Test\Fixture; -use Magento\Catalog\Test\Fixture\ProductAttribute; use Mtf\System\Config; use Mtf\Factory\Factory; use Magento\Catalog\Test\Fixture\Product; +use Magento\Catalog\Test\Fixture\ProductAttribute; use Magento\ConfigurableProduct\Test\Repository\ConfigurableProduct as Repository; /** @@ -338,11 +338,14 @@ class ConfigurableProduct extends Product ], ], 'checkout_data' => [ - 'configurable_options' => [ - [ - 'title' => '0', - 'value' => '0' - ] + 'options' => [ + 'configurable_options' => [ + [ + 'title' => '0', + 'value' => '0' + ] + ], + 'qty' => 1 ], 'special_price' => '10' ] @@ -383,7 +386,7 @@ class ConfigurableProduct extends Product public function getProductOptionsPrice() { $price = 0; - $configurableOptions = $this->getData('checkout_data/configurable_options'); + $configurableOptions = $this->getData('checkout_data/options/configurable_options'); $attributes = $this->getData('fields/configurable_attributes_data/value'); foreach ($configurableOptions as $option) { diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php index f586878dd952734b8395805bc8575a4f9df3b5aa..6ee26d3486c65b5dc91bd0554cc3e08c6d803c84 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php @@ -43,62 +43,74 @@ class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\Ch { $presets = [ 'default' => [ - 'configurable_options' => [ - [ - 'title' => 'attribute_0', - 'value' => 'option_0', + 'options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0', + ], + [ + 'title' => 'attribute_key_1', + 'value' => 'option_key_1', + ] ], - [ - 'title' => 'attribute_1', - 'value' => 'option_0', - ] - ], - 'checkoutItemForm' => [ - 'price' => 101, + 'qty' => 3 ], - 'qty' => 1 + 'cartItem' => [ + 'price' => 172, + 'qty' => 3, + 'subtotal' => 516 + ] ], 'two_options' => [ - 'configurable_options' => [ - [ - 'title' => 'attribute_0', - 'value' => 'option_0', + 'options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0', + ] ] ], - 'checkoutItemForm' => [ + 'cartItem' => [ 'price' => 101, ] ], 'two_new_options' => [ - 'configurable_options' => [ - [ - 'title' => 'attribute_0', - 'value' => 'option_1', + 'options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_1', + ] ] ], - 'checkoutItemForm' => [ + 'cartItem' => [ 'price' => 102, ] ], 'two_new_options_with_special_price' =>[ - 'configurable_options' => [ - [ - 'title' => 'attribute_0', - 'value' => 'option_1', + 'options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_1', + ] ] ], - 'checkoutItemForm' => [ + 'cartItem' => [ 'price' => 12, ] ], 'two_options_with_assigned_product' => [ - 'configurable_options' => [ - [ - 'title' => 'attribute_0', - 'value' => 'option_0', + 'options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0', + ] ] ], - 'checkoutItemForm' => [ + 'cartItem' => [ 'price' => 101, ] ], diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php index 7109b845623b41daacdc78e313411ccca24ff653..819c239687c8f78e96570d82a00336eb2969474f 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php @@ -93,38 +93,38 @@ class ConfigurableAttributesData implements FixtureInterface protected $presets = [ 'default' => [ 'attributes_data' => [ - 'attribute_0' => [ + 'attribute_key_0' => [ 'options' => [ - 'option_0' => [ + 'option_key_0' => [ 'pricing_value' => 12.00, 'include' => 'Yes', 'is_percent' => 'No' ], - 'option_1' => [ + 'option_key_1' => [ 'pricing_value' => 20.00, 'include' => 'Yes', 'is_percent' => 'No' ], - 'option_2' => [ + 'option_key_2' => [ 'pricing_value' => 18.00, 'include' => 'Yes', 'is_percent' => 'No' ], ] ], - 'attribute_1' => [ + 'attribute_key_1' => [ 'options' => [ - 'option_0' => [ + 'option_key_0' => [ 'pricing_value' => 42.00, 'include' => 'Yes', 'is_percent' => 'No' ], - 'option_1' => [ + 'option_key_1' => [ 'pricing_value' => 40.00, 'include' => 'Yes', 'is_percent' => 'No' ], - 'option_2' => [ + 'option_key_2' => [ 'pricing_value' => 48.00, 'include' => 'Yes', 'is_percent' => 'No' @@ -136,59 +136,59 @@ class ConfigurableAttributesData implements FixtureInterface ], 'attributes' => [ - 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown', - 'attribute_1' => 'catalogProductAttribute::attribute_type_dropdown' + 'attribute_key_0' => 'catalogProductAttribute::attribute_type_dropdown', + 'attribute_key_1' => 'catalogProductAttribute::attribute_type_dropdown' ], 'matrix' => [ - 'attribute_0:option_0 attribute_1:option_0' => [ + 'attribute_key_0:option_key_0 attribute_key_1:option_key_0' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_0 attribute_1:option_1' => [ + 'attribute_key_0:option_key_0 attribute_key_1:option_key_1' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_0 attribute_1:option_2' => [ + 'attribute_key_0:option_key_0 attribute_key_1:option_key_2' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_1 attribute_1:option_0' => [ + 'attribute_key_0:option_key_1 attribute_key_1:option_key_0' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_1 attribute_1:option_1' => [ + 'attribute_key_0:option_key_1 attribute_key_1:option_key_1' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_1 attribute_1:option_2' => [ + 'attribute_key_0:option_key_1 attribute_key_1:option_key_2' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_2 attribute_1:option_0' => [ + 'attribute_key_0:option_key_2 attribute_key_1:option_key_0' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_2 attribute_1:option_1' => [ + 'attribute_key_0:option_key_2 attribute_key_1:option_key_1' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_2 attribute_1:option_2' => [ + 'attribute_key_0:option_key_2 attribute_key_1:option_key_2' => [ 'quantity_and_stock_status' => [ 'qty' => 10 ], @@ -198,9 +198,9 @@ class ConfigurableAttributesData implements FixtureInterface ], 'one_variation' => [ 'attributes_data' => [ - 'attribute_0' => [ + 'attribute_key_0' => [ 'options' => [ - 'option_0' => [ + 'option_key_0' => [ 'pricing_value' => 12.00, 'include' => 'Yes', 'is_percent' => 'No' @@ -208,32 +208,31 @@ class ConfigurableAttributesData implements FixtureInterface ] ] ], - 'products' => [ - - ], + 'products' => [], 'attributes' => [ - 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_one_option' + 'attribute_key_0' => 'catalogProductAttribute::attribute_type_dropdown_one_option' ], 'matrix' => [ - 'attribute_0:option_0' => [ + 'attribute_key_0:option_key_0' => [ + 'display' => 'Yes', 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 - ], + ] ] ], 'two_options' => [ 'attributes_data' => [ - 'attribute_0' => [ + 'attribute_key_0' => [ 'options' => [ - 'option_0' => [ + 'option_key_0' => [ 'label' => 'option_1_%isolation%', 'pricing_value' => 1, 'is_percent' => 'Yes', 'include' => 'Yes' ], - 'option_1' => [ + 'option_key_1' => [ 'label' => 'option_2_%isolation%', 'pricing_value' => 2, 'is_percent' => 'Yes', @@ -243,18 +242,18 @@ class ConfigurableAttributesData implements FixtureInterface ] ], 'attributes' => [ - 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_two_options', + 'attribute_key_0' => 'catalogProductAttribute::attribute_type_dropdown_two_options', ], 'products' => [], 'matrix' => [ - 'attribute_0:option_0' => [ + 'attribute_key_0:option_key_0' => [ 'display' => 'Yes', 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_1' => [ + 'attribute_key_0:option_key_1' => [ 'display' => 'Yes', 'quantity_and_stock_status' => [ 'qty' => 20 @@ -265,20 +264,20 @@ class ConfigurableAttributesData implements FixtureInterface ], 'two_new_options' => [ 'attributes_data' => [ - 'attribute_0' => [ + 'attribute_key_0' => [ 'frontend_label' => 'two_new_options_title_%isolation%', 'frontend_input' => 'Dropdown', 'label' => 'two_new_options_title_%isolation%', 'is_required' => 'No', 'options' => [ - 'option_0' => [ - 'label' => 'option_1_%isolation%', + 'option_key_0' => [ + 'label' => 'option_key_1_%isolation%', 'pricing_value' => 1, 'is_percent' => 'No', 'include' => 'Yes' ], - 'option_1' => [ - 'label' => 'option_2_%isolation%', + 'option_key_1' => [ + 'label' => 'option_key_2_%isolation%', 'pricing_value' => 2, 'is_percent' => 'No', 'include' => 'Yes', @@ -289,14 +288,14 @@ class ConfigurableAttributesData implements FixtureInterface 'attributes' => [], 'products' => [], 'matrix' => [ - 'attribute_0:option_0' => [ + 'attribute_key_0:option_key_0' => [ 'display' => 'Yes', 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_1' => [ + 'attribute_key_0:option_key_1' => [ 'display' => 'Yes', 'quantity_and_stock_status' => [ 'qty' => 20 @@ -307,16 +306,16 @@ class ConfigurableAttributesData implements FixtureInterface ], 'two_options_with_assigned_product' => [ 'attributes_data' => [ - 'attribute_0' => [ + 'attribute_key_0' => [ 'options' => [ - 'option_0' => [ - 'label' => 'option_1_%isolation%', + 'option_key_0' => [ + 'label' => 'option_key_1_%isolation%', 'pricing_value' => 1, 'is_percent' => 'Yes', 'include' => 'Yes' ], - 'option_1' => [ - 'label' => 'option_2_%isolation%', + 'option_key_1' => [ + 'label' => 'option_key_2_%isolation%', 'pricing_value' => 2, 'is_percent' => 'Yes', 'include' => 'Yes', @@ -325,21 +324,21 @@ class ConfigurableAttributesData implements FixtureInterface ] ], 'attributes' => [ - 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_two_options', + 'attribute_key_0' => 'catalogProductAttribute::attribute_type_dropdown_two_options', ], 'products' => [ - 'attribute_0:option_0' => 'catalogProductSimple::default', - 'attribute_0:option_1' => 'catalogProductSimple::default' + 'attribute_key_0:option_key_0' => 'catalogProductSimple::default', + 'attribute_key_0:option_key_1' => 'catalogProductSimple::default' ], 'matrix' => [ - 'attribute_0:option_0' => [ + 'attribute_key_0:option_key_0' => [ 'display' => 'Yes', 'quantity_and_stock_status' => [ 'qty' => 10 ], 'weight' => 1 ], - 'attribute_0:option_1' => [ + 'attribute_key_0:option_key_1' => [ 'display' => 'Yes', 'quantity_and_stock_status' => [ 'qty' => 20 @@ -420,7 +419,7 @@ class ConfigurableAttributesData implements FixtureInterface $options = []; foreach ($attributeData['options'] as $key => $option) { - $options['option_' . $key] = $option; + $options['option_key_' . $key] = $option; } $attributeData['options'] = $options; @@ -617,6 +616,7 @@ class ConfigurableAttributesData implements FixtureInterface 'options', ]; $optionFields = [ + 'admin', 'label', 'pricing_value', 'is_percent', diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php index bd125a2ebdd39b132ed026b96d66f9c4f771d6c1..0b94381dc4cff68af0f3b602ed81102e6ca8b2bc 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php @@ -57,7 +57,7 @@ class ConfigurableProductInjectable extends AbstractRepository ], 'website_ids' => ['Main Website'], 'attribute_set_id' => ['dataSet' => 'default'], - 'checkout_data' => ['preset' => 'default'], + 'checkout_data' => ['preset' => 'default'] ]; $this->_data['one_variation'] = [ diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv index 89c333704a0047ce10c86243d60d8e4061ab0339..9e539ae215302b69ad6a6e33ba6d6ef21cdfd232 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv @@ -1,5 +1,5 @@ "product/data/configurable_attributes_data/preset";"product/data/checkout_data/preset";"product/data/name";"product/data/sku";"product/data/tax_class_id";"product/data/price/value";"product/data/special_price";"product/data/category_ids/presets";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/is_in_stock";"product/data/affected_attribute_set";"constraint";"issue" -"two_new_options";"two_new_options";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"default_subcategory";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertProductInCategory, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart, assertChildProductIsNotDisplayedSeparately";"Bug: MAGETWO-26979" +"two_new_options";"two_new_options";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"default_subcategory";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertProductInCategory, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart, assertChildProductIsNotDisplayedSeparately";"Bug: MAGETWO-28347" "two_options";"two_options";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"-";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart";"" -"two_new_options";"two_new_options_with_special_price";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"10";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart, assertProductSpecialPriceOnProductPage";"Bug: MAGETWO-26979" +"two_new_options";"two_new_options_with_special_price";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"10";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart, assertProductSpecialPriceOnProductPage";"Bug: MAGETWO-28347" "two_options_with_assigned_product";"two_options_with_assigned_product";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart";"" diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php index f126cdd375ae873c44dba505feb718909b4e86c5..a260c58e4c1fba91fba187c99615ad900644e306 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php @@ -124,12 +124,23 @@ class CreateConfigurableTest extends Functional 'Product name does not correspond to specified.' ); $price = $product->getProductPrice(); - $blockPrice = $productViewBlock->getProductPrice(); + $priceOnPage = $productViewBlock->getPriceBlock()->getPrice(); $this->assertEquals( number_format($price, 2), - number_format($blockPrice['price_regular_price'], 2), + number_format($priceOnPage, 2), 'Product price does not correspond to specified.' ); - $this->assertTrue($productViewBlock->verifyProductOptions($product), 'Added configurable options are absent'); + + $pageOptions = $productViewBlock->getOptions($product); + $configurableOptions = []; + foreach ($pageOptions['configurable_options'] as $attribute) { + $configurableOption = []; + foreach ($attribute['options'] as $option) { + $configurableOption[] = $option['title']; + } + + $configurableOptions[$attribute['title']] = $configurableOption; + } + $this->assertEquals($product->getConfigurableOptions(), $configurableOptions); } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php index 8194b254bc050538ea6fd96714b6e0d65cd17382..a89e555204a8c23d9d25418ef8822b442ed48393 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php @@ -205,15 +205,23 @@ class CreateWithAttributeTest extends Functional $productViewBlock->getProductName(), 'Product name does not correspond to specified.' ); - $price = $productViewBlock->getProductPrice(); + $price = $productViewBlock->getPriceBlock()->getPrice(); $this->assertEquals( number_format($product->getProductPrice(), 2), - $price['price_regular_price'], + $price, 'Product price does not correspond to specified.' ); - $this->assertTrue( - $productViewBlock->verifyProductOptions($variations), - 'Added configurable options are absent.' - ); + + $pageOptions = $productViewBlock->getOptions($variations); + $configurableOptions = []; + foreach ($pageOptions['configurable_options'] as $attribute) { + $configurableOption = []; + foreach ($attribute['options'] as $option) { + $configurableOption[] = $option['title']; + } + + $configurableOptions[$attribute['title']] = $configurableOption; + } + $this->assertEquals($variations->getConfigurableOptions(), $configurableOptions); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php new file mode 100644 index 0000000000000000000000000000000000000000..d59965809a97fee37a2dab39ade6eb099d3368cd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php @@ -0,0 +1,80 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @spi + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Test\Block\Account; + +use Magento\Customer\Test\Fixture\AddressInjectable; +use Mtf\Block\Block; +use Mtf\Client\Element\Locator; + +/** + * Class AddressesAdditional + * Additional Addresses block + */ +class AddressesAdditional extends Block +{ + /** + * Selector for address block + * + * @var string + */ + protected $addressSelector = '//li[address[contains(.,"%s")]]'; + + /** + * Selector for delete link + * + * @var string + */ + protected $deleteAddressLink = "[role='delete-address']"; + + /** + * Content of additional address block + * + * @var string + */ + protected $additionalAddressContent = '.block-content'; + + /** + * Delete Additional Address + * + * @param AddressInjectable $address + * @return void + */ + public function deleteAdditionalAddress(AddressInjectable $address) + { + $this->_rootElement->find(sprintf($this->addressSelector, $address->getStreet()), Locator::SELECTOR_XPATH) + ->find($this->deleteAddressLink)->click(); + $this->_rootElement->acceptAlert(); + } + + /** + * Get block text + * + * @return string + */ + public function getBlockText() + { + return $this->_rootElement->find($this->additionalAddressContent)->getText(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php new file mode 100644 index 0000000000000000000000000000000000000000..b379af48b64756ace50c40adef8267d4151eb982 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php @@ -0,0 +1,145 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Test\Block\Address; + +use Magento\Customer\Test\Fixture\AddressInjectable; + +/** + * Class Renderer + * Render output from AddressInjectable fixture according to data format type + */ +class Renderer +{ + /** + * Address format type + * + * @var string + */ + protected $type; + + /** + * AddressInjectable fixture + * + * @var AddressInjectable + */ + protected $address; + + /** + * @param AddressInjectable $address + * @param string $type + */ + public function __construct(AddressInjectable $address, $type = null) + { + $this->address = $address; + $this->type = $type; + } + + /** + * Returns pattern according to address type + * + * @return string + */ + protected function getPattern() + { + $region = $this->resolveRegion(); + switch ($this->type) { + case "oneline": + default: + $outputPattern = "{{depend}}{{prefix}} {{/depend}}{{firstname}} {{depend}}{{middlename}} {{/depend}}" + . "{{lastname}}{{depend}} {{suffix}}{{/depend}}, {{street}}, " + . "{{city}}, {{{$region}}} {{postcode}}, {{country_id}}"; + break; + } + return $outputPattern; + } + + /** + * Render address according to format type + * + * @return string + */ + public function render() + { + $outputPattern = $this->getPattern(); + $fields = $this->getFieldsArray($outputPattern); + $output = $this->preparePattern(); + + foreach ($fields as $field) { + $data = $this->address->getData($field); + $output = str_replace($field, $data, $output); + } + + $output = str_replace(['{', '}'], '', $output); + return $output; + } + + /** + * Get an array of necessary fields from pattern + * + * @param string $outputPattern + * @return mixed + */ + protected function getFieldsArray($outputPattern) + { + $fieldsArray = []; + preg_match_all('@\{\{(\w+)\}\}@', $outputPattern, $matches); + foreach ($matches[1] as $item) { + if ($item != 'depend') { + $fieldsArray[] = $item; + } + } + return $fieldsArray; + } + + /** + * Purge fields from pattern which are not present in fixture + * + * @return string + */ + protected function preparePattern() + { + $outputPattern = $this->getPattern(); + preg_match_all('@\{\{depend\}\}(.*?)\{\{.depend\}\}@', $outputPattern, $matches); + foreach ($matches[1] as $key => $dependPart) { + preg_match_all('@\{\{(\w+)\}\}@', $dependPart, $depends); + foreach ($depends[1] as $depend) { + if ($this->address->getData(trim($depend)) === null) { + $outputPattern = str_replace($matches[0][$key], "", $outputPattern); + } + } + } + return $outputPattern; + } + + /** + * Check necessary field to retrieve according to address country + * + * @return string + */ + protected function resolveRegion() + { + return $this->address->hasData('region') ? 'region' : 'region_id'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedBackend.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedBackend.php new file mode 100644 index 0000000000000000000000000000000000000000..a0652d5aead186c89bb10e0999a7239b1516dcdd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedBackend.php @@ -0,0 +1,86 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Test\Constraint; + +use Magento\Customer\Test\Fixture\AddressInjectable; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertAddressDeletedBackend + * Assert that deleted customers address is not displayed on backend during order creation + */ +class AssertAddressDeletedBackend extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that deleted customers address is not displayed on backend during order creation + * + * @param OrderIndex $orderIndex + * @param OrderCreateIndex $orderCreateIndex + * @param AddressInjectable $deletedAddress + * @param CustomerInjectable $customer + * @return void + */ + public function processAssert( + OrderIndex $orderIndex, + OrderCreateIndex $orderCreateIndex, + AddressInjectable $deletedAddress, + CustomerInjectable $customer + ) { + $filter = ['email' => $customer->getEmail()]; + $orderIndex->open()->getGridPageActions()->addNew(); + $orderCreateIndex->getCustomerBlock()->searchAndOpen($filter); + $orderCreateIndex->getStoreBlock()->selectStoreView(); + $actualAddresses = $orderCreateIndex->getCreateBlock()->getBillingAddressBlock()->getExistingAddresses(); + $addressRenderer = $this->objectManager->create( + 'Magento\Customer\Test\Block\Address\Renderer', + ['address' => $deletedAddress] + ); + $addressToSearch = $addressRenderer->render(); + \PHPUnit_Framework_Assert::assertFalse( + in_array($addressToSearch, $actualAddresses), + 'Deleted address is present on backend during order creation' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Deleted address is absent on backend during order creation'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedFrontend.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedFrontend.php new file mode 100644 index 0000000000000000000000000000000000000000..0e24a76b8b189206f8015f8088347f33d6110d33 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedFrontend.php @@ -0,0 +1,74 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Test\Constraint; + +use Magento\Customer\Test\Page\CustomerAccountIndex; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertAddressDeletedFrontend + * Assert that deleted customers address is absent in Address Book in Customer Account + */ +class AssertAddressDeletedFrontend extends AbstractConstraint +{ + /** + * Expected message + */ + const EXPECTED_MESSAGE = 'You have no additional address entries in your address book.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Asserts that Asserts that 'Additional Address Entries' contains expected message + * + * @param CustomerAccountIndex $customerAccountIndex + * @return void + */ + public function processAssert(CustomerAccountIndex $customerAccountIndex) + { + $customerAccountIndex->open(); + $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book'); + $actualText = $customerAccountIndex->getAdditionalAddressBlock()->getBlockText(); + \PHPUnit_Framework_Assert::assertTrue( + self::EXPECTED_MESSAGE == $actualText, + 'Expected text is absent in Additional Address block.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Deleted address is absent in "Additional Address Entries" block.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountIndex.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountIndex.xml index 0985c1a066a72170cc8674152b3f30f76efd9a6b..0d5e08f8aa459fac9fc4fb6be2a97f1d29aa4a55 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountIndex.xml @@ -55,5 +55,10 @@ <locator>.block.compare</locator> <strategy>css selector</strategy> </compareProductsBlock> + <additionalAddressBlock> + <class>Magento\Customer\Test\Block\Account\AddressesAdditional</class> + <locator>.block-addresses-list</locator> + <strategy>css selector</strategy> + </additionalAddressBlock> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/AddressInjectable.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/AddressInjectable.php index 1906e612a0a4897ca474424afbb07fa01cce9aa4..081300a20d779dc3fb3e83618a422868244decf0 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/AddressInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/AddressInjectable.php @@ -71,6 +71,21 @@ class AddressInjectable extends AbstractRepository 'default_shipping' => 'No' ]; + $this->_data['US_NY_address_billing'] = [ + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'John.Doe%isolation%@example.com', + 'company' => 'Magento %isolation%', + 'street' => '6262 Fifth Avenue', + 'city' => 'New York', + 'region_id' => 'New York', + 'postcode' => '90230', + 'country_id' => 'United States', + 'telephone' => '555-55-555-55', + 'default_billing' => 'No', + 'default_shipping' => 'No' + ]; + $this->_data['US_address_default_shipping'] = [ 'firstname' => 'John', 'lastname' => 'Doe', diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a962eacf963d2ed801a40c44f1bfcae3c5b9f101 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.php @@ -0,0 +1,115 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Test\TestCase; + +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Customer\Test\Page\CustomerAccountIndex; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Mtf\TestCase\Injectable; + +/** + * Test Creation for DeleteCustomerAddress + * + * Test Flow: + * + * Preconditions: + * 1. Create customer + * 2. Add default address (NY) + * 3. Add one more address (CA) + * + * Steps: + * 1. Open frontend + * 2. Login as customer + * 3. Go to 'Address Book' tab > Additional Address Entries + * 4. Delete second address - click 'Delete Address' button + * 5. Perform all assertions + * + * @group Customers_(CS) + * @ZephyrId MAGETWO-28066 + */ +class DeleteCustomerAddressTest extends Injectable +{ + /** + * Cms index page + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Customer login page + * + * @var CustomerAccountLogin + */ + protected $customerAccountLogin; + + /** + * Customer index page + * + * @var CustomerAccountIndex + */ + protected $customerAccountIndex; + + /** + * Prepare pages for test + * + * @param CustomerAccountLogin $customerAccountLogin + * @param CmsIndex $cmsIndex + * @param CustomerAccountIndex $customerAccountIndex + * @return void + */ + public function __inject( + CustomerAccountLogin $customerAccountLogin, + CmsIndex $cmsIndex, + CustomerAccountIndex $customerAccountIndex + ) { + $this->cmsIndex = $cmsIndex; + $this->customerAccountLogin = $customerAccountLogin; + $this->customerAccountIndex = $customerAccountIndex; + } + + /** + * Runs Delete Customer Address test + * + * @param CustomerInjectable $customer + * @return array + */ + public function test(CustomerInjectable $customer) + { + // Precondition: + $customer->persist(); + $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[1]; + + // Steps: + $this->cmsIndex->open(); + $this->cmsIndex->getLinksBlock()->openLink("Log In"); + $this->customerAccountLogin->getLoginBlock()->login($customer); + $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book'); + $this->customerAccountIndex->getAdditionalAddressBlock()->deleteAdditionalAddress($addressToDelete); + + return ['deletedAddress' => $addressToDelete]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest/test.csv b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..2f59beef4bef5db612281f2858977292b4b634b6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest/test.csv @@ -0,0 +1,2 @@ +"customer/dataSet";"customer/data/address/presets";"constraint" +"default";"US_address_default_billing,US_NY_address_billing";"assertAddressDeletedFrontend, assertAddressDeletedBackend" diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml index 48923128731e51307dd9c7ab59d98fd0d96ce986..83349a9f1da744ef0a95abdb8ea14ab5e9770542 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml @@ -136,4 +136,12 @@ <assertMassActionSuccessUpdateMessage module="Magento_Customer"> <severeness>low</severeness> </assertMassActionSuccessUpdateMessage> + <assertAddressDeletedFrontend module="Magento_Customer"> + <severeness>low</severeness> + <require /> + </assertAddressDeletedFrontend> + <assertAddressDeletedBackend module="Magento_Customer"> + <severeness>low</severeness> + <require /> + </assertAddressDeletedBackend> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View.php index e00adf945ce1fa70ea2756afa758ffa4a362190a..bd751951e376000ac068429eaa132d13b9566b41 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View.php @@ -24,14 +24,15 @@ namespace Magento\Downloadable\Test\Block\Catalog\Product; +use Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Block\Product\View as ParentView; +use Mtf\Fixture\FixtureInterface; /** * Class View * Downloadable product view block on the product page */ -class View extends ParentView +class View extends \Magento\Catalog\Test\Block\Product\View { /** * Block Downloadable links @@ -45,7 +46,7 @@ class View extends ParentView * * @var string */ - protected $blockDownloadableSamples = '//dl[contains(@class,"downloadable samples")]'; + protected $blockDownloadableSamples = '.downloadable.samples'; /** * Get downloadable link block @@ -72,8 +73,68 @@ class View extends ParentView return $this->blockFactory->create( 'Magento\Downloadable\Test\Block\Catalog\Product\View\Samples', [ - 'element' => $this->_rootElement->find($this->blockDownloadableSamples, Locator::SELECTOR_XPATH) + 'element' => $this->_rootElement->find($this->blockDownloadableSamples) ] ); } + + /** + * Fill specified option for the product + * + * @param FixtureInterface $product + * @return void + */ + public function fillOptions(FixtureInterface $product) + { + /** @var DownloadableProductInjectable $product */ + $productData = $product->getData(); + $downloadableLinks = isset($productData['downloadable_links']['downloadable']['link']) + ? $productData['downloadable_links']['downloadable']['link'] + : []; + $data = $product->getCheckoutData()['options']; + + // Replace link key to label + foreach ($data['links'] as $key => $linkData) { + $linkKey = str_replace('link_', '', $linkData['label']); + + $linkData['label'] = isset($downloadableLinks[$linkKey]['title']) + ? $downloadableLinks[$linkKey]['title'] + : $linkData['label']; + + $data['links'][$key] = $linkData; + } + + $this->getDownloadableLinksBlock()->fill($data['links']); + parent::fillOptions($product); + } + + /** + * Return product options + * + * @param FixtureInterface $product + * @return array + */ + public function getOptions(FixtureInterface $product) + { + $downloadableOptions = []; + + if ($this->_rootElement->find($this->blockDownloadableLinks, Locator::SELECTOR_XPATH)->isVisible()) { + $downloadableOptions['downloadable_links'] = [ + 'title' => $this->getDownloadableLinksBlock()->getTitle(), + 'downloadable' => [ + 'link' => $this->getDownloadableLinksBlock()->getLinks() + ] + ]; + } + if ($this->_rootElement->find($this->blockDownloadableSamples)->isVisible()) { + $downloadableOptions['downloadable_sample'] = [ + 'title' => $this->getDownloadableSamplesBlock()->getTitle(), + 'downloadable' => [ + 'sample' => $this->getDownloadableSamplesBlock()->getLinks() + ] + ]; + } + + return ['downloadable_options' => $downloadableOptions] + parent::getOptions($product); + } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View/Links.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View/Links.php index c0ca52627e921b8a13661935de42489e5112ff5a..30855d148745917c525bc3e3576f9ed8ce378d0e 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View/Links.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View/Links.php @@ -29,8 +29,9 @@ use Mtf\Client\Element\Locator; /** * Class Links - * * Downloadable links blocks on frontend + * + * @SuppressWarnings(PHPMD.NPathComplexity) */ class Links extends Block { @@ -39,90 +40,127 @@ class Links extends Block * * @var string */ - protected $titleForLink = '//div[contains(@class,"field downloads")]/label[@class="label"]/span'; + protected $title = '//div[contains(@class,"field downloads")]/label[@class="label"]/span'; /** - * Format for downloadable links list selector + * Selector for link by label * * @var string */ - protected $linksListSelector = '//*[@id="downloadable-links-list"]/div[%d]/'; + protected $linkByLabel = './/input[@type="checkbox" and (./../label/span[contains(text(),"%s")])]'; /** - * Title selector item links + * Choice link selector * * @var string */ - protected $titleForList = "label[@class='label']/span[1]"; + protected $choiceLink = './/*[contains(@class,"choice")]'; /** - * Price selector item links + * Checkbox selector item links * * @var string */ - protected $priceForList = 'label/span[contains(@class,"price-container")]//span[@class="price"]'; + protected $separatelyForChoice = 'input[type="checkbox"]'; /** * Checkbox selector item links * * @var string */ - protected $separatelyForList = "input[@type='checkbox']"; + protected $linkForChoice = './/label/span[1]'; /** - * Change format downloadable links list + * Checkbox selector item links * - * @param int $index - * @return string + * @var string */ - protected function formatIndex($index) - { - return sprintf($this->linksListSelector, $index); - } + protected $sampleLinkForChoice = '.sample.link'; + + /** + * Checkbox selector item links + * + * @var string + */ + protected $priceForChoice = '.price-wrapper .price'; + + /** + * Checkbox selector item links + * + * @var string + */ + protected $priceAdjustmentsForChoice = '.price-adjustments .price'; /** * Get title for links block * * @return string */ - public function getTitleForLinkBlock() + public function getTitle() { - return $this->_rootElement->find($this->titleForLink, Locator::SELECTOR_XPATH)->getText(); + return $this->_rootElement->find($this->title, Locator::SELECTOR_XPATH)->getText(); } /** - * Get title for item link on data list + * Fill links on product view page * - * @param int $index - * @return string + * @param array $data + * @return void */ - public function getItemTitle($index) + public function fill(array $data) { - return $this->_rootElement->find($this->formatIndex($index) . $this->titleForList, Locator::SELECTOR_XPATH) - ->getText(); + foreach ($data as $linkData) { + $link = $this->_rootElement->find( + sprintf($this->linkByLabel, $linkData['label']), + Locator::SELECTOR_XPATH, + 'checkbox' + ); + $link->setValue($linkData['value']); + } } /** - * Visible checkbox for item link on data list + * Return links data on product page view * - * @param int $index - * @return bool + * @return array */ - public function isVisibleItemCheckbox($index) + public function getLinks() { - return $this->_rootElement->find($this->formatIndex($index) . $this->separatelyForList, Locator::SELECTOR_XPATH) - ->isVisible(); + $linksData = []; + + $choiceLinks = $this->_rootElement->find($this->choiceLink, Locator::SELECTOR_XPATH)->getElements(); + foreach ($choiceLinks as $choiceLink) { + $link = $choiceLink->find($this->linkForChoice, Locator::SELECTOR_XPATH); + $sample = $choiceLink->find($this->sampleLinkForChoice); + $price = $choiceLink->find($this->priceForChoice); + $priceAdjustments = $choiceLink->find($this->priceAdjustmentsForChoice); + + $linkData = [ + 'links_purchased_separately' => $choiceLink->find($this->separatelyForChoice)->isVisible() + ? 'Yes' + : 'No', + 'title' => $link->isVisible() ? $link->getText() : null, + 'sample' => $sample->isVisible() ? $sample->getText() : null, + 'price' => $price->isVisible() ? $this->escapePrice($price->getText()) : null, + 'price_adjustments' => $priceAdjustments->isVisible() + ? $this->escapePrice($priceAdjustments->getText()) + : null, + ]; + + $linksData[] = array_filter($linkData); + } + + return $linksData; } /** - * Get price for item link on data list + * Escape currency for price * - * @param int $index + * @param string $price * @return string */ - public function getItemPrice($index) + protected function escapePrice($price) { - return $this->_rootElement->find($this->formatIndex($index) . $this->priceForList, Locator::SELECTOR_XPATH) - ->getText(); + return preg_replace('/[^0-9\.,]/', '', $price); } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View/Samples.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View/Samples.php index 65ea689e839df236ab2db65af9b3c5fbc98bf38b..8719348b063169410c2a135ee8a52c8465809375 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View/Samples.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View/Samples.php @@ -25,7 +25,6 @@ namespace Magento\Downloadable\Test\Block\Catalog\Product\View; use Mtf\Block\Block; -use Mtf\Client\Element\Locator; /** * Class Samples @@ -39,34 +38,41 @@ class Samples extends Block * * @var string */ - protected $titleForSampleBlock = '//dt[contains(@class,"samples title")]'; + protected $titleBlock = '.samples.title'; /** - * Title selector item sample + * Title selector item sample link * * @var string */ - protected $titleForList = '//dd[contains(@class,"sample item")][%d]/a'; + protected $linkTitle = '.sample.link'; /** * Get title for Samples block * * @return string */ - public function getTitleForSampleBlock() + public function getTitle() { - return $this->_rootElement->find($this->titleForSampleBlock, Locator::SELECTOR_XPATH)->getText(); + return $this->_rootElement->find($this->titleBlock)->getText(); } /** - * Get title for item sample on data list + * Get sample links * - * @param int $index - * @return string + * @return array */ - public function getItemTitle($index) + public function getLinks() { - $formatTitle = sprintf($this->titleForList, $index); - return $this->_rootElement->find($formatTitle, Locator::SELECTOR_XPATH)->getText(); + $links = $this->_rootElement->find($this->linkTitle)->getElements(); + $linksData = []; + + foreach ($links as $link) { + $linksData[] = [ + 'title' => $link->getText() + ]; + } + + return $linksData; } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableLinksData.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableLinksData.php index 88f555f33110e6052f0f0f4148f1640c434273ef..fa4db960b45cd8d39ad318c1b7510a6951507808 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableLinksData.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableLinksData.php @@ -25,17 +25,38 @@ namespace Magento\Downloadable\Test\Constraint; use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Catalog\Test\Page\Product\CatalogProductView; -use Magento\Downloadable\Test\Fixture\CatalogProductDownloadable; +use Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; /** * Class AssertDownloadableLinksData * * Assert that Link block for downloadable product on front-end */ -class AssertDownloadableLinksData extends AbstractConstraint +class AssertDownloadableLinksData extends AbstractAssertForm { + /** + * List downloadable link fields for verify + * + * @var array + */ + protected $downloadableLinksField = [ + 'title', + 'downloadable' + ]; + + /** + * List fields of downloadable link for verify + * + * @var array + */ + protected $linkField = [ + 'title', + 'links_purchased_separately', + 'price' + ]; + /** * Constraint severeness * @@ -46,78 +67,61 @@ class AssertDownloadableLinksData extends AbstractConstraint /** * Assert Link block for downloadable product on front-end * - * @param CatalogProductView $downloadableProductView - * @param CatalogProductDownloadable $product + * @param CatalogProductView $catalogProductView + * @param DownloadableProductInjectable $product * @param Browser $browser * @return void */ public function processAssert( - CatalogProductView $downloadableProductView, - CatalogProductDownloadable $product, + CatalogProductView $catalogProductView, + DownloadableProductInjectable $product, Browser $browser ) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $linksBlock = $downloadableProductView->getDownloadableViewBlock()->getDownloadableLinksBlock(); - $fields = $product->getData(); - // Title for for Link block - \PHPUnit_Framework_Assert::assertEquals( - $linksBlock->getTitleForLinkBlock(), - $fields['downloadable_links']['title'], - 'Title for for Link block for downloadable product on front-end is not correct.' - ); - $this->sortDownloadableArray($fields['downloadable_links']['downloadable']['link']); + $fixtureDownloadableLinks = $this->prepareFixtureData($product); + $pageOptions = $catalogProductView->getViewBlock()->getOptions($product); + $pageDownloadableLinks = $this->preparePageData($pageOptions['downloadable_options']['downloadable_links']); + $error = $this->verifyData($fixtureDownloadableLinks, $pageDownloadableLinks); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); + } - foreach ($fields['downloadable_links']['downloadable']['link'] as $index => $link) { - $index++; - // Titles for each links - // Links are displaying according to Sort Order - \PHPUnit_Framework_Assert::assertEquals( - $linksBlock->getItemTitle($index), - $link['title'], - 'Link item ' . $index . ' with title "' . $link['title'] . '" is not visible.' - ); + /** + * Prepare fixture data for verify + * + * @param DownloadableProductInjectable $product + * @return array + */ + protected function prepareFixtureData(DownloadableProductInjectable $product) + { + $data = $this->sortDataByPath($product->getDownloadableLinks(), 'downloadable/link::sort_order'); - // If Links can be Purchase Separately, check-nob is presented near each link - // If Links CANNOT be Purchase Separately, check-nob is not presented near each link - if ($fields['downloadable_links']['links_purchased_separately'] == "Yes") { - \PHPUnit_Framework_Assert::assertTrue( - $linksBlock->isVisibleItemCheckbox($index), - 'Item ' . $index . ' link block CANNOT be Purchase Separately.' - ); - // Price is equals passed according to fixture - $link['price'] = sprintf('$%1.2f', $link['price']); - \PHPUnit_Framework_Assert::assertEquals( - $linksBlock->getItemPrice($index), - $link['price'], - 'Link item ' . $index . ' price is not visible.' - ); - } elseif ($fields['downloadable_links']['links_purchased_separately'] == "No") { - \PHPUnit_Framework_Assert::assertFalse( - $linksBlock->isVisibleItemCheckbox($index), - 'Item ' . $index . ' link block can be Purchase Separately.' - ); - } + foreach ($data['downloadable']['link'] as $key => $link) { + $link['links_purchased_separately'] = $data['links_purchased_separately']; + $link = array_intersect_key($link, array_flip($this->linkField)); + + $data['downloadable']['link'][$key] = $link; } + $data = array_intersect_key($data, array_flip($this->downloadableLinksField)); + + return $data; } /** - * Sort downloadable links array + * Prepare page data for verify * - * @param array $fields + * @param array $data * @return array */ - protected function sortDownloadableArray(&$fields) + protected function preparePageData(array $data) { - usort( - $fields, - function ($a, $b) { - if ($a['sort_order'] == $b['sort_order']) { - return 0; - } - return ($a['sort_order'] < $b['sort_order']) ? -1 : 1; - } - ); + foreach ($data['downloadable']['link'] as $key => $link) { + $link = array_intersect_key($link, array_flip($this->linkField)); + $data['downloadable']['link'][$key] = $link; + } + $data = array_intersect_key($data, array_flip($this->downloadableLinksField)); + + return $data; } /** diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableSamplesData.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableSamplesData.php index 69e409c67ea8032fe5a04d217e7d1ca336da3973..498f67d092f1317fddcafe243b1824f1e7d3840c 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableSamplesData.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableSamplesData.php @@ -25,17 +25,36 @@ namespace Magento\Downloadable\Test\Constraint; use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Catalog\Test\Page\Product\CatalogProductView; -use Magento\Downloadable\Test\Fixture\CatalogProductDownloadable; +use Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; /** * Class AssertDownloadableSamplesData * * Assert that Sample block for downloadable product on front-end */ -class AssertDownloadableSamplesData extends AbstractConstraint +class AssertDownloadableSamplesData extends AbstractAssertForm { + /** + * List downloadable sample links fields for verify + * + * @var array + */ + protected $downloadableSampleField = [ + 'title', + 'downloadable' + ]; + + /** + * List fields of downloadable sample link for verify + * + * @var array + */ + protected $linkField = [ + 'title', + ]; + /** * Constraint severeness * @@ -47,56 +66,58 @@ class AssertDownloadableSamplesData extends AbstractConstraint * Assert Sample block for downloadable product on front-end * * @param CatalogProductView $productView - * @param CatalogProductDownloadable $product + * @param DownloadableProductInjectable $product * @param Browser $browser * @return void */ public function processAssert( CatalogProductView $productView, - CatalogProductDownloadable $product, + DownloadableProductInjectable $product, Browser $browser ) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $sampleBlock = $productView->getDownloadableViewBlock()->getDownloadableSamplesBlock(); - $fields = $product->getData(); - // Title for for sample block - \PHPUnit_Framework_Assert::assertEquals( - $sampleBlock->getTitleForSampleBlock(), - $fields['downloadable_sample']['title'], - 'Title for for Samples block for downloadable product on front-end is not correct.' - ); + $fixtureSampleLinks = $this->prepareFixtureData($product); + $pageOptions = $productView->getViewBlock()->getOptions($product); + $pageSampleLinks = $this->preparePageData($pageOptions['downloadable_options']['downloadable_sample']); + $error = $this->verifyData($fixtureSampleLinks, $pageSampleLinks); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); + } - $this->sortDownloadableArray($fields['downloadable_sample']['downloadable']['sample']); + /** + * Prepare fixture data for verify + * + * @param DownloadableProductInjectable $product + * @return array + */ + protected function prepareFixtureData(DownloadableProductInjectable $product) + { + $data = $this->sortDataByPath($product->getDownloadableSample(), 'downloadable/sample::sort_order'); - foreach ($fields['downloadable_sample']['downloadable']['sample'] as $index => $sample) { - // Titles for each sample - // Samples are displaying according to Sort Order - \PHPUnit_Framework_Assert::assertEquals( - $sampleBlock->getItemTitle(++$index), - $sample['title'], - 'Sample item ' . $index . ' with title "' . $sample['title'] . '" is not visible.' - ); + foreach ($data['downloadable']['sample'] as $key => $link) { + $link = array_intersect_key($link, array_flip($this->linkField)); + $data['downloadable']['sample'][$key] = $link; } + $data = array_intersect_key($data, array_flip($this->downloadableSampleField)); + + return $data; } /** - * Sort downloadable sample array + * Prepare page data for verify * - * @param array $fields + * @param array $data * @return array */ - protected function sortDownloadableArray(&$fields) + protected function preparePageData(array $data) { - usort( - $fields, - function ($a, $b) { - if ($a['sort_order'] == $b['sort_order']) { - return 0; - } - return ($a['sort_order'] < $b['sort_order']) ? -1 : 1; - } - ); + foreach ($data['downloadable']['sample'] as $key => $link) { + $link = array_intersect_key($link, array_flip($this->linkField)); + $data['downloadable']['sample'][$key] = $link; + } + $data = array_intersect_key($data, array_flip($this->downloadableSampleField)); + + return $data; } /** diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/Cart/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..bc9dc5a2a2c20cc018faeb1f877fc255c9215073 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/Cart/Item.php @@ -0,0 +1,39 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Downloadable\Test\Fixture\Cart; + +use Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; + +/** + * Class Item + * Data for verify cart item block on checkout page + * + * Data keys: + * - product (fixture data for verify) + */ +class Item extends \Magento\Catalog\Test\Fixture\Cart\Item +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.php index 29d7bc57ff924bc300a0755ed02df7918575502f..4781f0aec79d053f6236484102807ed71127aa5b 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.php @@ -45,6 +45,7 @@ class DownloadableProduct extends Product { parent::_initData(); $this->_dataConfig = array( + 'type_id' => 'downloadable', 'constraint' => 'Success', 'grid_filter' => array('name'), 'create_url_params' => array( diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.php similarity index 96% rename from dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php rename to dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.php index e6d589489fade8431829af9c6d9f88127b3bce60..f9c8e601043b1ebd42ef829ace4fe7f1ee97588b 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.php @@ -32,24 +32,24 @@ use Mtf\Repository\RepositoryFactory; use Mtf\System\Event\EventManagerInterface; /** - * Class CatalogProductDownloadable + * Class DownloadableProductInjectable * Fixture for Downloadable product * * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.TooManyFields) */ -class CatalogProductDownloadable extends InjectableFixture +class DownloadableProductInjectable extends InjectableFixture { /** * @var string */ - protected $repositoryClass = 'Magento\Downloadable\Test\Repository\CatalogProductDownloadable'; + protected $repositoryClass = 'Magento\Downloadable\Test\Repository\DownloadableProductInjectable'; // @codingStandardsIgnoreStart /** * @var string */ - protected $handlerInterface = 'Magento\Downloadable\Test\Handler\CatalogProductDownloadable\CatalogProductDownloadableInterface'; + protected $handlerInterface = 'Magento\Downloadable\Test\Handler\DownloadableProductInjectable\DownloadableProductInjectableInterface'; // @codingStandardsIgnoreEnd /** @@ -91,6 +91,7 @@ class CatalogProductDownloadable extends InjectableFixture } protected $dataConfig = [ + 'type_id' => 'downloadable', 'create_url_params' => [ 'type' => 'downloadable', 'set' => '4', @@ -455,7 +456,7 @@ class CatalogProductDownloadable extends InjectableFixture 'default_value' => 'dafault', 'input' => 'text', 'group' => 'downloadable_information', - 'source' => 'Magento\Downloadable\Test\Fixture\CatalogProductDownloadable\Links' + 'source' => 'Magento\Downloadable\Test\Fixture\DownloadableProductInjectable\Links' ]; protected $downloadable_sample = [ @@ -465,7 +466,7 @@ class CatalogProductDownloadable extends InjectableFixture 'default_value' => 'dafault', 'input' => 'text', 'group' => 'downloadable_information', - 'source' => 'Magento\Downloadable\Test\Fixture\CatalogProductDownloadable\Samples' + 'source' => 'Magento\Downloadable\Test\Fixture\DownloadableProductInjectable\Samples' ]; protected $sku = [ @@ -648,6 +649,13 @@ class CatalogProductDownloadable extends InjectableFixture 'group' => 'websites', ]; + protected $checkout_data = [ + 'attribute_code' => 'checkout_data', + 'backend_type' => 'virtual', + 'group' => null, + 'source' => 'Magento\Downloadable\Test\Fixture\DownloadableProductInjectable\CheckoutData', + ]; + public function getCategoryIds() { return $this->getData('category_ids'); @@ -942,4 +950,19 @@ class CatalogProductDownloadable extends InjectableFixture { return $this->getData('custom_options'); } + + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } + + public function getDownloadableLinks() + { + return $this->getData('downloadable_links'); + } + + public function getDownloadableSample() + { + return $this->getData('downloadable_sample'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.xml old mode 100755 new mode 100644 similarity index 93% rename from dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml rename to dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.xml index b900829c1ee0e6265f83d717bdb6185a641218ef..a67f158eca5349a8e2b7c7b37001375fb2b5ba0a --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<fixture class="Magento\Downloadable\Test\Fixture\CatalogProductDownloadable"> +<fixture class="Magento\Downloadable\Test\Fixture\DownloadableProductInjectable"> <module>Magento_Downloadable</module> <type>eav</type> <entity_type>catalog_product</entity_type> @@ -459,6 +459,24 @@ <default_value>Main Website</default_value> <group>websites</group> </website_ids> + <downloadable_links> + <attribute_code>downloadable_links</attribute_code> + <backend_type>virtual</backend_type> + <group>downloadable_information</group> + <source>Magento\Downloadable\Test\Fixture\DownloadableProductInjectable\Links</source> + </downloadable_links> + <downloadable_sample> + <attribute_code>downloadable_sample</attribute_code> + <backend_type>virtual</backend_type> + <group>downloadable_information</group> + <source>Magento\Downloadable\Test\Fixture\DownloadableProductInjectable\Samples</source> + </downloadable_sample> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <source>Magento\Downloadable\Test\Fixture\DownloadableProductInjectable\CheckoutData</source> + </checkout_data> </fields> <data_set> <sku></sku> @@ -478,6 +496,6 @@ </create_url_params> <input_prefix>product</input_prefix> </data_config> - <repository_class>Magento\Downloadable\Test\Repository\CatalogProductDownloadable</repository_class> - <handler_interface>Magento\Downloadable\Test\Handler\CatalogProductDownloadable\CatalogProductDownloadableInterface</handler_interface> + <repository_class>Magento\Downloadable\Test\Repository\DownloadableProductInjectable</repository_class> + <handler_interface>Magento\Downloadable\Test\Handler\DownloadableProductInjectable\DownloadableProductInjectableInterface</handler_interface> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php new file mode 100644 index 0000000000000000000000000000000000000000..729448141d0302e3ae9b03d02ee17a3aa90cc1f9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php @@ -0,0 +1,64 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; + +/** + * Class CheckoutData + * Data for fill product form on frontend + * + * Data keys: + * - preset (Checkout data verification preset name) + */ +class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData +{ + /** + * Get preset array + * + * @param $name + * @return array|null + */ + protected function getPreset($name) + { + $presets = [ + 'with_two_separately_links' => [ + 'options' => [ + 'links' => [ + [ + 'label' => 'link_1', + 'value' => 'Yes' + ] + ], + 'qty' => 2, + ], + 'cartItem' => [ + 'price' => 23, + 'qty' => 2, + 'subtotal' => 46 + ] + ], + ]; + return isset($presets[$name]) ? $presets[$name] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable/Links.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/Links.php similarity index 78% rename from dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable/Links.php rename to dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/Links.php index 5015ced85080d367c9c82de931b6603621d5c8b8..39a0a9d5930ee2084eea4617f9de5675e4ef769f 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable/Links.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/Links.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Downloadable\Test\Fixture\CatalogProductDownloadable; +namespace Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; use Mtf\Fixture\FixtureInterface; @@ -30,6 +30,8 @@ use Mtf\Fixture\FixtureInterface; * Class Links * * Preset for link block + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ class Links implements FixtureInterface { @@ -48,8 +50,7 @@ class Links implements FixtureInterface protected $params; /** - * Construct for class - * + * @constructor * @param array $params * @param array $data */ @@ -137,6 +138,40 @@ class Links implements FixtureInterface ] ] ], + 'with_two_separately_links' => [ + 'title' => 'Links%isolation%', + 'links_purchased_separately' => 'Yes', + 'downloadable' => [ + 'link' => [ + [ + 'title' => 'link1%isolation%', + 'price' => 2.43, + 'number_of_downloads' => 2, + 'is_shareable' => 'No', + 'sample' => [ + 'sample_type_url' => 'Yes', + 'sample_url' => 'http://example.com/sample' + ], + 'file_type_url' => 'Yes', + 'file_link_url' => 'http://example.com', + 'sort_order' => 0 + ], + [ + 'title' => 'link2%isolation%', + 'price' => 3, + 'number_of_downloads' => 3, + 'is_shareable' => 'Yes', + 'sample' => [ + 'sample_type_url' => 'Yes', + 'sample_url' => 'http://example.com/sample2' + ], + 'file_type_url' => 'Yes', + 'file_link_url' => 'http://example2.com', + 'sort_order' => 1 + ], + ] + ] + ], 'with_three_links' => [ 'title' => 'Links%isolation%', 'links_purchased_separately' => 'Yes', diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable/Samples.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/Samples.php similarity index 97% rename from dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable/Samples.php rename to dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/Samples.php index bb890670a923ce48251a5cb6e696456035c9732e..35c7dea6bb3a6dc49047b96c9a1368a8a9885fa7 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable/Samples.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/Samples.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Downloadable\Test\Fixture\CatalogProductDownloadable; +namespace Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; use Mtf\Fixture\FixtureInterface; @@ -61,7 +61,7 @@ class Samples implements FixtureInterface } /** - * Persist group price + * Persist fixture * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/CatalogProductDownloadable/Curl.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProductInjectable/Curl.php similarity index 93% rename from dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/CatalogProductDownloadable/Curl.php rename to dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProductInjectable/Curl.php index 917ec398302d271c917bc19767f7252a637c98e9..d71ff09faf3bf56d7d49e5e782fbf8f17ea7235e 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/CatalogProductDownloadable/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProductInjectable/Curl.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Downloadable\Test\Handler\CatalogProductDownloadable; +namespace Magento\Downloadable\Test\Handler\DownloadableProductInjectable; use Mtf\System\Config; use Mtf\Fixture\FixtureInterface; @@ -32,7 +32,7 @@ use Magento\Catalog\Test\Handler\CatalogProductSimple\Curl as ProductCurl; * Class Curl * Create new downloadable product via curl */ -class Curl extends ProductCurl implements CatalogProductDownloadableInterface +class Curl extends ProductCurl implements DownloadableProductInjectableInterface { /** * Constructor @@ -70,6 +70,8 @@ class Curl extends ProductCurl implements CatalogProductDownloadableInterface $downloadableData = []; if (!empty($data['downloadable_links'])) { $data['links_title'] = $data['downloadable_links']['title']; + $data['links_purchased_separately'] = $data['downloadable_links']['links_purchased_separately']; + foreach ($data['downloadable_links']['downloadable']['link'] as $key => $link) { $downloadableData['downloadable']['link'][$key]['title'] = $link['title']; // only url type @@ -79,7 +81,6 @@ class Curl extends ProductCurl implements CatalogProductDownloadableInterface $downloadableData['downloadable']['link'][$key]['number_of_downloads'] = $link['number_of_downloads']; $downloadableData['downloadable']['link'][$key]['is_shareable'] = $link['is_shareable']; $downloadableData['downloadable']['link'][$key]['sort_order'] = $link['sort_order']; - // only url type $downloadableData['downloadable']['link'][$key]['sample']['type'] = 'url'; $downloadableData['downloadable']['link'][$key]['sample']['url'] = $link['sample']['sample_url']; } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/CatalogProductDownloadable/CatalogProductDownloadableInterface.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProductInjectable/DownloadableProductInjectableInterface.php similarity index 82% rename from dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/CatalogProductDownloadable/CatalogProductDownloadableInterface.php rename to dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProductInjectable/DownloadableProductInjectableInterface.php index 847a2a03e842aadf2f2ea7dd4e4712a7f002366f..68c99d00e9da3c3e6d3f447c60dd3296dc18c83a 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/CatalogProductDownloadable/CatalogProductDownloadableInterface.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProductInjectable/DownloadableProductInjectableInterface.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Downloadable\Test\Handler\CatalogProductDownloadable; +namespace Magento\Downloadable\Test\Handler\DownloadableProductInjectable; use Mtf\Handler\HandlerInterface; /** - * Interface CatalogProductDownloadableInterface + * Interface DownloadableProductInjectableInterface */ -interface CatalogProductDownloadableInterface extends HandlerInterface +interface DownloadableProductInjectableInterface extends HandlerInterface { // } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Page/Product/CatalogProductView.xml index 70a710dcc93fc2e6e675ca07c0dbf18d55ea0544..dddbac2df830385726a7c33f2c01566e7b875c67 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Page/Product/CatalogProductView.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Page/Product/CatalogProductView.xml @@ -25,10 +25,12 @@ --> <page mca="catalog/product/view"> <blocks> - <downloadableViewBlock> - <class>Magento\Downloadable\Test\Block\Catalog\Product\View</class> - <locator>.product-info-main</locator> - <strategy>css selector</strategy> - </downloadableViewBlock> + <viewBlock> + <renders> + <downloadable> + <class>Magento\Downloadable\Test\Block\Catalog\Product\View</class> + </downloadable> + </renders> + </viewBlock> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/CatalogProductDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php similarity index 70% rename from dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/CatalogProductDownloadable.php rename to dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php index 69f62020455072ab10d9b9579fde9367acb144d5..42b9cc14d7aaf6401a6c4be6df95e012bac91bb3 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/CatalogProductDownloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php @@ -27,10 +27,10 @@ namespace Magento\Downloadable\Test\Repository; use Mtf\Repository\AbstractRepository; /** - * Class CatalogProductDownloadable + * Class DownloadableProductInjectable * Data for creation Catalog Product Downloadable */ -class CatalogProductDownloadable extends AbstractRepository +class DownloadableProductInjectable extends AbstractRepository { /** * Constructor @@ -58,6 +58,23 @@ class CatalogProductDownloadable extends AbstractRepository 'is_virtual' => 'Yes', 'downloadable_links' => ['preset' => 'default'], 'website_ids' => ['Main Website'], + 'checkout_data' => ['preset' => 'default'] + ]; + $this->_data['with_two_separately_links'] = [ + 'name' => 'Downloadable product %isolation%', + 'sku' => 'downloadable_product_%isolation%', + 'url_key' => 'downloadable-product-%isolation%', + 'price' => ['value' => '20'], + 'tax_class_id' => ['dataSet' => 'Taxable Goods'], + 'quantity_and_stock_status' => [ + 'qty' => 1111, + 'is_in_stock' => 'In Stock' + ], + 'status' => 'Product online', + 'visibility' => 'Catalog, Search', + 'is_virtual' => 'Yes', + 'downloadable_links' => ['preset' => 'with_two_separately_links'], + 'checkout_data' => ['preset' => 'with_two_separately_links'] ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php index 9b064e8544a6989f68ee532ed00918414350639f..bbc5127ffd858595b811ca24e084bdabf23eb599 100755 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php @@ -105,26 +105,30 @@ class LinksPurchasedSeparatelyTest extends Functional $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); - $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName())); - $productListBlock->openProductViewPage($product->getName()); - $productViewBlock = $productPage->getDownloadableViewBlock(); + $productListBlock->openProductViewPage($product->getName()); + $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); $this->assertEquals( - sprintf('%1.2f', $product->getProductPrice()), - $productViewBlock->getProductPrice()['price_regular_price'] - ); - - $this->assertEquals( - $productPage->getDownloadableViewBlock()->getDownloadableLinksBlock()->getItemTitle(1), - $product->getData('fields/downloadable_links/value/downloadable/link/0/title') + number_format($product->getProductPrice(), 2), + $productViewBlock->getPriceBlock()->getPrice() ); - $this->assertEquals( - sprintf('$%1.2f', $product->getData('fields/downloadable_links/value/downloadable/link/0/price')), - $productPage->getDownloadableViewBlock()->getDownloadableLinksBlock()->getItemPrice(1) - ); + $productDownloadableLinks = $product->getData('fields/downloadable_links/value/downloadable/link'); + $pageOptions = $productViewBlock->getOptions($product); + $pageDownloadableOptions = $pageOptions['downloadable_options']['downloadable_links']; + $pageDownloadableLinks = $pageDownloadableOptions['downloadable']['link']; + foreach ($productDownloadableLinks as $key => $link) { + $this->assertEquals( + $pageDownloadableLinks[$key]['title'], + $link['title'] + ); + $this->assertEquals( + $pageDownloadableLinks[$key]['price'], + $link['price'] + ); + } } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php index d10086c72ebddb0ab5d97643635e5f77e54b87ac..27e04d5bbb24fbe510a1ccf8235c3100a1d32600 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php @@ -28,7 +28,7 @@ use Mtf\TestCase\Injectable; use Magento\Catalog\Test\Fixture\CatalogCategory; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\Downloadable\Test\Fixture\CatalogProductDownloadable; +use Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; /** * Test Creation for Create DownloadableProductEntity @@ -103,11 +103,11 @@ class CreateDownloadableProductEntityTest extends Injectable /** * Test create downloadable product * - * @param CatalogProductDownloadable $product + * @param DownloadableProductInjectable $product * @param CatalogCategory $category * @return void */ - public function testCreateDownloadableProduct(CatalogProductDownloadable $product, CatalogCategory $category) + public function testCreateDownloadableProduct(DownloadableProductInjectable $product, CatalogCategory $category) { $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('downloadable'); diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest/testCreateDownloadableProduct.csv b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest/testCreateDownloadableProduct.csv index 1a84344a633592e923de242cb4804ac54ad28ad9..bdb8d901464726f8ba558d6abad954d430e78a7c 100755 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest/testCreateDownloadableProduct.csv +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest/testCreateDownloadableProduct.csv @@ -1,15 +1,15 @@ -"product/data/name";"product/data/sku";"product/data/price/value";"product/data/tax_class_id/dataSet";"product/data/quantity_and_stock_status/qty";"product/data/quantity_and_stock_status/is_in_stock";"product/data/is_virtual";"product/data/category";"product/data/description";"product/data/short_description";"product/data/stock_data/manage_stock";"product/data/stock_data/qty";"product/data/stock_data/use_config_min_qty";"product/data/stock_data/min_qty";"product/data/downloadable_sample/preset";"product/data/downloadable_links/preset";"product/data/custom_options/preset";"product/data/custom_options/import_products";"product/data/special_price";"product/data/group_price/preset";"product/data/tier_price/preset";"constraint";"issue" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"100";"Taxable Goods";"1";"In Stock";"Yes";"Default Category";"-";"-";"-";"-";"-";"-";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductVisibleInCategory, assertProductPage, assertProductInStock";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"1";"Taxable Goods";"10";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"default";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductVisibleInCategory, assertDownloadableSamplesData, assertDownloadableLinksData";"Bug: MAGETWO-26676" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"33";"Taxable Goods";"10";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"-";"default";"default";"-";"-";"-";"-";"assertProductSaveMessage, assertDownloadableProductForm, assertProductCustomOptionsOnProductPage, assertProductVisibleInCategory, assertProductPage, assertDownloadableLinksData";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"55";"Taxable Goods";"10";"In Stock";"Yes";"-";"-";"-";"-";"-";"-";"-";"with_three_samples";"with_three_links";"two_options";"-";"-";"-";"-";"assertProductSaveMessage, assertProductCustomOptionsOnProductPage, assertProductInGrid, assertDownloadableProductForm, assertProductVisibleInCategory, assertProductPage, assertDownloadableLinksData, assertProductInStock, assertProductSearchableBySku";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"100";"Taxable Goods";"50";"Out of Stock";"Yes";"Default Category";"-";"-";"-";"-";"-";"-";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductOutOfStock, assertProductInGrid, assertDownloadableProductForm";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"9999";"Taxable Goods";"-";"-";"Yes";"Default Category";"-";"-";"Yes";"123";"No";"123";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductOutOfStock";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"98";"None";"5";"In Stock";"Yes";"Default Category";"This is description for downloadable product";"-";"-";"-";"-";"-";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"57";"Taxable Goods";"10";"In Stock";"Yes";"category %isolation%";"-";"This is short description for downloadable product";"-";"-";"-";"-";"default";"with_three_links";"default";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertProductCustomOptionsOnProductPage, assertDownloadableSamplesData, assertDownloadableLinksData";"Bug: MAGETWO-26676" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"65";"Taxable Goods";"11";"In Stock";"Yes";"category %isolation%";"This is description for downloadable product";"This is short description for downloadable product";"-";"-";"-";"-";"default";"with_three_links";"default";"-";"-";"-";"-";"assertProductSaveMessage, assertProductPage, assertProductInGrid, assertDownloadableProductForm, assertProductCustomOptionsOnProductPage, assertDownloadableSamplesData, assertDownloadableLinksData";"Bug: MAGETWO-26676" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"65";"Taxable Goods";"11";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"default";"with_three_links";"default";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertDownloadableLinksData, assertProductCustomOptionsOnProductPage";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"100";"Taxable Goods";"-";"-";"Yes";"Default Category";"-";"-";"-";"-";"-";"-";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertDownloadableProductForm, assertProductVisibleInCategory, assertProductPage";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"10";"Taxable Goods";"10";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"5";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertProductSpecialPriceOnProductPage";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"365";"Taxable Goods";"23";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"default";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertProductGroupedPriceOnProductPage";"" -"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"250";"Taxable Goods";"65";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"default";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertProductTierPriceOnProductPage";"Bug: MAGETWO-26853" +"product/data/name";"product/data/sku";"product/data/price/value";"product/data/tax_class_id/dataSet";"product/data/quantity_and_stock_status/qty";"product/data/quantity_and_stock_status/is_in_stock";"product/data/is_virtual";"product/data/category";"product/data/description";"product/data/short_description";"product/data/stock_data/manage_stock";"product/data/stock_data/qty";"product/data/stock_data/use_config_min_qty";"product/data/stock_data/min_qty";"product/data/downloadable_sample/preset";"product/data/downloadable_links/preset";"product/data/custom_options/preset";"product/data/custom_options/import_products";"product/data/special_price";"product/data/group_price/preset";"product/data/tier_price/preset";"constraint"; +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"100";"Taxable Goods";"1";"In Stock";"Yes";"Default Category";"-";"-";"-";"-";"-";"-";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductVisibleInCategory, assertProductPage, assertProductInStock" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"1";"Taxable Goods";"10";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"default";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductVisibleInCategory, assertDownloadableSamplesData, assertDownloadableLinksData" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"33";"Taxable Goods";"10";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"-";"default";"default";"-";"-";"-";"-";"assertProductSaveMessage, assertDownloadableProductForm, assertProductCustomOptionsOnProductPage, assertProductVisibleInCategory, assertProductPage, assertDownloadableLinksData" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"55";"Taxable Goods";"10";"In Stock";"Yes";"-";"-";"-";"-";"-";"-";"-";"with_three_samples";"with_three_links";"two_options";"-";"-";"-";"-";"assertProductSaveMessage, assertProductCustomOptionsOnProductPage, assertProductInGrid, assertDownloadableProductForm, assertProductVisibleInCategory, assertProductPage, assertDownloadableLinksData, assertProductInStock, assertProductSearchableBySku" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"100";"Taxable Goods";"50";"Out of Stock";"Yes";"Default Category";"-";"-";"-";"-";"-";"-";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductOutOfStock, assertProductInGrid, assertDownloadableProductForm" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"9999";"Taxable Goods";"-";"-";"Yes";"Default Category";"-";"-";"Yes";"123";"No";"123";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductOutOfStock" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"98";"None";"5";"In Stock";"Yes";"Default Category";"This is description for downloadable product";"-";"-";"-";"-";"-";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"57";"Taxable Goods";"10";"In Stock";"Yes";"category %isolation%";"-";"This is short description for downloadable product";"-";"-";"-";"-";"default";"with_three_links";"default";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertProductCustomOptionsOnProductPage, assertDownloadableSamplesData, assertDownloadableLinksData" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"65";"Taxable Goods";"11";"In Stock";"Yes";"category %isolation%";"This is description for downloadable product";"This is short description for downloadable product";"-";"-";"-";"-";"default";"with_three_links";"default";"-";"-";"-";"-";"assertProductSaveMessage, assertProductPage, assertProductInGrid, assertDownloadableProductForm, assertProductCustomOptionsOnProductPage, assertDownloadableSamplesData, assertDownloadableLinksData" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"65";"Taxable Goods";"11";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"default";"with_three_links";"default";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertDownloadableLinksData, assertProductCustomOptionsOnProductPage" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"100";"Taxable Goods";"-";"-";"Yes";"Default Category";"-";"-";"-";"-";"-";"-";"-";"default";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertDownloadableProductForm, assertProductVisibleInCategory, assertProductPage" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"10";"Taxable Goods";"10";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"5";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertProductSpecialPriceOnProductPage" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"365";"Taxable Goods";"23";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"default";"-";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertProductGroupedPriceOnProductPage" +"DownloadableProduct_%isolation%";"DownloadableProduct_%isolation%";"250";"Taxable Goods";"65";"In Stock";"Yes";"category %isolation%";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"default";"assertProductSaveMessage, assertProductInGrid, assertDownloadableProductForm, assertProductPage, assertProductTierPriceOnProductPage" diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php index 0f8267503003352b415dd68a9c2b75aeec228652..9e1150ac5d5015e1d2b9e380ba86d2e942330a8d 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php @@ -27,7 +27,7 @@ namespace Magento\Downloadable\Test\TestCase; use Mtf\TestCase\Injectable; use Mtf\Fixture\FixtureFactory; use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\Downloadable\Test\Fixture\CatalogProductDownloadable; +use Magento\Downloadable\Test\Fixture\DownloadableProductInjectable; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; @@ -56,7 +56,7 @@ class UpdateDownloadableProductEntityTest extends Injectable /** * Downloadable product fixture * - * @var CatalogProductDownloadable + * @var DownloadableProductInjectable */ protected $product; @@ -102,7 +102,7 @@ class UpdateDownloadableProductEntityTest extends Injectable FixtureFactory $fixtureFactory ) { $this->product = $fixtureFactory->createByCode( - 'catalogProductDownloadable', + 'downloadableProductInjectable', ['dataSet' => 'default'] ); $this->product->persist(); @@ -113,11 +113,11 @@ class UpdateDownloadableProductEntityTest extends Injectable /** * Test update downloadable product * - * @param CatalogProductDownloadable $product + * @param DownloadableProductInjectable $product * @param CatalogCategory $category * @return void */ - public function testUpdateDownloadableProduct(CatalogProductDownloadable $product, CatalogCategory $category) + public function testUpdateDownloadableProduct(DownloadableProductInjectable $product, CatalogCategory $category) { $filter = ['sku' => $this->product->getSku()]; $this->catalogProductIndex->open()->getProductGrid()->searchAndOpen($filter); diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/curl/di.xml index 55ab8c434895bd16910a64a3574b62ef3c43b373..3dff02c9bf8c9e33c0325920448f47609a982bef 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/curl/di.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/curl/di.xml @@ -24,5 +24,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Downloadable\Test\Handler\CatalogProductDownloadable\CatalogProductDownloadableInterface" type="\Magento\Downloadable\Test\Handler\CatalogProductDownloadable\Curl" /> + <preference for="Magento\Downloadable\Test\Handler\DownloadableProductInjectable\DownloadableProductInjectableInterface" type="\Magento\Downloadable\Test\Handler\DownloadableProductInjectable\Curl" /> </config> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/fixture.xml index 15cf432afdb3c08a0799d81a7cd721ba7880b5eb..fb762727aa379aa747c6a203b69b5d6730daff11 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/fixture.xml @@ -24,7 +24,7 @@ */ --> <fixture> - <catalogProductDownloadable module="Magento_Downloadable"> + <downloadableProductInjectable module="Magento_Downloadable"> <type>eav</type> <entity_type>catalog_product</entity_type> <product_type>downloadable</product_type> @@ -54,5 +54,5 @@ </create_url_params> <input_prefix>product</input_prefix> </data_config> - </catalogProductDownloadable> + </downloadableProductInjectable> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php index 437a1c4c92847395752bb14b2d0f32e7356099e6..432ba599957cf5f3ccdd7eaa459a0cb3588a768f 100755 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php @@ -25,6 +25,8 @@ namespace Magento\GroupedProduct\Test\Block\Catalog\Product; use Magento\Catalog\Test\Block\Product\View as ParentView; +use Mtf\Fixture\FixtureInterface; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; /** * Class View @@ -89,4 +91,28 @@ class View extends ParentView { $this->priceBlock = str_replace('%row-number%', $index, $this->formatSpecialPrice); } + + /** + * Return product options + * + * @param FixtureInterface $product + * @return array + */ + public function getOptions(FixtureInterface $product) + { + $groupedOptions = $this->getGroupedProductBlock()->getOptions($product); + return ['grouped_options' => $groupedOptions] + parent::getOptions($product); + } + + /** + * Fill specified option for the product + * + * @param FixtureInterface $product + * @return void + */ + public function fillOptions(FixtureInterface $product) + { + $this->getGroupedProductBlock()->fill($product); + parent::fillOptions($product); + } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View/Type/Grouped.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View/Type/Grouped.php index ce889be6f7368673e68fb0c29a39ec7374e78ab0..8e911912ba8a79ccb73fcd4d46c9b1870de8df52 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View/Type/Grouped.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View/Type/Grouped.php @@ -24,7 +24,13 @@ namespace Magento\GroupedProduct\Test\Block\Catalog\Product\View\Type; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Mtf\Block\Block; +use Mtf\Client\Element\Locator; +use Mtf\Fixture\FixtureInterface; +use Magento\GroupedProduct\Test\Fixture\GroupedProduct; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; +use Mtf\Fixture\InjectableFixture; /** * Class Grouped @@ -33,11 +39,39 @@ use Mtf\Block\Block; class Grouped extends Block { /** - * Selector qty for sub product + * Selector qty for sub product by id * * @var string */ - protected $qtySubProduct = '[name="super_group[%d]"]'; + protected $qtySubProductById = '[name="super_group[%d]"]'; + + /** + * Selector for sub product block by name + * + * @var string + */ + protected $subProductByName = './/tr[./td[contains(@class,"item")] and .//*[contains(.,"%s")]]'; + + /** + * Selector for sub product name + * + * @var string + */ + protected $productName = '.product.name'; + + /** + * Selector for sub product price + * + * @var string + */ + protected $price = '.price.price'; + + /** + * Selector for qty of sub product + * + * @var string + */ + protected $qty = '[name^="super_group"]'; /** * Get qty for subProduct @@ -47,6 +81,70 @@ class Grouped extends Block */ public function getQty($subProductId) { - return $this->_rootElement->find(sprintf($this->qtySubProduct, $subProductId))->getValue(); + return $this->_rootElement->find(sprintf($this->qtySubProductById, $subProductId))->getValue(); + } + + /** + * Fill product options on view page + * + * @param FixtureInterface $product + * @return void + */ + public function fill(FixtureInterface $product) + { + /** @var GroupedProductInjectable $product */ + $associatedProducts = $product->getAssociated()['products']; + $data = $product->getCheckoutData()['options']; + + // Replace link key to label + foreach ($data as $key => $productData) { + $productKey = str_replace('product_key_', '', $productData['name']); + $data[$key]['name'] = $associatedProducts[$productKey]->getName(); + } + + // Fill + foreach ($data as $productData) { + $subProduct = $this->_rootElement->find( + sprintf($this->subProductByName, $productData['name']), + Locator::SELECTOR_XPATH + ); + $subProduct->find($this->qty)->setValue($productData['qty']); + } + } + + /** + * Return product options on view page + * + * @param FixtureInterface $product + * @return array + */ + public function getOptions(FixtureInterface $product) + { + + $options = []; + if ($product instanceof InjectableFixture) { + /** @var GroupedProductInjectable $product */ + $associatedProducts = $product->getAssociated()['products']; + } else { + // TODO: Removed after refactoring(removed) old product fixture. + /** @var GroupedProduct $product */ + $associatedProducts = $product->getAssociatedProducts(); + } + + foreach ($associatedProducts as $subProduct) { + /** @var CatalogProductSimple $subProduct */ + $subProductBlock = $this->_rootElement->find( + sprintf($this->subProductByName, $subProduct->getName()), + Locator::SELECTOR_XPATH + ); + + $options[] = [ + 'name' => $subProductBlock->find($this->productName)->getText(), + 'price' => $subProductBlock->find($this->price)->getText(), + 'qty' => $subProductBlock->find($this->qty)->getValue() + ]; + } + + return $options; } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart.php new file mode 100644 index 0000000000000000000000000000000000000000..9e9720a291c3804dfde6e3a0546341c8766ced98 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart.php @@ -0,0 +1,73 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\GroupedProduct\Test\Block\Checkout; + +use Mtf\Fixture\FixtureInterface; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; + +/** + * Class Cart + * Shopping cart block + */ +class Cart extends \Magento\Checkout\Test\Block\Cart +{ + /** + * Get cart item block + * + * @param FixtureInterface $product + * @return \Magento\Checkout\Test\Block\Cart\CartItem + */ + public function getCartItem(FixtureInterface $product) + { + return $this->blockFactory->create( + 'Magento\GroupedProduct\Test\Block\Checkout\Cart\CartItem', + [ + 'element' => $this->_rootElement, + 'config' => [ + 'associated_cart_items' => $this->findCartItems($product) + ] + ] + ); + } + + /** + * Find cart item blocks for associated products + * + * @param FixtureInterface $product + * @return array + */ + protected function findCartItems(FixtureInterface $product) + { + $cartItems = []; + + /** @var GroupedProductInjectable $product */ + $associatedProducts = $product->getAssociated()['products']; + foreach ($associatedProducts as $product) { + $cartItems[$product->getSku()] = parent::getCartItem($product); + } + + return $cartItems; + } +} diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart/CartItem.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart/CartItem.php new file mode 100644 index 0000000000000000000000000000000000000000..ea82808e17c70986df4bd243864b4aa74d58eecb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart/CartItem.php @@ -0,0 +1,124 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\GroupedProduct\Test\Block\Checkout\Cart; + +use Magento\Checkout\Test\Block\Cart\AbstractCartItem; +use Magento\Checkout\Test\Block\Cart\CartItem as CheckoutCartItem; + +/** + * Class CartItem + * Product item block on checkout page + */ +class CartItem extends AbstractCartItem +{ + /** + * Get product name + * + * @return string + */ + protected function getProductName() + { + $this->_rootElement->find($this->productName)->getText(); + } + + /** + * Get product price + * + * @return string + */ + public function getPrice() + { + $result = []; + foreach ($this->config['associated_cart_items'] as $productSku => $cartItem) { + /** @var CheckoutCartItem $cartItem */ + $result[$productSku] = $cartItem->getPrice(); + } + + return $result; + } + + /** + * Set product quantity + * + * @param array $data + * @return void + */ + public function setQty(array $data) + { + foreach ($data as $productSku => $qty) { + /** @var CheckoutCartItem $cartItem */ + $cartItem = $this->config['associated_cart_items'][$productSku]; + $cartItem->setQty($qty); + } + } + + /** + * Get product quantity + * + * @return string + */ + public function getQty() + { + $result = []; + foreach ($this->config['associated_cart_items'] as $productSku => $cartItem) { + /** @var CheckoutCartItem $cartItem */ + $result[$productSku] = $cartItem->getQty(); + } + + return $result; + } + + /** + * Get sub-total for the specified item in the cart + * + * @return string + */ + public function getSubtotalPrice() + { + $result = []; + foreach ($this->config['associated_cart_items'] as $productSku => $cartItem) { + /** @var CheckoutCartItem $cartItem */ + $result[$productSku] = $cartItem->getSubtotalPrice(); + } + + return $result; + } + + /** + * Get product options in the cart + * + * @return string + */ + public function getOptions() + { + $result = []; + foreach ($this->config['associated_cart_items'] as $productSku => $cartItem) { + /** @var CheckoutCartItem $cartItem */ + $result[$productSku] = $cartItem->getOptions(); + } + + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AbstractAssertPriceOnGroupedProductPage.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AbstractAssertPriceOnGroupedProductPage.php index bf63ed1eb9b72ad6a84cbe0a0a8194de2913fb21..81f1ff42d667522d4ef05ab1729fe7280d8d6fea 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AbstractAssertPriceOnGroupedProductPage.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AbstractAssertPriceOnGroupedProductPage.php @@ -27,7 +27,7 @@ namespace Magento\GroupedProduct\Test\Constraint; use Mtf\Client\Browser; use Mtf\Fixture\InjectableFixture; use Mtf\Constraint\AbstractConstraint; -use Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Catalog\Test\Constraint\AssertPriceOnProductPageInterface; @@ -54,7 +54,7 @@ abstract class AbstractAssertPriceOnGroupedProductPage extends AbstractConstrain /** * Verify product price on grouped product view page * - * @param CatalogProductGrouped $product + * @param GroupedProductInjectable $product * @param CatalogProductView $catalogProductView * @param AssertPriceOnProductPageInterface $object * @param Browser $browser @@ -62,7 +62,7 @@ abstract class AbstractAssertPriceOnGroupedProductPage extends AbstractConstrain * @return bool|string */ protected function processAssertPrice( - CatalogProductGrouped $product, + GroupedProductInjectable $product, CatalogProductView $catalogProductView, AssertPriceOnProductPageInterface $object, Browser $browser, @@ -74,7 +74,7 @@ abstract class AbstractAssertPriceOnGroupedProductPage extends AbstractConstrain /** @var InjectableFixture $subProduct */ foreach ($groupedData['products'] as $key => $subProduct) { //Process assertions - $catalogProductView->getGroupedViewBlock() + $catalogProductView->getViewBlock() ->{'item' . $typePrice . 'PriceProductBlock'}(++$key); $object->setErrorMessage(sprintf($this->errorMessage, $subProduct->getData('name'))); $object->assertPrice($subProduct, $catalogProductView, 'Grouped'); diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedPriceOnGroupedProductPage.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedPriceOnGroupedProductPage.php index f16bdfb2a49f71a418d4eb7dcf90db58caf55b13..be7068d61feca48456e2bb9dad1d5482874897ba 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedPriceOnGroupedProductPage.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedPriceOnGroupedProductPage.php @@ -24,12 +24,14 @@ namespace Magento\GroupedProduct\Test\Constraint; -use Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; -use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Mtf\Client\Browser; use Magento\Catalog\Test\Constraint\AssertProductGroupedPriceOnProductPage; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; /** * Class AssertGroupedPriceOnGroupedProductPage + * Assert that displayed grouped price on grouped product page equals passed from fixture */ class AssertGroupedPriceOnGroupedProductPage extends AbstractAssertPriceOnGroupedProductPage { @@ -58,15 +60,17 @@ class AssertGroupedPriceOnGroupedProductPage extends AbstractAssertPriceOnGroupe * Assert that displayed grouped price on grouped product page equals passed from fixture * * @param CatalogProductView $catalogProductView - * @param CatalogProductGrouped $product + * @param GroupedProductInjectable $product * @param AssertProductGroupedPriceOnProductPage $groupedPrice + * @param Browser $browser * @return void */ public function processAssert( CatalogProductView $catalogProductView, - CatalogProductGrouped $product, - AssertProductGroupedPriceOnProductPage $groupedPrice + GroupedProductInjectable $product, + AssertProductGroupedPriceOnProductPage $groupedPrice, + Browser $browser ) { - $this->processAssertPrice($product, $catalogProductView, $groupedPrice); + $this->processAssertPrice($product, $catalogProductView, $groupedPrice, $browser); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductsDefaultQty.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductsDefaultQty.php index 0472bb5c369e3c3775e3fd00de404be3f337de47..5e6db5afb27965578af1d4b3d804942d08425428 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductsDefaultQty.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductsDefaultQty.php @@ -25,14 +25,15 @@ namespace Magento\GroupedProduct\Test\Constraint; use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Catalog\Test\Page\Product\CatalogProductView; -use Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; /** * Class AssertGroupedProductsDefaultQty + * Assert that default qty for sub products in grouped product displays according to dataset on product page */ -class AssertGroupedProductsDefaultQty extends AbstractConstraint +class AssertGroupedProductsDefaultQty extends AbstractAssertForm { /** * Constraint severeness @@ -42,29 +43,41 @@ class AssertGroupedProductsDefaultQty extends AbstractConstraint protected $severeness = 'low'; /** - * Assert that default qty for sub products in grouped product displays according to dataset on product page. + * Assert that default qty for sub products in grouped product displays according to dataset on product page * * @param CatalogProductView $groupedProductView - * @param CatalogProductGrouped $product + * @param GroupedProductInjectable $product * @param Browser $browser * @return void */ public function processAssert( CatalogProductView $groupedProductView, - CatalogProductGrouped $product, + GroupedProductInjectable $product, Browser $browser ) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $groupedBlock = $groupedProductView->getGroupedViewBlock()->getGroupedProductBlock(); - $groupedProduct = $product->getData(); + $associatedProducts = $product->getAssociated(); + $fixtureQtyData = []; + $pageOptions = $groupedProductView->getViewBlock()->getOptions($product); + $pageQtyData = []; - foreach ($groupedProduct['associated']['assigned_products'] as $item) { - \PHPUnit_Framework_Assert::assertEquals( - $groupedBlock->getQty($item['id']), - $item['qty'], - 'Default qty for sub product "' . $item['name'] . '" in grouped product according to dataset.' - ); + foreach ($associatedProducts['assigned_products'] as $productData) { + $fixtureQtyData[] = [ + 'name' => $productData['name'], + 'qty' => $productData['qty'] + ]; } + foreach ($pageOptions['grouped_options'] as $productData) { + $pageQtyData[] = [ + 'name' => $productData['name'], + 'qty' => $productData['qty'] + ]; + } + $fixtureQtyData = $this->sortDataByPath($fixtureQtyData, '::name'); + $pageQtyData = $this->sortDataByPath($pageQtyData, '::name'); + + $error = $this->verifyData($fixtureQtyData, $pageQtyData); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); } /** diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertSpecialPriceOnGroupedProductPage.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertSpecialPriceOnGroupedProductPage.php index 340f60539cbc1b7ead14ce44f6d7332dd0d0b7a2..0e47230ab383efacea9c3a875c7dce650143685c 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertSpecialPriceOnGroupedProductPage.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertSpecialPriceOnGroupedProductPage.php @@ -24,7 +24,8 @@ namespace Magento\GroupedProduct\Test\Constraint; -use Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; +use Mtf\Client\Browser; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Catalog\Test\Constraint\AssertProductSpecialPriceOnProductPage; @@ -58,15 +59,17 @@ class AssertSpecialPriceOnGroupedProductPage extends AbstractAssertPriceOnGroupe * Assert that displayed grouped price on grouped product page equals passed from fixture * * @param CatalogProductView $catalogProductView - * @param CatalogProductGrouped $product + * @param GroupedProductInjectable $product * @param AssertProductSpecialPriceOnProductPage $specialPrice + * @param Browser $browser * @return void */ public function processAssert( CatalogProductView $catalogProductView, - CatalogProductGrouped $product, - AssertProductSpecialPriceOnProductPage $specialPrice + GroupedProductInjectable $product, + AssertProductSpecialPriceOnProductPage $specialPrice, + Browser $browser ) { - $this->processAssertPrice($product, $catalogProductView, $specialPrice); + $this->processAssertPrice($product, $catalogProductView, $specialPrice, $browser); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertTierPriceOnGroupedProductPage.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertTierPriceOnGroupedProductPage.php index 2ec5d6b127b42c1a7e18a401c5c09ca47457d583..cf70e874b09609ca37afd447a07f2c7bf575e864 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertTierPriceOnGroupedProductPage.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertTierPriceOnGroupedProductPage.php @@ -24,12 +24,14 @@ namespace Magento\GroupedProduct\Test\Constraint; -use Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; +use Mtf\Client\Browser; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Catalog\Test\Constraint\AssertProductTierPriceOnProductPage; /** * Class AssertTierPriceOnGroupedProductPage + * Assert that displayed grouped price on grouped product page equals passed from fixture */ class AssertTierPriceOnGroupedProductPage extends AbstractAssertPriceOnGroupedProductPage { @@ -58,15 +60,17 @@ class AssertTierPriceOnGroupedProductPage extends AbstractAssertPriceOnGroupedPr * Assert that displayed grouped price on grouped product page equals passed from fixture * * @param CatalogProductView $catalogProductView - * @param CatalogProductGrouped $product + * @param GroupedProductInjectable $product * @param AssertProductTierPriceOnProductPage $tierPrice + * @param Browser $browser * @return void */ public function processAssert( CatalogProductView $catalogProductView, - CatalogProductGrouped $product, - AssertProductTierPriceOnProductPage $tierPrice + GroupedProductInjectable $product, + AssertProductTierPriceOnProductPage $tierPrice, + Browser $browser ) { - $this->processAssertPrice($product, $catalogProductView, $tierPrice, 'Tier'); + $this->processAssertPrice($product, $catalogProductView, $tierPrice, $browser, 'Tier'); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/Cart/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..4451da993073a6d35a0d7419def5953b4ea93ed1 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/Cart/Item.php @@ -0,0 +1,105 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\GroupedProduct\Test\Fixture\Cart; + +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; +use Mtf\Fixture\FixtureInterface; +use Magento\Bundle\Test\Fixture\BundleProduct; + +/** + * Class Item + * Data for verify cart item block on checkout page + * + * Data keys: + * - product (fixture data for verify) + */ +class Item extends \Magento\Catalog\Test\Fixture\Cart\Item +{ + /** + * @constructor + * @param FixtureInterface $product + */ + public function __construct(FixtureInterface $product) + { + parent::__construct($product); + + /** @var GroupedProductInjectable $product */ + $associatedProducts = []; + $cartItem = []; + + foreach ($product->getAssociated()['products'] as $key => $product) { + $key = 'product_key_' . $key; + $associatedProducts[$key] = $product; + } + + // Replace key in checkout data + foreach ($this->data as $fieldName => $fieldValues) { + foreach ($fieldValues as $key => $value) { + $product = $associatedProducts[$key]; + $cartItem[$fieldName][$product->getSku()] = $value; + } + } + + // Add empty "options" field + foreach ($associatedProducts as $product) { + $cartItem['options'][$product->getSku()] = []; + } + + $this->data = array_replace($this->data, $cartItem); + } + + /** + * Persist fixture + * + * @return void + */ + public function persist() + { + // + } + + /** + * Return prepared data set + * + * @param string $key [optional] + * @return mixed + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getData($key = null) + { + return $this->data; + } + + /** + * Return data set configuration settings + * + * @return string + */ + public function getDataConfig() + { + // + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/GroupedProduct.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct.php similarity index 93% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/GroupedProduct.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct.php index 01be0918c75e9c81ff2923f6bc206b84f5703ec1..f82ec93223e0d6c9c7655855d3699007fabbc297 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/GroupedProduct.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct.php @@ -22,10 +22,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Fixture; +namespace Magento\GroupedProduct\Test\Fixture; use Mtf\System\Config; use Mtf\Factory\Factory; +use Magento\Catalog\Test\Fixture\Product; /** * Class GroupedProduct @@ -61,6 +62,16 @@ class GroupedProduct extends Product $this->_placeholders['downloadable::getProductId'] = array($this, 'productProvider'); } + /** + * Get Associated Products + * + * @return array + */ + public function getAssociatedProducts() + { + return $this->products; + } + /** * Get Associated Product Names * @@ -81,6 +92,7 @@ class GroupedProduct extends Product protected function _initData() { $this->_dataConfig = array( + 'type_id' => 'grouped', 'constraint' => 'Success', 'create_url_params' => array( 'type' => 'grouped', @@ -145,6 +157,6 @@ class GroupedProduct extends Product ); $this->_repository = Factory::getRepositoryFactory() - ->getMagentoCatalogGroupedProduct($this->_dataConfig, $this->_data); + ->getMagentoGroupedProductGroupedProduct($this->_dataConfig, $this->_data); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable.php similarity index 95% rename from dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable.php index d8ecfa6b48df209ea07b6b6c214768d6de719ec7..2cf7358439304ec2bbb3ba0ba16498fcff2f926d 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable.php @@ -32,24 +32,24 @@ use Mtf\Repository\RepositoryFactory; use Mtf\System\Event\EventManagerInterface; /** - * Class CatalogProductGrouped + * Class GroupedProductInjectable * Fixture for Grouped product * * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessivePublicCount) */ -class CatalogProductGrouped extends InjectableFixture +class GroupedProductInjectable extends InjectableFixture { /** * @var string */ - protected $repositoryClass = 'Magento\GroupedProduct\Test\Repository\CatalogProductGrouped'; + protected $repositoryClass = 'Magento\GroupedProduct\Test\Repository\GroupedProductInjectable'; // @codingStandardsIgnoreStart /** * @var string */ - protected $handlerInterface = 'Magento\GroupedProduct\Test\Handler\CatalogProductGrouped\CatalogProductGroupedInterface'; + protected $handlerInterface = 'Magento\GroupedProduct\Test\Handler\GroupedProductInjectable\GroupedProductInjectableInterface'; // @codingStandardsIgnoreEnd /** @@ -75,9 +75,6 @@ class CatalogProductGrouped extends InjectableFixture $dataSet = '', $persist = false ) { - if (!isset($data['url_key']) && isset($data['name'])) { - $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); - } parent::__construct( $configuration, $repositoryFactory, @@ -88,9 +85,13 @@ class CatalogProductGrouped extends InjectableFixture $dataSet, $persist ); + if (!isset($this->data['url_key']) && isset($this->data['name'])) { + $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); + } } protected $dataConfig = [ + 'type_id' => 'grouped', 'create_url_params' => [ 'type' => 'grouped', 'set' => '4', @@ -149,7 +150,7 @@ class CatalogProductGrouped extends InjectableFixture 'backend_type' => 'virtual', 'is_required' => '1', 'group' => 'grouped', - 'source' => 'Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped\Associated', + 'source' => 'Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable\Associated', ]; protected $custom_design_from = [ @@ -487,7 +488,14 @@ class CatalogProductGrouped extends InjectableFixture protected $price = [ 'attribute_code' => 'price', 'backend_type' => 'virtual', - 'source' => 'Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped\Price', + 'source' => 'Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable\Price', + ]; + + protected $checkout_data = [ + 'attribute_code' => 'checkout_data', + 'backend_type' => 'virtual', + 'group' => null, + 'source' => 'Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable\CheckoutData', ]; public function getCategoryIds() @@ -739,4 +747,9 @@ class CatalogProductGrouped extends InjectableFixture { return $this->getData('website_ids'); } + + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable.xml similarity index 95% rename from dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.xml rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable.xml index 69b7e75c3492c1cd80d4d5c937c0d6f19587c0fc..ce5b11fbd4a648f51e8c25b54de63c7ed68c2376 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<fixture class="Magento\Catalog\Test\Fixture\CatalogProductGrouped"> +<fixture class="Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable"> <module>Magento_Catalog</module> <type>eav</type> <entity_type>catalog_product</entity_type> @@ -327,7 +327,7 @@ <backend_type>virtual</backend_type> <group>grouped</group> <is_required>1</is_required> - <source>Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped\GroupedProducts</source> + <source>Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable\GroupedProducts</source> </associated> <type_id> <attribute_code>type_id</attribute_code> @@ -354,6 +354,12 @@ <attribute_code>stock_data</attribute_code> <group>advanced-inventory</group> </stock_data> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <source>Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable\CheckoutData</source> + </checkout_data> </fields> <data_set> <sku></sku> @@ -369,7 +375,7 @@ </create_url_params> <input_prefix>product</input_prefix> </data_config> - <repository_class>Magento\Catalog\Test\Repository\CatalogProductGrouped</repository_class> - <handler_interface>Magento\Catalog\Test\Handler\CatalogProductGrouped\CatalogProductGroupedInterface + <repository_class>Magento\Catalog\Test\Repository\GroupedProductInjectable</repository_class> + <handler_interface>Magento\Catalog\Test\Handler\GroupedProductInjectable\GroupedProductInjectableInterface </handler_interface> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped/Associated.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/Associated.php similarity index 82% rename from dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped/Associated.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/Associated.php index eee73da0d12be440a0779fe3d0083683412db8bc..cb263e9232043b12dba8866afc42a02c3d071b25 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped/Associated.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/Associated.php @@ -22,15 +22,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; +namespace Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; -use Mtf\Fixture\FixtureFactory; use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\FixtureFactory; use Mtf\Fixture\InjectableFixture; /** * Class Associated * Grouped selections preset + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ class Associated implements FixtureInterface { @@ -48,13 +50,6 @@ class Associated implements FixtureInterface */ protected $params; - /** - * Current preset - * - * @var string - */ - protected $currentPreset; - /** * Constructor * @@ -67,13 +62,10 @@ class Associated implements FixtureInterface $this->params = $params; if (isset($data['preset'])) { - $this->currentPreset = $data['preset']; - $this->data = $this->getPreset($this->currentPreset); + $this->data = $this->getPreset($data['preset']); } - $this->data['products'] = isset($data['products']) && $data['products'] != '-' - ? explode(',', $data['products']) - : $this->data['products']; + $this->data['products'] = isset($data['products']) ? explode(',', $data['products']) : $this->data['products']; foreach ($this->data['products'] as $key => $product) { list($fixture, $dataSet) = explode('::', $product); @@ -215,7 +207,34 @@ class Associated implements FixtureInterface 'catalogProductVirtual::default', 'catalogProductVirtual::50_dollar_product' ], - ] + ], + 'three_simple_products' => [ + 'assigned_products' => [ + [ + 'id' => '%id%', + 'name' => '%item1_simple::getProductName%', + 'position' => '%position%', + 'qty' => 17, + ], + [ + 'id' => '%id%', + 'name' => '%item1_simple::getProductName%', + 'position' => '%position%', + 'qty' => 36, + ], + [ + 'id' => '%id%', + 'name' => '%item1_simple::getProductName%', + 'position' => '%position%', + 'qty' => 20, + ], + ], + 'products' => [ + 'catalogProductSimple::default', + 'catalogProductSimple::40_dollar_product', + 'catalogProductSimple::100_dollar_product' + ], + ], ]; if (!isset($presets[$name])) { return null; diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/CheckoutData.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/CheckoutData.php new file mode 100644 index 0000000000000000000000000000000000000000..295c6bb955b80366d57c5358b1c5149adaad0f01 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/CheckoutData.php @@ -0,0 +1,81 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; + +/** + * Class CheckoutData + * Data for fill product form on frontend + * + * Data keys: + * - preset (Checkout data verification preset name) + */ +class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData +{ + /** + * Get preset array + * + * @param $name + * @return array|null + */ + protected function getPreset($name) + { + $presets = [ + 'three_simple_products' => [ + 'options' => [ + [ + 'name' => 'product_key_0', + 'qty' => 3 + ], + [ + 'name' => 'product_key_1', + 'qty' => 1 + ], + [ + 'name' => 'product_key_2', + 'qty' => 2 + ] + ], + 'cartItem' => [ + 'price' => [ + 'product_key_0' => 560, + 'product_key_1' => 40, + 'product_key_2' => 100, + ], + 'qty' => [ + 'product_key_0' => 3, + 'product_key_1' => 1, + 'product_key_2' => 2, + ], + 'subtotal' => [ + 'product_key_0' => 1680, + 'product_key_1' => 40, + 'product_key_2' => 200, + ], + ] + ], + ]; + return isset($presets[$name]) ? $presets[$name] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped/Price.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/Price.php similarity index 95% rename from dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped/Price.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/Price.php index f045ffde4d5b10aa3079005270d0e786bd269800..a6ac0a906a90672ff0454dc70f84cfa710f7d1a4 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped/Price.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProductInjectable/Price.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; +namespace Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; use Mtf\Fixture\FixtureInterface; use Magento\Catalog\Test\Fixture\CatalogProductSimple\Price as ParentPrice; diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/CatalogProductGrouped/Curl.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/GroupedProductInjectable/Curl.php similarity index 92% rename from dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/CatalogProductGrouped/Curl.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/GroupedProductInjectable/Curl.php index 800c541211b73c9a3dc46ce7cce672f5c413ab7f..41d32d755be7f3c7f37eda66cfed05815889c232 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/CatalogProductGrouped/Curl.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/GroupedProductInjectable/Curl.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\GroupedProduct\Test\Handler\CatalogProductGrouped; +namespace Magento\GroupedProduct\Test\Handler\GroupedProductInjectable; use Mtf\Fixture\FixtureInterface; use Mtf\Util\Protocol\CurlTransport; @@ -32,7 +32,7 @@ use Magento\Catalog\Test\Handler\CatalogProductSimple\Curl as AbstractCurl; * Class Curl * Create new grouped product via curl */ -class Curl extends AbstractCurl implements CatalogProductGroupedInterface +class Curl extends AbstractCurl implements GroupedProductInjectableInterface { /** * Prepare POST data for creating product request diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/CatalogProductGrouped/CatalogProductGroupedInterface.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/GroupedProductInjectable/GroupedProductInjectableInterface.php similarity index 83% rename from dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/CatalogProductGrouped/CatalogProductGroupedInterface.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/GroupedProductInjectable/GroupedProductInjectableInterface.php index 88fd5283d4d7e3b15c523a87cb5e7ce356686ed4..3b3a723ff60688cd196ce0ab3cd1ad2bf3816819 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/CatalogProductGrouped/CatalogProductGroupedInterface.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Handler/GroupedProductInjectable/GroupedProductInjectableInterface.php @@ -22,14 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\GroupedProduct\Test\Handler\CatalogProductGrouped; +namespace Magento\GroupedProduct\Test\Handler\GroupedProductInjectable; use Mtf\Handler\HandlerInterface; /** - * Interface CatalogProductGroupedInterface + * Interface GroupedProductInjectableInterface */ -interface CatalogProductGroupedInterface extends HandlerInterface +interface GroupedProductInjectableInterface extends HandlerInterface { // } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Page/CheckoutCart.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Page/CheckoutCart.xml new file mode 100644 index 0000000000000000000000000000000000000000..e68be1f30fb802919bbf1cc38e3e6cf280ad83ed --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Page/CheckoutCart.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="checkout/cart/index" module="Magento_Checkout"> + <blocks> + <cartBlock> + <renders> + <grouped> + <class>Magento\GroupedProduct\Test\Block\Checkout\Cart</class> + </grouped> + </renders> + </cartBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Page/Product/CatalogProductView.xml index a981fcd6ce3249452a03b9342c27d1483e9b524f..f59d700538cdbd08871280121229ab4259b23b26 100755 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Page/Product/CatalogProductView.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Page/Product/CatalogProductView.xml @@ -25,10 +25,12 @@ --> <page mca="catalog/product/view"> <blocks> - <groupedViewBlock> - <class>Magento\GroupedProduct\Test\Block\Catalog\Product\View</class> - <locator>.product-info-main</locator> - <strategy>css selector</strategy> - </groupedViewBlock> + <viewBlock> + <renders> + <grouped> + <class>Magento\GroupedProduct\Test\Block\Catalog\Product\View</class> + </grouped> + </renders> + </viewBlock> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/GroupedProduct.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.php similarity index 85% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/GroupedProduct.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.php index 90a8004d0b60d4ab8704be1f608a393c0e61c591..873ae7a0e2f3ff1612771bcf50df4417dc85617e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/GroupedProduct.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.php @@ -22,12 +22,15 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Repository; +namespace Magento\GroupedProduct\Test\Repository; + +use Magento\Catalog\Test\Repository\Product; /** - * Class Category Repository - * + * Class GroupedProduct + * Repository for Grouped product */ class GroupedProduct extends Product { + // } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/CatalogProductGrouped.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProductInjectable.php similarity index 80% rename from dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/CatalogProductGrouped.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProductInjectable.php index 7ab94432e2492f3a88af2034ac29ea0817736839..b8ca856772bb8d24f86a6882b2269a9fde2180d8 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/CatalogProductGrouped.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProductInjectable.php @@ -27,10 +27,10 @@ namespace Magento\GroupedProduct\Test\Repository; use Mtf\Repository\AbstractRepository; /** - * Class CatalogProductGrouped + * Class GroupedProductInjectable * Data for creation Catalog Product Grouped */ -class CatalogProductGrouped extends AbstractRepository +class GroupedProductInjectable extends AbstractRepository { /** * Constructor @@ -90,5 +90,22 @@ class CatalogProductGrouped extends AbstractRepository 'website_ids' => ['Main Website'], 'attribute_set_id' => ['dataSet' => 'default'], ]; + + $this->_data['three_simple_products'] = [ + 'name' => 'Grouped product %isolation%', + 'sku' => 'grouped_product_%isolation%', + 'category_ids' => ['presets' => 'default'], + 'associated' => ['preset' => 'three_simple_products'], + 'status' => 'Product online', + 'visibility' => 'Catalog, Search', + 'tax_class_id' => ['dataSet' => 'Taxable Goods'], + 'url_key' => 'test-grouped-product-%isolation%', + 'quantity_and_stock_status' => [ + 'is_in_stock' => 'In Stock', + ], + 'website_ids' => ['Main Website'], + 'attribute_set_id' => ['dataSet' => 'default'], + 'checkout_data' => ['preset' => 'three_simple_products'], + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php index 04ea3664ed7b77a1fc6373aa51cdc770fee99e75..28fb4ddf0f37722ccaf8e21a62aaf44c3873461d 100755 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php @@ -26,7 +26,7 @@ namespace Magento\GroupedProduct\Test\TestCase; use Mtf\TestCase\Injectable; use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; @@ -96,11 +96,11 @@ class CreateGroupedProductEntityTest extends Injectable /** * Test create grouped product * - * @param CatalogProductGrouped $product + * @param GroupedProductInjectable $product * @param CatalogCategory $category * @return void */ - public function test(CatalogProductGrouped $product, CatalogCategory $category) + public function test(GroupedProductInjectable $product, CatalogCategory $category) { //Steps $this->catalogProductIndex->open(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedTest.php similarity index 88% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php rename to dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedTest.php index 08d3bfb537aee3fece265e111016c97e87e00619..b5f3d5542d1a994cebd50afd29e130c9731767a7 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedTest.php @@ -22,11 +22,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\TestCase\Product; +namespace Magento\GroupedProduct\Test\TestCase; use Mtf\Factory\Factory; use Mtf\TestCase\Functional; -use Magento\Catalog\Test\Fixture\GroupedProduct; +use Magento\GroupedProduct\Test\Fixture\GroupedProduct; /** * Class CreateGroupedTest @@ -54,7 +54,7 @@ class CreateGroupedTest extends Functional public function testCreateGroupedProduct() { //Data - $product = Factory::getFixtureFactory()->getMagentoCatalogGroupedProduct(); + $product = Factory::getFixtureFactory()->getMagentoGroupedProductGroupedProduct(); $product->switchData('grouped'); //Page & Blocks $manageProductsGrid = Factory::getPageFactory()->getCatalogProductIndex(); @@ -67,7 +67,7 @@ class CreateGroupedTest extends Functional $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); - // Flush cache + //Flush cache $cachePage = Factory::getPageFactory()->getAdminCache(); $cachePage->open(); $cachePage->getActionsBlock()->flushMagentoCache(); @@ -127,6 +127,12 @@ class CreateGroupedTest extends Functional $productViewBlock->getProductName(), 'Product name does not correspond to specified.' ); - $this->assertTrue($productViewBlock->verifyGroupedProducts($product), 'Added Grouped options are absent'); + + $optionsOnPage = $productViewBlock->getOptions($product); + $pageAssociatedProductNames = []; + foreach ($optionsOnPage['grouped_options'] as $optionOnPage) { + $pageAssociatedProductNames[] = $optionOnPage['name']; + } + $this->assertEquals($product->getAssociatedProductNames(), $pageAssociatedProductNames); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php index cce5f8a4976e07fd17569451b946a3c3c178b3db..caacf61a6052cf68934d80f24e133fa45318fdd4 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php @@ -27,7 +27,7 @@ namespace Magento\GroupedProduct\Test\TestCase; use Mtf\TestCase\Injectable; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\GroupedProduct\Test\Fixture\CatalogProductGrouped; +use Magento\GroupedProduct\Test\Fixture\GroupedProductInjectable; /** * Test Creation for Update GroupedProductEntity @@ -82,11 +82,11 @@ class UpdateGroupedProductEntityTest extends Injectable /** * Test update grouped product * - * @param CatalogProductGrouped $product - * @param CatalogProductGrouped $originalProduct + * @param GroupedProductInjectable $product + * @param GroupedProductInjectable $originalProduct * @return void */ - public function test(CatalogProductGrouped $product, CatalogProductGrouped $originalProduct) + public function test(GroupedProductInjectable $product, GroupedProductInjectable $originalProduct) { // Precondition $originalProduct->persist(); diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/etc/curl/di.xml index 787da2ccf44a910b74a7fc1e07119f566a0534e5..c9e0d69b180f124ef7f5850ef59433bd5629841b 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/etc/curl/di.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/etc/curl/di.xml @@ -24,5 +24,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\GroupedProduct\Test\Handler\CatalogProductGrouped\CatalogProductGroupedInterface" type="\Magento\GroupedProduct\Test\Handler\CatalogProductGrouped\Curl" /> + <preference for="Magento\GroupedProduct\Test\Handler\GroupedProductInjectable\GroupedProductInjectableInterface" type="\Magento\GroupedProduct\Test\Handler\GroupedProductInjectable\Curl" /> </config> diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/etc/fixture.xml index 8c5d35ae0c9f71f74bfe4d9ae3f61870086b43b5..190afa8506d96161392c3739a61c176440c5fee7 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/etc/fixture.xml @@ -24,7 +24,7 @@ */ --> <fixture> - <catalogProductGrouped module="Magento_GroupedProduct"> + <groupedProductInjectable module="Magento_GroupedProduct"> <type>eav</type> <entity_type>catalog_product</entity_type> <product_type>grouped</product_type> @@ -51,5 +51,5 @@ </create_url_params> <input_prefix>product</input_prefix> </data_config> - </catalogProductGrouped> + </groupedProductInjectable> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Sold/Grid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Sold/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..a8d5b49f26812aa7fbec3e01f1565251eb553289 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Sold/Grid.php @@ -0,0 +1,123 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Block\Adminhtml\Product\Sold; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Mtf\ObjectManager; +use Mtf\Client\Element\Locator; + +/** + * Class Grid + * Ordered Products Report grid + */ +class Grid extends \Magento\Backend\Test\Block\Widget\Grid +{ + /** + * Mapping for fields in Ordered Products Report Grid + * + * @var array + */ + protected $dataMapping = [ + 'report_from' => 'datepicker', + 'report_to' => 'datepicker', + 'report_period' => 'select', + ]; + + /** + * Product in grid locator + * + * @var string + */ + protected $product = './/*[contains(.,"%s")]/*[contains(@class,"col-qty")]'; + + /** + * Filter locator + * + * @var string + */ + protected $filter = '[name=%s]'; + + /** + * Refresh button locator + * + * @var string + */ + protected $refreshButton = '[data-ui-id="adminhtml-report-grid-refresh-button"]'; + + /** + * Search accounts in report grid + * + * @var array $customersReport + * @return void + */ + public function searchAccounts(array $customersReport) + { + $customersReport = $this->prepareData($customersReport); + foreach ($customersReport as $name => $value) { + $this->_rootElement + ->find(sprintf($this->filter, $name), Locator::SELECTOR_CSS, $this->dataMapping[$name]) + ->setValue($value); + } + $this->_rootElement->find($this->refreshButton)->click(); + } + + /** + * Prepare data + * + * @param array $customersReport + * @return array + */ + protected function prepareData(array $customersReport) + { + foreach ($customersReport as $name => $reportFilter) { + if ($name === 'report_period') { + continue; + } + $date = ObjectManager::getInstance()->create( + '\Magento\Backend\Test\Fixture\Date', + ['params' => [], 'data' => ['pattern' => $reportFilter]] + ); + $customersReport[$name] = $date->getData(); + } + return $customersReport; + } + + /** + * Get orders quantity from Ordered Products Report grid + * + * @param OrderInjectable $order + * @return array + */ + public function getOrdersResults(OrderInjectable $order) + { + $products = $order->getEntityId()['products']; + $views = []; + foreach ($products as $key => $product) { + $views[$key] = $this->_rootElement + ->find(sprintf($this->product, $product->getName()), Locator::SELECTOR_XPATH)->getText(); + } + return $views; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/Action.php similarity index 95% rename from dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/Action.php index bccabb9ab184b7da74044e94ffa87ee23caf8476..08d497acfc1e59d43b313f581bfbac76ec84abd1 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/Action.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed; +namespace Magento\Reports\Test\Block\Adminhtml\Product\Viewed; use Magento\Backend\Test\Block\GridPageActions; diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/Filter.php similarity index 96% rename from dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/Filter.php index 9f808c067f343c4a33cbf36529d92057d4bec86b..6358623e20621c9d6acb9400f3dcc3eb182273c5 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/Filter.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed; +namespace Magento\Reports\Test\Block\Adminhtml\Product\Viewed; use Mtf\Block\Form; use Mtf\ObjectManager; diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/Filter.xml similarity index 100% rename from dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/Filter.xml diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/ProductGrid.php similarity index 69% rename from dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/ProductGrid.php index a98e434e52f4f3ed8fbfd1ff9d36b80c6b390800..43c2bebd7e4d3482b4436c3cdfbdf96028545d55 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Viewed/ProductGrid.php @@ -22,8 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed; +namespace Magento\Reports\Test\Block\Adminhtml\Product\Viewed; +use Mtf\Client\Element\Locator; use Magento\Backend\Test\Block\Widget\Grid; /** @@ -50,15 +51,23 @@ class ProductGrid extends Grid * Get views Results from Products Report grid * * @param array $products + * @param string $date * @return array */ - public function getViewsResults(array $products) + public function getViewsResults(array $products, $date = '') { $views = []; + $date = date($date); + if ($date) { + $text = $this->_rootElement->getText(); + preg_match("`$date([^\n]*\n){1,5}`", $text, $match); + } foreach ($products as $product) { - $views[] = $this->_rootElement - ->find(sprintf($this->product . $this->productView, $product->getName(), $product->getPrice())) - ->getText(); + if (isset($match[0]) && !strstr($match[0], $product->getName())) { + continue; + } + $productLocator = sprintf($this->product . $this->productView, $product->getName(), $product->getPrice()); + $views[] = $this->_rootElement->find($productLocator, Locator::SELECTOR_XPATH)->getText(); } return $views; } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Refresh/Statistics/Grid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Refresh/Statistics/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..efbb94e879cc148a20409c65b2bee9e03b3710e7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Refresh/Statistics/Grid.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Block\Adminhtml\Refresh\Statistics; + +use Magento\Backend\Test\Block\Widget\Grid as AbstractGrid; +use Mtf\Client\Element\Locator; + +/** + * Class Grid + * Refresh statistics grid + */ +class Grid extends AbstractGrid +{ + /** + * An element locator which allows to select entities in grid + * + * @var string + */ + protected $selectItem = '//tr[td[contains(@class,"col-report") and normalize-space(.)="%s"]]//input'; + + /** + * Search for item and select it + * + * @param array $filter + * @throws \Exception + * @return void + */ + public function searchAndSelect(array $filter) + { + $selectItem = $this->_rootElement->find(sprintf($this->selectItem, $filter['report']), Locator::SELECTOR_XPATH); + if ($selectItem->isVisible()) { + $selectItem->click(); + } else { + throw new \Exception('Searched item was not found.'); + } + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/PaymentMethodBuilder.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Action.php similarity index 64% rename from app/code/Magento/Checkout/Service/V1/Data/PaymentMethodBuilder.php rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Action.php index 58c58b9e091527efefe6aebca3864ac98bb52f8f..7a8d4867c1379d11765b669d3055045a79e895a1 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/PaymentMethodBuilder.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Action.php @@ -22,32 +22,30 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Checkout\Service\V1\Data; +namespace Magento\Reports\Test\Block\Adminhtml\Sales\Coupons; + +use Magento\Backend\Test\Block\GridPageActions; /** - * @method PaymentMethod create() + * Class Action + * Action block for Coupons Views Report */ -class PaymentMethodBuilder extends \Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder +class Action extends GridPageActions { /** - * Set payment method code + * Show Report button * - * @param string $value - * @return $this + * @var string */ - public function setCode($value) - { - return $this->_set(PaymentMethod::CODE, $value); - } + protected $showReportButton = '#filter_form_submit'; /** - * Set payment method title + * Show report button click * - * @param string $value - * @return $this + * @return void */ - public function setTitle($value) + public function showReport() { - return $this->_set(PaymentMethod::TITLE, $value); + $this->_rootElement->find($this->showReportButton)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Filter.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Filter.php new file mode 100644 index 0000000000000000000000000000000000000000..1e6594dd135fae19686e0b8bfe10f862ffc000db --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Filter.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Block\Adminhtml\Sales\Coupons; + +use Mtf\Block\Form; +use Mtf\ObjectManager; + +/** + * Class Filter + * Filter for Coupons Views Report + */ +class Filter extends Form +{ + /** + * Search coupons in report grid + * + * @var array $productsReport + * @return void + */ + public function viewsReport(array $viewsReport) + { + $viewsReport = $this->prepareData($viewsReport); + $data = $this->dataMapping($viewsReport); + $this->_fill($data); + } + + /** + * Prepare data + * + * @param array $viewsReport + * @return array + */ + protected function prepareData(array $viewsReport) + { + foreach ($viewsReport as $name => $reportFilter) { + if ($reportFilter == '-') { + unset($viewsReport[$name]); + } + if ($name === 'from' || $name === 'to') { + $date = ObjectManager::getInstance()->create( + '\Magento\Backend\Test\Fixture\Date', + ['params' => [], 'data' => ['pattern' => $reportFilter]] + ); + $viewsReport[$name] = $date->getData(); + } + } + return $viewsReport; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Filter.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Filter.xml new file mode 100644 index 0000000000000000000000000000000000000000..807b8c3de4e708847ff09de193f48561d805b0eb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Filter.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<mapping strict="0"> + <fields> + <report_type> + <input>select</input> + </report_type> + <period_type> + <input>select</input> + </period_type> + <from> + <input>datepicker</input> + </from> + <to> + <input>datepicker</input> + </to> + <show_order_statuses> + <input>select</input> + </show_order_statuses> + <show_empty_rows> + <input>select</input> + </show_empty_rows> + <price_rule_type> + <input>select</input> + </price_rule_type> + <order_statuses> + <selector>[name="order_statuses[]"]</selector> + <input>multiselect</input> + </order_statuses> + <rules_list> + <selector>[name="rules_list[]"]</selector> + <input>multiselect</input> + </rules_list> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Grid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..450e532f8249b4b5d5571cd5e364b7bccc3bde14 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Grid.php @@ -0,0 +1,52 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Block\Adminhtml\Sales\Coupons; + +/** + * Class Grid + * Coupons report grid + */ +class Grid extends \Magento\Backend\Test\Block\Widget\Grid +{ + /** + * Filters array mapping + * + * @var array + */ + protected $filters = [ + 'coupon_code' => [ + 'selector' => '.col-coupon_code', + ], + 'rule_name' => [ + 'selector' => '.col-rule_name' + ], + 'subtotal' => [ + 'selector' => '.col-subtotal' + ], + 'discount' => [ + 'selector' => '.col-discount' + ] + ]; +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertBestsellerReportResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertBestsellerReportResult.php new file mode 100644 index 0000000000000000000000000000000000000000..4be59b9b37994d6332be13ae41e8316f9a0ca9e9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertBestsellerReportResult.php @@ -0,0 +1,76 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Reports\Test\Page\Adminhtml\Bestsellers; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; + +/** + * Class AssertBestsellerReportResult + * Assert bestseller info in report: date, product name and qty + */ +class AssertBestsellerReportResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert bestseller info in report: date, product name and qty + * + * @param Bestsellers $bestsellers + * @param OrderInjectable $order + * @param string $date + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function processAssert(Bestsellers $bestsellers, OrderInjectable $order, $date) + { + $products = $order->getEntityId()['products']; + $totalQuantity = $bestsellers->getGridBlock()->getViewsResults($products, $date); + $productQty = []; + foreach ($products as $key => $product) { + /** @var CatalogProductSimple $product*/ + $productQty[$key] = $product->getCheckoutData()['qty']; + } + \PHPUnit_Framework_Assert::assertEquals($productQty, $totalQuantity); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Bestseller total result is equals to data from dataSet.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertCouponReportResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertCouponReportResult.php new file mode 100644 index 0000000000000000000000000000000000000000..71956d30cc36e238030e82a31a88b5b35a3133ef --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertCouponReportResult.php @@ -0,0 +1,80 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Reports\Test\Page\Adminhtml\SalesCouponReportView; + +/** + * Class AssertCouponReportResult + * Assert coupon info in report: code, rule name, subtotal, discount on coupons report page + */ +class AssertCouponReportResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert coupon info in report: code, rule name, subtotal, discount on coupons report page + * + * @param SalesCouponReportView $salesCouponReportView + * @param OrderInjectable $order + * @param string $currency + * @return void + */ + public function processAssert(SalesCouponReportView $salesCouponReportView, OrderInjectable $order, $currency = '$') + { + $data = $order->getData(); + $discount = $data['price']['discount'] != 0 + ? '-' . $currency . number_format($data['price']['discount'], 2) + : $currency . '0.00'; + $roleName = $data['coupon_code']->getName(); + $filter = [ + 'coupon_code' => $data['coupon_code']->getCouponCode(), + 'rule_name' => $roleName, + 'subtotal' => $currency . number_format($data['price']['subtotal'], 2), + 'discount' => $discount + ]; + \PHPUnit_Framework_Assert::assertTrue( + $salesCouponReportView->getGridBlock()->isRowVisible($filter, false), + "Coupon '$roleName' is not visible." + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return "Coupon info is correct on coupons report page."; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertOrderedProductResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertOrderedProductResult.php new file mode 100644 index 0000000000000000000000000000000000000000..5fb436aa0abb769607ec060c7aa3dc648d6c43bb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertOrderedProductResult.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Constraint; + +use Magento\Reports\Test\Page\Adminhtml\OrderedProductsReport; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Mtf\Constraint\AbstractConstraint; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; + +/** + * Class AssertOrderedProductResult + * Assert product name and qty in Ordered Products report + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ +class AssertOrderedProductResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert product name and qty in Ordered Products report + * + * @param OrderedProductsReport $orderedProducts + * @param OrderInjectable $order + * @return void + */ + public function processAssert(OrderedProductsReport $orderedProducts, OrderInjectable $order) + { + $products = $order->getEntityId()['products']; + $totalQuantity = $orderedProducts->getGridBlock()->getOrdersResults($order); + $productQty = []; + + foreach ($totalQuantity as $key => $value) { + /** @var CatalogProductSimple $product */ + $product = $products[$key]; + $productQty[$key] = $product->getCheckoutData()['qty']; + } + \PHPUnit_Framework_Assert::assertEquals($totalQuantity, $productQty); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Ordered Products result is equals to data from fixture.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Bestsellers.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Bestsellers.xml new file mode 100644 index 0000000000000000000000000000000000000000..60c537110ec2ff97388e79277fec48b3297ea5e7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Bestsellers.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="reports/report_sales/bestsellers" module="Magento_Reports"> + <blocks> + <messagesBlock> + <class>Magento\Core\Test\Block\Messages</class> + <locator>#messages .messages</locator> + <strategy>css selector</strategy> + </messagesBlock> + <actionsBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Product\Viewed\Action</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </actionsBlock> + <filterBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Product\Viewed\Filter</class> + <locator>#filter_form</locator> + <strategy>css selector</strategy> + </filterBlock> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Product\Viewed\ProductGrid</class> + <locator>.grid</locator> + <strategy>css selector</strategy> + </gridBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/OrderedProductsReport.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/OrderedProductsReport.xml new file mode 100644 index 0000000000000000000000000000000000000000..676b8935dab8c1e254572ce824dae9bffa5f7c54 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/OrderedProductsReport.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="reports/report_product/sold/" module="Magento_Reports"> + <blocks> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Product\Sold\Grid</class> + <locator>#gridProductsSold</locator> + <strategy>css selector</strategy> + </gridBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml index 32c82d39a3a778cbc370c92ad52ea27909b4b15e..fc2df3729db4ddf66eb5b30249b84e6b3c582f00 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml @@ -26,17 +26,17 @@ <page mca="reports/report_product/viewed/" module="Magento_Reports"> <blocks> <actionsBlock> - <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\Action</class> + <class>Magento\Reports\Test\Block\Adminhtml\Product\Viewed\Action</class> <locator>.page-main-actions</locator> <strategy>css selector</strategy> </actionsBlock> <gridBlock> - <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\ProductGrid</class> + <class>Magento\Reports\Test\Block\Adminhtml\Product\Viewed\ProductGrid</class> <locator>.grid</locator> <strategy>css selector</strategy> </gridBlock> <filterBlock> - <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\Filter</class> + <class>Magento\Reports\Test\Block\Adminhtml\Product\Viewed\Filter</class> <locator>#filter_form</locator> <strategy>css selector</strategy> </filterBlock> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesCouponReportView.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesCouponReportView.xml new file mode 100644 index 0000000000000000000000000000000000000000..ef26463e1cca4185e2caed20f7089890d201c696 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesCouponReportView.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="reports/report_sales/coupons" module="Magento_Reports"> + <blocks> + <filterBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Sales\Coupons\Filter</class> + <locator>#filter_form</locator> + <strategy>css selector</strategy> + </filterBlock> + <actionBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Sales\Coupons\Action</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </actionBlock> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Sales\Coupons\Grid</class> + <locator>//*[@class="grid"]/..</locator> + <strategy>xpath</strategy> + </gridBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Statistics.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Statistics.xml new file mode 100644 index 0000000000000000000000000000000000000000..41439cb77e081832624efdfff8bd128092017541 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Statistics.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="reports/report_statistics" module="Magento_Reports"> + <blocks> + <gridBlock>            + <class>Magento\Reports\Test\Block\Adminhtml\Refresh\Statistics\Grid</class>            + <locator>#gridRefreshStatistics</locator>            + <strategy>css selector</strategy>        + </gridBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/BestsellerProductsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/BestsellerProductsReportEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..07d0094314248e40249408ceabad0f1053963451 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/BestsellerProductsReportEntityTest.php @@ -0,0 +1,89 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Reports\Test\Page\Adminhtml\Bestsellers; + +/** + * Test Creation for BestsellerProductsReportEntity + * + * Test Flow: + * Preconditions: + * 1. Create customer + * 2. Create product + * 3. Place order + * 4. Refresh statistic + * + * Steps: + * 1. Open Backend + * 2. Go to Reports > Products > Bestsellers + * 3. Select time range, report period + * 4. Click "Show report" + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-28222 + */ +class BestsellerProductsReportEntityTest extends Injectable +{ + /** + * Bestsellers page + * + * @var Bestsellers + */ + protected $bestsellers; + + /** + * Inject pages + * + * @param Bestsellers $bestsellers + * @return void + */ + public function __inject(Bestsellers $bestsellers) + { + $this->bestsellers = $bestsellers; + } + + /** + * Bestseller Products Report + * + * @param OrderInjectable $order + * @param array $bestsellerReport + * @return void + */ + public function test(OrderInjectable $order, array $bestsellerReport) + { + // Preconditions + $order->persist(); + $this->bestsellers->open(); + $this->bestsellers->getMessagesBlock()->clickLinkInMessages('notice', 'here'); + + // Steps + $this->bestsellers->getFilterBlock()->viewsReport($bestsellerReport); + $this->bestsellers->getActionsBlock()->showReport(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/BestsellerProductsReportEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/BestsellerProductsReportEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..78dc2381483263924f1672265c7244179f073d32 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/BestsellerProductsReportEntityTest/test.csv @@ -0,0 +1,4 @@ +"order/dataSet";"bestsellerReport/period_type";"bestsellerReport/from";"bestsellerReport/to";"bestsellerReport/show_empty_rows";"date";"constraint" +"simple_big_qty";"Year";"m/d/Y -1 year";"m/d/Y";"No";"Y";"assertBestsellerReportResult" +"virtual_big_qty";"Month";"m/d/Y -1 month";"m/d/Y";"Yes";"n/Y";"assertBestsellerReportResult" +"simple_big_qty";"Day";"m/d/Y -1 day";"m/d/Y +1 day";"No";"M d, Y";"assertBestsellerReportResult" diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/OrderedProductsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/OrderedProductsReportEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6889b0be07b2f7656b79122c7ebe08e8b18fd50c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/OrderedProductsReportEntityTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\TestCase; + +use Magento\Reports\Test\Page\Adminhtml\OrderedProductsReport; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Mtf\TestCase\Injectable; + +/** + * Test Creation for OrderedProductsReportEntity + * + * Test Flow: + * Preconditions: + * 1. Place order + * + * Steps: + * 1. Open Backend + * 2. Go to Reports > Products > Ordered + * 3. Select time range and report period + * 4. Click "Refresh button" + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-28200 + */ +class OrderedProductsReportEntityTest extends Injectable +{ + /** + * Ordered Products Report + * + * @var OrderedProductsReport + */ + protected $orderedProducts; + + /** + * Inject pages + * + * @param OrderedProductsReport $orderedProducts + * @return void + */ + public function __inject(OrderedProductsReport $orderedProducts) + { + $this->orderedProducts = $orderedProducts; + } + + /** + * Search order products report + * + * @param OrderInjectable $order + * @param array $customersReport + * @return void + */ + public function test(OrderInjectable $order, array $customersReport) + { + // Preconditions + $order->persist(); + + // Steps + $this->orderedProducts->open(); + $this->orderedProducts->getGridBlock()->searchAccounts($customersReport); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/OrderedProductsReportEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/OrderedProductsReportEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..a19d4bc8b76b3a876f015e558a941ba99ef50ee3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/OrderedProductsReportEntityTest/test.csv @@ -0,0 +1,4 @@ +"order/dataSet";"customersReport/report_from";"customersReport/report_to";"customersReport/report_period";"constraint" +"default";"m/d/Y";"m/d/Y";"Year";"assertOrderedProductResult" +"default";"m/d/Y";"m/d/Y";"Month";"assertOrderedProductResult" +"virtual_product";"m/d/Y";"m/d/Y";"Day";"assertOrderedProductResult" diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesCouponReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesCouponReportEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b5d48fa5e48da49af5fa212fb7caa9ee2208a24e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesCouponReportEntityTest.php @@ -0,0 +1,145 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderView; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceNew; +use Magento\Reports\Test\Page\Adminhtml\Statistics; +use Magento\Reports\Test\Page\Adminhtml\SalesCouponReportView; + +/** + * Test Creation for SalesCouponReportEntity + * + * Test Flow: + * + * Preconditions: + * 1. Create order with coupon + * 2. Make invoice for this order + * 3. Refresh statistic + * + * Steps: + * 1. Login to backend + * 2. Go to Reports > Sales > Coupons + * 3. Select time range, report period etc + * 4. Click "Show report" + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-28190 + */ +class SalesCouponReportEntityTest extends Injectable +{ + /** + * Order index page + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Order invoice new page + * + * @var OrderInvoiceNew + */ + protected $orderInvoiceNew; + + /** + * Sales coupon report view page + * + * @var SalesCouponReportView + */ + protected $salesCouponReportView; + + /** + * Order view page + * + * @var OrderView + */ + protected $orderView; + + /** + * Report statistic page + * + * @var Statistics + */ + protected $reportStatistic; + + /** + * Injection data + * + * @param OrderIndex $orderIndex + * @param OrderInvoiceNew $orderInvoiceNew + * @param SalesCouponReportView $salesCouponReportView + * @param OrderView $orderView + * @param Statistics $reportStatistic + * @return void + */ + public function __inject( + OrderIndex $orderIndex, + OrderInvoiceNew $orderInvoiceNew, + SalesCouponReportView $salesCouponReportView, + OrderView $orderView, + Statistics $reportStatistic + ) { + $this->orderIndex = $orderIndex; + $this->orderInvoiceNew = $orderInvoiceNew; + $this->salesCouponReportView = $salesCouponReportView; + $this->orderView = $orderView; + $this->reportStatistic = $reportStatistic; + } + + /** + * Sales coupon report + * + * @param OrderInjectable $order + * @param array $viewsReport + * @return void + */ + public function test(OrderInjectable $order, array $viewsReport) + { + // Precondition + $order->persist(); + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); + $this->orderView->getPageActions()->invoice(); + $this->orderInvoiceNew->getTotalsBlock()->submit(); + $this->reportStatistic->open(); + $this->reportStatistic->getGridBlock()->massaction( + [['report' => 'Coupons']], + 'Refresh Statistics for the Last Day', + true + ); + + // Steps + $this->salesCouponReportView->open(); + $ruleName = $order->getCouponCode()->getName(); + $viewsReport['rules_list'] = str_replace('%rule_name%', $ruleName, $viewsReport['rules_list']); + $this->salesCouponReportView->getFilterBlock()->viewsReport($viewsReport); + $this->salesCouponReportView->getActionBlock()->showReport(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesCouponReportEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesCouponReportEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..d3b91c6d306ef73c0a0dd97c616de3bad5770cad --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesCouponReportEntityTest/test.csv @@ -0,0 +1,5 @@ +"order/dataSet";"viewsReport/report_type";"viewsReport/period_type";"viewsReport/from";"viewsReport/to";"viewsReport/show_order_statuses";"viewsReport/order_statuses";"viewsReport/show_empty_rows";"viewsReport/price_rule_type";"viewsReport/rules_list";"constraint";"issue" +"with_coupon";"Order Created Date";"Year";"m/d/Y";"m/d/Y";"Any";"-";"No";"Any";"-";"assertCouponReportResult";"" +"with_coupon";"Order Created Date";"Month";"m/d/Y";"m/d/Y";"Specified";"Processing";"No";"Any";"-";"assertCouponReportResult";"" +"with_coupon";"Order Updated Date";"Day";"m/d/Y";"m/d/Y";"Any";"-";"No";"Specified";"%rule_name%";"assertCouponReportResult";"Bug: MAGETWO-28201" +"with_coupon";"Order Updated Date";"Day";"m/d/Y 12:00 a-1 day";"m/d/Y 12:00 a+1 day";"Specified";"Processing";"Yes";"Specified";"%rule_name%";"assertCouponReportResult";"Bug: MAGETWO-28201" diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml index 6fd3f3d703ac7b67844c8bf970e3e7c4b9261f31..23c4f8a0c9cc2144439c242f66769d16163a26ed 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml @@ -57,4 +57,13 @@ <assertProductInCartResult module="Magento_Reports"> <severeness>low</severeness> </assertProductInCartResult> + <assertOrderedProductResult module="Magento_Reports"> + <severeness>low</severeness> + </assertOrderedProductResult> + <assertBestsellerReportResult module="Magento_Reports"> + <severeness>low</severeness> + </assertBestsellerReportResult> + <assertCouponReportResult module="Magento_Reports"> + <severeness>low</severeness> + </assertCouponReportResult> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml index f486dc564505f186ed84f6aa3145677f508c7b07..9850ac960dea12476079d12e8c5b989ed5fe10f4 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml @@ -59,4 +59,24 @@ <area>adminhtml</area> <class>Magento\Reports\Test\Page\Adminhtml\ShopCartProductReport</class> </shopCartProductReport> + <orderedProductsReport> + <mca>reports/report_product/sold/</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\OrderedProductsReport</class> + </orderedProductsReport> + <bestsellers> + <mca>reports/report_sales/bestsellers</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\Bestsellers</class> + </bestsellers> + <statistics> + <mca>reports/report_statistics</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\Statistics</class> + </statistics> + <salesCouponReportView> + <mca>reports/report_sales/coupons</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\SalesCouponReportView</class> + </salesCouponReportView> </page> diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/EmulateCustomerTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/EmulateCustomerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d4a7cda0711b5ebb9e37bea0ebf9da617b5f7799 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/EmulateCustomerTest.php @@ -0,0 +1,108 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +/** + * @magentoDataFixture Magento/Persistent/_files/persistent.php + */ +class EmulateCustomerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $_customerAccountService; + + /** + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSessionHelper; + + /** + * @var \Magento\Framework\ObjectManager + */ + protected $_objectManager; + + /** + * @var \Magento\Persistent\Model\Observer\EmulateCustomer + */ + protected $_observer; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + public function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $this->_customerSession = $this->_objectManager->get('Magento\Customer\Model\Session'); + + $this->_customerAccountService = $this->_objectManager->create( + 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' + ); + $this->_persistentSessionHelper = $this->_objectManager->create('Magento\Persistent\Helper\Session'); + + $this->_observer = $this->_objectManager->create( + 'Magento\Persistent\Model\Observer\EmulateCustomer', + [ + 'customerAccountService' => $this->_customerAccountService, + 'persistentSession' => $this->_persistentSessionHelper + ] + ); + } + + /** + * @magentoAppArea frontend + * @magentoConfigFixture current_store persistent/options/shopping_cart 1 + * @magentoConfigFixture current_store persistent/options/logout_clear 0 + * @magentoConfigFixture current_store persistent/options/enabled 1 + */ + public function testEmulateCustomer() + { + $observer = new \Magento\Framework\Event\Observer(); + + $this->_customerSession->loginById(1); + $this->_customerSession->logout(); + $this->assertNull($this->_customerSession->getCustomerId()); + $this->assertEquals( + \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + $this->_customerSession->getCustomerGroupId() + ); + + $this->_observer->execute($observer); + $customer = $this->_customerAccountService->getCustomer( + $this->_persistentSessionHelper->getSession()->getCustomerId() + ); + $this->assertEquals( + $customer->getId(), + $this->_customerSession->getCustomerId() + ); + $this->assertEquals( + $customer->getGroupId(), + $this->_customerSession->getCustomerGroupId() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/EmulateQuoteTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/EmulateQuoteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6564722183033720a37d0bebd80e583b1b395759 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/EmulateQuoteTest.php @@ -0,0 +1,118 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +/** + * @magentoDataFixture Magento/Persistent/_files/persistent.php + */ +class EmulateQuoteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $_customerAccountService; + + /** + * @var \Magento\Persistent\Helper\Session + */ + protected $_persistentSessionHelper; + + /** + * @var \Magento\Framework\ObjectManager + */ + protected $_objectManager; + + /** + * @var \Magento\Persistent\Model\Observer\EmulateQuote + */ + protected $_observer; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * @var \Magento\Checkout\Model\Session | \PHPUnit_Framework_MockObject_MockObject + */ + protected $_checkoutSession; + + public function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $this->_customerSession = $this->_objectManager->get('Magento\Customer\Model\Session'); + + $this->_customerAccountService = $this->_objectManager->create( + 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' + ); + + $this->_checkoutSession = $this->getMockBuilder( + 'Magento\Checkout\Model\Session' + )->disableOriginalConstructor()->setMethods([])->getMock(); + + $this->_persistentSessionHelper = $this->_objectManager->create('Magento\Persistent\Helper\Session'); + + $this->_observer = $this->_objectManager->create( + 'Magento\Persistent\Model\Observer\EmulateQuote', + [ + 'customerAccountService' => $this->_customerAccountService, + 'checkoutSession' => $this->_checkoutSession, + 'persistentSession' => $this->_persistentSessionHelper + ] + ); + } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_default 1 + * @magentoAppArea frontend + * @magentoConfigFixture current_store persistent/options/shopping_cart 1 + * @magentoConfigFixture current_store persistent/options/logout_clear 0 + */ + public function testEmulateQuote() + { + $requestMock = $this->getMockBuilder( + 'Magento\Framework\App\Request\Http' + )->disableOriginalConstructor()->setMethods( + [] + )->getMock(); + $requestMock->expects($this->once())->method('getFullActionName')->will($this->returnValue('valid_action')); + $event = new \Magento\Framework\Event(['request' => $requestMock]); + $observer = new \Magento\Framework\Event\Observer(); + $observer->setEvent($event); + + $this->_customerSession->loginById(1); + + $customer = $this->_customerAccountService->getCustomer( + $this->_persistentSessionHelper->getSession()->getCustomerId() + ); + $this->_checkoutSession->expects($this->once())->method('setCustomerData')->with($customer); + $this->_customerSession->logout(); + + $this->_observer->execute($observer); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/ObserverTest.php index 229dcb454807daf89d488e684f55d92c9b42c69e..0c72546460912e02ec7b71d47c2db11027a2934f 100644 --- a/dev/tests/integration/testsuite/Magento/Persistent/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/ObserverTest.php @@ -134,73 +134,4 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->assertStringMatchesFormat('%A' . $translation . '%A', $block->getWelcome()); $this->_customerSession->logout(); } - - /** - * @magentoConfigFixture current_store persistent/options/enabled 1 - * @magentoConfigFixture current_store persistent/options/remember_enabled 1 - * @magentoConfigFixture current_store persistent/options/remember_default 1 - * @magentoAppArea frontend - * @magentoAppIsolation enabled - * @magentoConfigFixture current_store persistent/options/shopping_cart 1 - * @magentoConfigFixture current_store persistent/options/logout_clear 0 - */ - public function testEmulateQuote() - { - $requestMock = $this->getMockBuilder( - 'Magento\Framework\App\Request\Http' - )->disableOriginalConstructor()->setMethods( - [] - )->getMock(); - $requestMock->expects($this->once())->method('getFullActionName')->will($this->returnValue('valid_action')); - $event = new \Magento\Framework\Event( - [ - 'request' => $requestMock - ] - ); - $observer = new \Magento\Framework\Event\Observer(); - $observer->setEvent($event); - - $this->_customerSession->loginById(1); - - $customer = $this->_customerAccountService->getCustomer( - $this->_persistentSessionHelper->getSession()->getCustomerId() - ); - $this->_checkoutSession->expects($this->once())->method('setCustomerData')->with($customer); - $this->_customerSession->logout(); - - $this->_observer->emulateQuote($observer); - } - - /** - * @magentoAppArea frontend - * @magentoAppIsolation enabled - * @magentoConfigFixture current_store persistent/options/shopping_cart 1 - * @magentoConfigFixture current_store persistent/options/logout_clear 0 - * @magentoConfigFixture current_store persistent/options/enabled 1 - */ - public function testEmulateCustomer() - { - $observer = new \Magento\Framework\Event\Observer(); - - $this->_customerSession->loginById(1); - $this->_customerSession->logout(); - $this->assertNull($this->_customerSession->getCustomerId()); - $this->assertEquals( - \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, - $this->_customerSession->getCustomerGroupId() - ); - - $this->_observer->emulateCustomer($observer); - $customer = $this->_customerAccountService->getCustomer( - $this->_persistentSessionHelper->getSession()->getCustomerId() - ); - $this->assertEquals( - $customer->getId(), - $this->_customerSession->getCustomerId() - ); - $this->assertEquals( - $customer->getGroupId(), - $this->_customerSession->getCustomerGroupId() - ); - } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php index 166f138ed929699d8e91ebbe024ed866df47f0ea..5088d69e99e2cb8950bbce670725acc9a9dc4d8d 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php @@ -47,6 +47,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $objectManager->get('Magento\Backend\Block\Template\Context'), $objectManager->get('Magento\Backend\Model\Session\Quote'), $objectManager->get('Magento\Sales\Model\AdminOrder\Create'), + $objectManager->get('Magento\Framework\Pricing\PriceCurrencyInterface'), $objectManager->get('Magento\Framework\Data\FormFactory') ); diff --git a/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php index ba812c310c4c83b46b8944b6e8a2695158e381eb..9bff9bed2a4253cb7e34be20945e4ca8f619e022 100644 --- a/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php @@ -312,15 +312,6 @@ class StoreTest extends \PHPUnit_Framework_TestCase $this->assertEquals($this->model->getDefaultCurrencyCode(), $this->model->getDefaultCurrency()->getCode()); } - /** - * @todo refactor \Magento\Store\Model\Store::getPriceFilter, it can return two different types - */ - public function testGetPriceFilter() - { - $this->model->load('default'); - $this->assertInstanceOf('Magento\Directory\Model\Currency\Filter', $this->model->getPriceFilter()); - } - public function testIsCanDelete() { $this->assertFalse($this->model->isCanDelete()); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 4a278c7b43105ed4c343b27af97c64f10a98f71b..ee13cdcbc81417b1891be3383ab26c5e4c64c725 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -2806,5 +2806,8 @@ return array( '\Magento\Framework\Service\Data\AbstractObjectBuilder', 'Magento\Framework\Service\Data\AbstractSimpleObjectBuilder' ], + ['Magento\Catalog\Block\Product'], ['\Magento\Sales\Model\Observer'], + ['\Magento\Checkout\Service\V1\QuoteLoader', '\Magento\Sales\Model\QuoteRepository'], + ['Magento\PageCache\Model\Observer'] ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 4881dc984770d49470c880273c8c718180e72ad1..09e6a7709ec14eea33efd048b4d36be5af2b2338 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -1918,4 +1918,8 @@ return array( ['loadByTags', 'Magento\UrlRewrite\Model\UrlRewrite'], ['getMethodFormBlock', 'Magento\Centinel\Helper\Data'], ['login', 'Magento\Customer\Model\Session'], + ['roundPrice', 'Magento\Store\Model\Store', 'Magento\Framework\Pricing\PriceCurrencyInterface::round'], + ['formatPrice', 'Magento\Store\Model\Store', 'Magento\Framework\Pricing\PriceCurrencyInterface::format'], + ['convertPrice', 'Magento\Store\Model\Store', 'Magento\Framework\Pricing\PriceCurrencyInterface::convert'], + ['getPriceFilter', 'Magento\Store\Model\Store'], ); diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php index 407ae918420116cacf3c232a9d0641fc74a7d790..6af1165471b2cee32503d2735ad16c22351570d0 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php @@ -65,6 +65,11 @@ class PriceTest extends \PHPUnit_Framework_TestCase */ protected $model; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + protected function setUp() { $this->ruleFactoryMock = $this->getMock( @@ -80,6 +85,7 @@ class PriceTest extends \PHPUnit_Framework_TestCase $this->eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface'); $this->catalogHelperMock = $this->getMock('\Magento\Catalog\Helper\Data', array(), array(), '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', array(), array(), '', false); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $this->model = new \Magento\Bundle\Model\Product\Price( $this->ruleFactoryMock, @@ -87,6 +93,7 @@ class PriceTest extends \PHPUnit_Framework_TestCase $this->localeDateMock, $this->customerSessionMock, $this->eventManagerMock, + $this->priceCurrency, $this->catalogHelperMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Adjustment/CalculatorTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Adjustment/CalculatorTest.php index f7cb2446164efd414b2522a8b7fcb12fc04499c5..a70fde6243ff1ce25aad91e2116b8d3ee6e0ccfd 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Adjustment/CalculatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Adjustment/CalculatorTest.php @@ -78,6 +78,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase ->setMethods(['getPriceInfo', 'getPriceType', '__wakeup', 'getStore']) ->disableOriginalConstructor() ->getMock(); + $priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); $priceInfo->expects($this->any())->method('getPrice')->will( $this->returnCallback( @@ -94,7 +95,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $store = $this->getMockBuilder('Magento\Store\Model\Store') ->disableOriginalConstructor() ->getMock(); - $store->expects($this->any())->method('roundPrice')->will($this->returnArgument(0)); + $priceCurrency->expects($this->any())->method('round')->will($this->returnArgument(0)); $this->saleableItem->expects($this->any())->method('getStore')->will($this->returnValue($store)); @@ -128,7 +129,8 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase 'calculator' => $this->baseCalculator, 'amountFactory' => $this->amountFactory, 'bundleSelectionFactory' => $this->selectionFactory, - 'taxHelper' => $this->taxData + 'taxHelper' => $this->taxData, + 'priceCurrency' => $priceCurrency, ] ); } diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Price/BundleOptionPriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Price/BundleOptionPriceTest.php index 629920fd72b0336466ff522d87080f113d981f1b..6a87813d5ae97280394d3e42b2a81289870713bd 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Price/BundleOptionPriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Price/BundleOptionPriceTest.php @@ -72,15 +72,15 @@ class BundleOptionPriceTest extends \PHPUnit_Framework_TestCase { $this->priceInfoMock = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); $this->saleableItemMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $this->saleableItemMock->expects($this->once()) ->method('getPriceInfo') ->will($this->returnValue($this->priceInfoMock)); $store = $this->getMockBuilder('Magento\Store\Model\Store') - ->setMethods(['roundPrice', '__wakeup']) ->disableOriginalConstructor() ->getMock(); - $store->expects($this->any())->method('roundPrice')->will($this->returnArgument(0)); + $priceCurrency->expects($this->any())->method('round')->will($this->returnArgument(0)); $this->saleableItemMock->expects($this->once()) ->method('setQty') @@ -107,7 +107,9 @@ class BundleOptionPriceTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->bundleCalculatorMock = $this->getMockBuilder('Magento\Bundle\Pricing\Adjustment\Calculator') - ->setConstructorArgs([$this->baseCalculator, $this->amountFactory, $this->selectionFactoryMock, $taxData]) + ->setConstructorArgs( + [$this->baseCalculator, $this->amountFactory, $this->selectionFactoryMock, $taxData, $priceCurrency] + ) ->setMethods(['getOptionsAmount']) ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Shipping/PriceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Block/Shipping/PriceTest.php index f94db86a1ae0c059ab6b04f137d4278aa4f76f23..d57d865f38456755818e4117ee44f0903c15295b 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Shipping/PriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Block/Shipping/PriceTest.php @@ -44,36 +44,20 @@ class PriceTest extends \PHPUnit_Framework_TestCase */ protected $store; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->store = $this->getMockBuilder('Magento\Store\Model\Store') - ->disableOriginalConstructor() - ->setMethods(['convertPrice', '__wakeup']) - ->getMock(); - - $this->quote = $this->getMockBuilder('Magento\Sales\Model\Quote') - ->disableOriginalConstructor() - ->setMethods(['getStore', '__wakeup']) - ->getMock(); - - $this->quote->expects($this->once()) - ->method('getStore') - ->will($this->returnValue($this->store)); - - $checkoutSession = $this->getMockBuilder('\Magento\Checkout\Model\Session') - ->disableOriginalConstructor() - ->setMethods(['getQuote', '__wakeup']) - ->getMock(); - - $checkoutSession->expects($this->once()) - ->method('getQuote') - ->will($this->returnValue($this->quote)); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $this->priceObj = $objectManager->getObject( '\Magento\Checkout\Block\Shipping\Price', - ['checkoutSession' => $checkoutSession] + ['priceCurrency' => $this->priceCurrency] ); } @@ -90,10 +74,10 @@ class PriceTest extends \PHPUnit_Framework_TestCase ->method('getPrice') ->will($this->returnValue($shippingPrice)); - $this->store->expects($this->once()) - ->method('convertPrice') + $this->priceCurrency->expects($this->once()) + ->method('convertAndFormat') ->with($shippingPrice, true, true) - ->will($this->returnValue($convertedPrice)); + ->willReturn($convertedPrice); $this->priceObj->setShippingRate($shippingRateMock); $this->assertEquals($convertedPrice, $this->priceObj->getShippingPrice()); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php index 47c9115bf6399bc53b72f03e7b1db8f866c8c0b2..6ebbd14971b18fb4d9b6640167b1c2fa9acd6d5a 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php @@ -28,6 +28,11 @@ use Magento\Store\Model\ScopeInterface; class DataTest extends \PHPUnit_Framework_TestCase { + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\PriceCurrencyInterface + */ + private $priceCurrency; + /** * @var Data */ @@ -158,6 +163,8 @@ class DataTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->_helper = new Data( $this->_context, $this->_scopeConfig, @@ -165,7 +172,8 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_checkoutSession, $localeDate, $this->_transportBuilder, - $this->_translator + $this->_translator, + $this->priceCurrency ); } @@ -309,24 +317,14 @@ class DataTest extends \PHPUnit_Framework_TestCase ); $this->_checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $storeMock->expects($this->once())->method('formatPrice')->will($this->returnValue('5.5')); + $this->priceCurrency->expects($this->once())->method('format')->will($this->returnValue('5.5')); $this->assertEquals('5.5', $this->_helper->formatPrice($price)); } public function testConvertPrice() { $price = 5.5; - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', array(), array(), '', false); - $storeMock = $this->getMock( - 'Magento\Store\Model\Store', - array('convertPrice', '__wakeup'), - array(), - '', - false - ); - $this->_checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); - $quoteMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $storeMock->expects($this->once())->method('convertPrice')->will($this->returnValue('5.5')); + $this->priceCurrency->expects($this->once())->method('convertAndFormat')->willReturn($price); $this->assertEquals(5.5, $this->_helper->convertPrice($price)); } @@ -383,14 +381,10 @@ class DataTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', - ['storeManager' => $storeManager] - ); - $storeMock = $this->getMock( - 'Magento\Store\Model\Store', - array('roundPrice', '__wakeup'), - array(), - '', - false + [ + 'storeManager' => $storeManager, + 'priceCurrency' => $this->priceCurrency, + ] ); $itemMock = $this->getMock( 'Magento\Framework\Object', @@ -406,9 +400,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $itemMock->expects($this->once()) ->method('getDiscountTaxCompensation')->will($this->returnValue($discountTaxCompensation)); $itemMock->expects($this->once())->method('getRowTotal')->will($this->returnValue($rowTotal)); - $storeManager->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $storeMock->expects($this->once()) - ->method('roundPrice')->with($roundPrice)->will($this->returnValue($roundPrice)); + $this->priceCurrency->expects($this->once())->method('round')->with($roundPrice)->willReturn($roundPrice); $this->assertEquals($expected, $helper->getPriceInclTax($itemMock)); } @@ -448,19 +440,14 @@ class DataTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', - ['storeManager' => $storeManager] + [ + 'storeManager' => $storeManager, + 'priceCurrency' => $this->priceCurrency, + ] ); $itemMock = $this->getMock('Magento\Framework\Object', array('getQty'), array(), '', false); $itemMock->expects($this->once())->method('getQty'); - $storeMock = $this->getMock( - 'Magento\Store\Model\Store', - array('roundPrice', '__wakeup'), - array(), - '', - false - ); - $storeManager->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $storeMock->expects($this->once())->method('roundPrice'); + $this->priceCurrency->expects($this->once())->method('round'); $helper->getPriceInclTax($itemMock); } @@ -470,20 +457,15 @@ class DataTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', - ['storeManager' => $storeManager] + [ + 'storeManager' => $storeManager, + 'priceCurrency' => $this->priceCurrency, + ] ); $itemMock = $this->getMock('Magento\Framework\Object', array('getQty', 'getQtyOrdered'), array(), '', false); $itemMock->expects($this->once())->method('getQty')->will($this->returnValue(false)); $itemMock->expects($this->exactly(2))->method('getQtyOrdered')->will($this->returnValue(5.5)); - $storeMock = $this->getMock( - 'Magento\Store\Model\Store', - array('roundPrice', '__wakeup'), - array(), - '', - false - ); - $storeManager->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $storeMock->expects($this->once())->method('roundPrice'); + $this->priceCurrency->expects($this->once())->method('round'); $helper->getBasePriceInclTax($itemMock); } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/ReadPluginTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/ReadPluginTest.php new file mode 100644 index 0000000000000000000000000000000000000000..11351f11b66cc942e6c06722c3460a3a76a69f57 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/ReadPluginTest.php @@ -0,0 +1,106 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Model\Cart\Access; + +class ReadPluginTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Checkout\Model\Cart\Access\ReadPlugin + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $userContextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + 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); + } + + /** + * @param int $userType + * @dataProvider successTypeDataProvider + */ + public function testBeforeGetCartSuccess($userType) + { + $this->userContextMock->expects($this->once())->method('getUserType')->will($this->returnValue($userType)); + $this->model->beforeGetCart($this->subjectMock, 1); + } + + /** + * @expectedException \Magento\Framework\Exception\AuthorizationException + * @expectedExceptionMessage Access denied + */ + public function testBeforeGetCartDenied() + { + $this->userContextMock->expects($this->once())->method('getUserType') + ->will($this->returnValue(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER)); + $this->model->beforeGetCart($this->subjectMock, 1); + } + + public function successTypeDataProvider() + { + return [ + 'admin' => [\Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN], + 'integration' => [\Magento\Authorization\Model\UserContextInterface::USER_TYPE_INTEGRATION], + ]; + } + + /** + * @param int $userType + * @dataProvider successTypeDataProvider + */ + public function testBeforeGetCartListSuccess($userType) + { + $this->userContextMock->expects($this->once())->method('getUserType')->will($this->returnValue($userType)); + $this->model->beforeGetCartList( + $this->subjectMock, + $this->getMock('\Magento\Framework\Service\V1\Data\SearchCriteria', [], [], '', false) + ); + } + + /** + * @expectedException \Magento\Framework\Exception\AuthorizationException + * @expectedExceptionMessage Access denied + */ + public function testBeforeGetCartListDenied() + { + $this->userContextMock->expects($this->once())->method('getUserType') + ->will($this->returnValue(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER)); + $this->model->beforeGetCartList( + $this->subjectMock, + $this->getMock('\Magento\Framework\Service\V1\Data\SearchCriteria', [], [], '', false) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/WritePluginTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/WritePluginTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b76a7f63f68264a5584a7ba0ac26bea7228730e8 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Cart/Access/WritePluginTest.php @@ -0,0 +1,79 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Model\Cart\Access; + +class WritePluginTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Checkout\Model\Cart\Access\WritePlugin + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $userContextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + 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); + } + + /** + * @param int $userType + * @dataProvider successTypeDataProvider + */ + public function testBeforeCreateSuccess($userType) + { + $this->userContextMock->expects($this->once())->method('getUserType')->will($this->returnValue($userType)); + $this->model->beforeAssignCustomer($this->subjectMock, 1, 1); + } + + public function successTypeDataProvider() + { + return [ + 'admin' => [\Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN], + 'integration' => [\Magento\Authorization\Model\UserContextInterface::USER_TYPE_INTEGRATION], + ]; + } + + /** + * @expectedException \Magento\Framework\Exception\AuthorizationException + * @expectedExceptionMessage Access denied + */ + public function testBeforeCreateDenied() + { + $this->userContextMock->expects($this->once())->method('getUserType') + ->will($this->returnValue(\Magento\Authorization\Model\UserContextInterface::USER_TYPE_CUSTOMER)); + $this->model->beforeAssignCustomer($this->subjectMock, 1, 1); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php index 58b0718f83b6b864deb7fef157edd8b7ff2e118f..f442095e2ee63bc7e2a0ce4763e01aaafc20fc69 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php @@ -35,36 +35,26 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteLoaderMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $converterMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - protected function setUp() { - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); - $this->service = new ReadService($this->quoteLoaderMock, $this->converterMock, $this->storeManagerMock); + $this->service = new ReadService($this->quoteRepositoryMock, $this->converterMock); } public function testGetAddress() { - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue(11)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once())->method('load') - ->with('cartId', '11')->will($this->returnValue($quoteMock)); + $this->quoteRepositoryMock->expects($this->once())->method('get') + ->with('cartId')->will($this->returnValue($quoteMock)); $addressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock)); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php index 93bf3f8e14df0ad18cb31b8e6d52b740cd1ae786..9483e5cd147c27af3be2fe69f591f3e7787bc99b 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php @@ -35,7 +35,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteLoaderMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -47,11 +47,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ protected $quoteAddressMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -63,19 +58,17 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected $converterMock; /** - * @var \Magento\TestFramework\Helper\ObjectManager + * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $objectManager; + protected $loggerMock; protected function setUp() { - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $this->addressFactoryMock = $this->getMock( '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false ); - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteAddressMock = $this->getMock( '\Magento\Sales\Model\Quote\Address', ['getCustomerId', 'load', 'getData', 'setData', 'setStreet', 'setRegionId', 'setRegion', '__wakeup'], @@ -95,33 +88,27 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase '\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false ); - $this->service = $this->objectManager->getObject( - '\Magento\Checkout\Service\V1\Address\Billing\WriteService', - [ - 'quoteLoader' => $this->quoteLoaderMock, - 'storeManager' => $this->storeManagerMock, - 'quoteAddressFactory' => $this->addressFactoryMock, - 'addressValidator' => $this->validatorMock, - 'addressConverter' => $this->converterMock, - ] + $this->loggerMock = $this->getMock('\Magento\Framework\Logger', [], [], '', 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 - * @expected ExceptionMessage error123 + * @expectedExceptionMessage error123 */ public function testSetAddressValidationFailed() { - $storeId = 323; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with('cartId', $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with('cartId') ->will($this->returnValue($quoteMock)); $this->validatorMock->expects($this->once())->method('validate') @@ -132,19 +119,22 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testSetAddress() { - $storeId = 323; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with('cartId', $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->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 = $this->objectManager->getObject('Magento\Checkout\Service\V1\Data\Cart\AddressBuilder'); + $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(); @@ -167,4 +157,46 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $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\Sales\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->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); + $quoteMock->expects($this->once())->method('save')->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 index e6ee3243d7a3b8a6da2dc669d4308c577975bb17..59cb19b9a9e431bc15a5309d300995e7a38b2ed2 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.php @@ -97,9 +97,9 @@ class ConverterTest extends \PHPUnit_Framework_TestCase Address::KEY_ID => 2, Address::KEY_CUSTOMER_ID => 3, Address::KEY_REGION => [ - Region::KEY_REGION => 'Alabama', - Region::KEY_REGION_ID => 4, - Region::KEY_REGION_CODE => 'aa', + Region::REGION => 'Alabama', + Region::REGION_ID => 4, + Region::REGION_CODE => 'aa', ], Address::KEY_STREET => 'street', Address::KEY_COMPANY => 'company', diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php index 180ebe591443ee0d55c045c3e4211f49b956aa2f..e211849ed9a22b12138ff7368110dcfc78c3d81f 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php @@ -35,35 +35,25 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteLoaderMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $converterMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - protected function setUp() { - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->any())->method('getId')->will($this->returnValue(123)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - - $this->service = new ReadService($this->quoteLoaderMock, $this->converterMock, $this->storeManagerMock); + $this->service = new ReadService($this->quoteRepositoryMock, $this->converterMock); } public function testGetAddress() { $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once())->method('load')->with('cartId', '123')->will( + $this->quoteRepositoryMock->expects($this->once())->method('get')->with('cartId')->will( $this->returnValue($quoteMock) ); @@ -84,7 +74,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase public function testGetAddressOfQuoteWithVirtualProducts() { $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once())->method('load')->with('cartId', '123')->will( + $this->quoteRepositoryMock->expects($this->once())->method('get')->with('cartId')->will( $this->returnValue($quoteMock) ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php index c25c0e7b708eac23de7af21cef9e0b2b238dbe9a..16738a83206416bbd37add7be323c89cf2a9b1e1 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php @@ -35,7 +35,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteLoaderMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -47,11 +47,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ protected $quoteAddressMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -69,8 +64,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $this->addressFactoryMock = $this->getMock( '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false ); @@ -98,8 +92,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->service = $this->objectManager->getObject( '\Magento\Checkout\Service\V1\Address\Shipping\WriteService', [ - 'quoteLoader' => $this->quoteLoaderMock, - 'storeManager' => $this->storeManagerMock, + 'quoteRepository' => $this->quoteRepositoryMock, 'quoteAddressFactory' => $this->addressFactoryMock, 'addressValidator' => $this->validatorMock, 'addressConverter' => $this->converterMock, @@ -113,15 +106,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ public function testSetAddressValidationFailed() { - $storeId = 554; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with('cart654', $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with('cart654') ->will($this->returnValue($quoteMock)); $this->validatorMock->expects($this->once())->method('validate') @@ -132,20 +120,22 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testSetAddress() { - $storeId = 323; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with('cart867', $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with('cart867') ->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'); + $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(); @@ -177,20 +167,22 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ public function testSetAddressForVirtualProduct() { - $storeId = 323; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with('cart867', $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with('cart867') ->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'); + $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(); @@ -202,4 +194,46 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->service->setAddress('cart867', $addressData); } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Unable to save address. Please, check input data. + */ + public function testSetAddressWithInabilityToSaveQuote() + { + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with('cart867') + ->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) + ->will($this->returnValue(true)); + + $this->converterMock->expects($this->once())->method('convertDataObjectToModel') + ->with($addressData, $this->quoteAddressMock) + ->will($this->returnValue($this->quoteAddressMock)); + + $quoteMock->expects($this->once())->method('setShippingAddress')->with($this->quoteAddressMock); + $quoteMock->expects($this->once())->method('setDataChanges')->with(true); + $quoteMock->expects($this->once())->method('save')->willThrowException( + new \Exception('Some DB Error') + ); + $this->service->setAddress('cart867', $addressData); + } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php index 7b81d325859220382479b8fe2a4bd577e70b1963..ffe29b206e4c1fc69acab807b2a8499d31e59abe 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php @@ -84,8 +84,13 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase ; $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' + '\Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', + ['regionBuilder' => $builder] ); $this->model = $this->objectManager->getObject( 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 index 12cf1ec8637f1f1f13f14209df55053d512097d9..ff507f8d18d3b8dbf364114c9506ea2e65c49a11 100644 --- 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 @@ -55,7 +55,7 @@ class BuilderTest extends \PHPUnit_Framework_TestCase $paymentMethodMock->expects($this->once())->method('__toArray')->will($this->returnValue($paymentData)); $paymentMethodMock->expects($this->once()) ->method('getPaymentDetails') - ->will($this->returnValue(['paymentDetailsTest'])); + ->will($this->returnValue(serialize(['paymentDetailsTest']))); $paymentMock = $this->getMock('\Magento\Sales\Model\Quote\Payment', [], [], '', false); $paymentMock->expects($this->once()) 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 index 854ba8643778c754b8877f6b68675f51ed968914..30dbf7bd1261b7fefabefc29c2a49985402477c6 100644 --- 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 @@ -47,7 +47,11 @@ class ConverterTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->paymentMethodBuilderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder', [], [], '', false + '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethodBuilder', + ['populateWithArray', 'create'], + [], + '', + false ); $this->converter = $this->objectManager->getObject( 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 index e2746e3de139f959b922df90df3ff113cb3d6a0b..67ffa0e07f79c6a450c139dfa6374e881c1c95b9 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php @@ -52,76 +52,11 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase */ protected $searchResultsBuilderMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cartMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cartBuilderMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $cartMapperMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $totalsMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $totalsBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $totalsMapperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $customerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $customerBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $customerMapperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $currencyMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $currencyBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $currencyMapperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $itemTotalBuilderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $itemTotalMapperMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -130,7 +65,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', ['get'], [], '', false); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $methods = [ 'getId', 'getStoreId', 'getCreatedAt', 'getUpdatedAt', 'getConvertedAt', 'getIsActive', 'getIsVirtual', 'getItemsCount', 'getItemsQty', 'getCheckoutMethod', 'getReservedOrderId', @@ -148,47 +83,13 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase '\Magento\Sales\Model\Resource\Quote\Collection', [$this->quoteMock]); $this->searchResultsBuilderMock = $this->getMock('\Magento\Checkout\Service\V1\Data\CartSearchResultsBuilder', [], [], '', false); - - $this->cartBuilderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\CartBuilder', [], [], '', false); - $this->cartMapperMock = $this->getMock('\Magento\Checkout\Service\V1\Data\CartMapper', ['map']); - - $this->totalsBuilderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\TotalsBuilder', [], [], '', false); - $this->totalsMapperMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\TotalsMapper', ['map']); - $this->totalsMock = $this->getMock('Magento\Sales\Model\Order\Total', [], [], '', false); - - $this->customerBuilderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CustomerBuilder', [], [], '', false); - $this->customerMapperMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CustomerMapper', ['map']); - $this->customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); - - $this->currencyBuilderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CurrencyBuilder', [], [], '', false); - $this->currencyMapperMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CurrencyMapper', ['extractDto']); - - $this->itemTotalBuilderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\Totals\ItemBuilder', [], [], '', false); - $this->itemTotalMapperMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\Totals\ItemMapper', ['extractDto']); - - $this->currencyMock = $this->getMock('Magento\Checkout\Service\V1\Data\Cart\Currency', [], [], '', false); + $this->cartMapperMock = $this->getMock('\Magento\Checkout\Service\V1\Data\CartMapper', ['map'], [], '', false); $this->service = new ReadService( $this->quoteRepositoryMock, $this->quoteCollectionMock, $this->searchResultsBuilderMock, - $this->cartBuilderMock, - $this->cartMapperMock, - $this->totalsBuilderMock, - $this->totalsMapperMock, - $this->customerBuilderMock, - $this->customerMapperMock, - $this->currencyBuilderMock, - $this->currencyMapperMock, - $this->itemTotalBuilderMock, - $this->itemTotalMapperMock + $this->cartMapperMock ); } @@ -198,20 +99,22 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId) ->will($this->returnValue($this->quoteMock)); - $this->cartBuilderMock->expects($this->once())->method('setCustomer')->with($this->customerMock); - $this->cartBuilderMock->expects($this->once())->method('setTotals')->with($this->totalsMock); - $this->cartBuilderMock->expects($this->once())->method('setCurrency')->with($this->currencyMock); - $this->cartBuilderMock->expects($this->once())->method('create'); - - $this->setCartTotalsExpectations(); - $this->setCartDataExpectations(); - $this->setCurrencyDataExpectations(); - $this->setCustomerDataExpectations(); - $this->setCartItemTotalsExpectations(); + $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('getForCustomer')->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 @@ -232,6 +135,14 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->expects($this->any()) ->method('getFilterGroups') ->will($this->returnValue([$filterGroupMock])); + $sortOrderMock = $this->getMock('\Magento\Framework\Service\V1\Data\SortOrder', [], [], '', false); + $searchCriteriaMock + ->expects($this->any()) + ->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)); + $filterMock = $this->getMock('\Magento\Framework\Service\V1\Data\Filter', [], [], '', false); $filterGroupMock->expects($this->any())->method('getFilters')->will($this->returnValue([$filterMock])); $filterMock->expects($this->once())->method('getField')->will($this->returnValue('store_id')); @@ -245,24 +156,12 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->quoteCollectionMock->expects($this->once())->method('getSize')->will($this->returnValue(10)); $this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with(10); - $searchCriteriaMock - ->expects($this->once()) - ->method('getSortOrders') - ->will($this->returnValue(['id' => $direction])); $this->quoteCollectionMock->expects($this->once())->method('addOrder')->with('entity_id', $expected); $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->will($this->returnValue(1)); $searchCriteriaMock->expects($this->once())->method('getPageSize')->will($this->returnValue(10)); - $this->setCartTotalsExpectations(); - $this->setCartDataExpectations(); - $this->setCustomerDataExpectations(); - $this->setCurrencyDataExpectations(); - $this->setCartItemTotalsExpectations(); - - $this->cartBuilderMock->expects($this->once())->method('setCurrency')->with($this->currencyMock); - $this->cartBuilderMock->expects($this->once())->method('setCustomer')->with($this->customerMock); - $this->cartBuilderMock->expects($this->once())->method('setTotals')->with($this->totalsMock); - $this->cartBuilderMock->expects($this->once())->method('create')->will($this->returnValue($cartMock)); + $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 @@ -306,71 +205,4 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase 'desc' => [SearchCriteria::SORT_DESC, 'DESC'] ]; } - - /** - * Set expectations for cart general data processing - */ - protected function setCartDataExpectations() - { - $this->cartMapperMock->expects($this->once())->method('map')->with($this->quoteMock) - ->will($this->returnValue([])); - $this->cartBuilderMock->expects($this->once())->method('populateWithArray')->with([]); - } - - /** - * Set expectations for totals processing - */ - protected function setCartTotalsExpectations() - { - $this->totalsMapperMock->expects($this->once())->method('map')->with($this->quoteMock) - ->will($this->returnValue([])); - $this->totalsBuilderMock->expects($this->once())->method('populateWithArray')->with([]); - $this->totalsBuilderMock->expects($this->once())->method('create')->will($this->returnValue($this->totalsMock)); - } - - /** - * Set expectations for totals item data processing - * - * @return array - */ - protected function setCartItemTotalsExpectations() - { - $quoteItemMock = $this->getMock('\Magento\Sales\Model\Quote\Item', [], [], '', false); - $items = [$quoteItemMock]; - $this->quoteMock->expects($this->once())->method('getAllItems')->will($this->returnValue($items)); - $this->itemTotalMapperMock->expects($this->once())->method('extractDto')->with($quoteItemMock); - } - - /** - * Set expectations for cart customer data processing - */ - protected function setCustomerDataExpectations() - { - $this->customerMapperMock->expects($this->once())->method('map')->with($this->quoteMock) - ->will($this->returnValue([])); - $this->customerBuilderMock->expects($this->once())->method('populateWithArray')->with([]); - $this->customerBuilderMock->expects($this->once())->method('create') - ->will($this->returnValue($this->customerMock)); - } - - /** - * Set expectations for currency data processing - */ - protected function setCurrencyDataExpectations() - { - $this->currencyMapperMock->expects($this->once())->method('extractDto')->with($this->quoteMock) - ->will($this->returnValue($this->currencyMock)); - } - - public function testGetTotals() - { - $cartId = 12; - $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId) - ->will($this->returnValue($this->quoteMock)); - - $this->setCartTotalsExpectations(); - $this->setCartItemTotalsExpectations(); - - $this->service->getTotals($cartId); - } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..0bd9ceba8a7b60e5a43e736a371a3c149a2d7900 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/TotalsServiceTest.php @@ -0,0 +1,104 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Checkout\Service\V1\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\Sales\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\Sales\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('get')->with($cartId) + ->will($this->returnValue($this->quoteMock)); + + $this->totalsMapperMock->expects($this->once()) + ->method('map') + ->with($this->quoteMock) + ->will($this->returnValue(array('test'))); + + $item = $this->getMock('Magento\Sales\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 index 5b5a3fa5a5126bedddbb2653ddc1c74ce8c59b6c..67477f6f83b466387417b53ae5742a6228986b84 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php @@ -65,13 +65,30 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ protected $customerRegistryMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteRepositoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $userContextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteServiceFactory; + public function setUp() { $this->objectManager = new ObjectManager($this); $this->quoteFactoryMock = $this->getMock( '\Magento\Sales\Model\QuoteFactory', ['create', '__wakeup'], [], '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); + $this->userContextMock = $this->getMock('\Magento\Authorization\Model\UserContextInterface'); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $this->quoteMock = @@ -91,93 +108,144 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->customerRegistryMock = $this->getMock('\Magento\Customer\Model\CustomerRegistry', [], [], '', false); + $this->quoteServiceFactory = $this->getMock( + 'Magento\Sales\Model\Service\QuoteFactory', + ['create'], + [], + '', + false + ); $this->service = $this->objectManager->getObject( '\Magento\Checkout\Service\V1\Cart\WriteService', [ 'quoteFactory' => $this->quoteFactoryMock, 'storeManager' => $this->storeManagerMock, - 'customerRegistry' => $this->customerRegistryMock + 'customerRegistry' => $this->customerRegistryMock, + 'quoteRepository' => $this->quoteRepositoryMock, + 'userContext' => $this->userContextMock, + 'quoteServiceFactory' => $this->quoteServiceFactory ] ); } - public function testCreate() + 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->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('setStoreId')->with($storeId); $this->quoteMock->expects($this->once())->method('save'); - - $this->service->create(); + $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() + public function testCreateCustomerCartWhenCustomerHasActiveCart() { $storeId = 345; + $userId = 50; + $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); + $this->customerRegistryMock->expects($this->once()) + ->method('retrieve')->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->once())->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->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('setStoreId')->with($storeId); - $this->quoteMock->expects($this->once())->method('save') - ->will($this->throwException(new CouldNotSaveException('Cannot create quote'))); + $customerQuoteMock = $this->getMock('\Magento\Sales\Model\Quote', + [ + 'loadByCustomer', + 'getIsActive', + 'getId', + '__wakeup' + ], + [], + '', + false + ); + $customerQuoteMock->expects($this->once()) + ->method('loadByCustomer') + ->with($customerMock) + ->will($this->returnSelf()); + $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($customerQuoteMock); + $customerQuoteMock->expects($this->once())->method('getId')->willReturn(1); + $customerQuoteMock->expects($this->once())->method('getIsActive')->willReturn(true); + $this->quoteMock->expects($this->never())->method('save'); $this->service->create(); } - /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage There is no cart with provided ID. - */ - public function testAssignCustomerNoSuchEntityExceptionByCartId() + public function testCreateCustomerCart() { - $cartId = 956; - $customerId = 125; - $storeId = 12; + $storeId = 345; + $userId = 50; + + $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); + $this->customerRegistryMock->expects($this->once()) + ->method('retrieve')->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->once())->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->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue(33)); - $customerRegistryMock = - $this->getMock('\Magento\Customer\Model\CustomerRegistry', [], [], '', false); - $customerRegistryMock->expects($this->never())->method('retrieve'); - $this->service->assignCustomer($cartId, $customerId); + $customerQuoteMock = $this->getMock('\Magento\Sales\Model\Quote', + [ + 'loadByCustomer', + 'getIsActive', + 'getId', + '__wakeup' + ], + [], + '', + false + ); + $customerQuoteMock->expects($this->once()) + ->method('loadByCustomer') + ->with($customerMock) + ->will($this->returnSelf()); + $this->quoteFactoryMock->expects($this->at(0))->method('create')->willReturn($customerQuoteMock); + $this->quoteFactoryMock->expects($this->at(1))->method('create')->willReturn($this->quoteMock); + $customerQuoteMock->expects($this->once())->method('getId')->willReturn(1); + $customerQuoteMock->expects($this->once())->method('getIsActive')->willReturn(false); + + $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->quoteMock->expects($this->once())->method('save'); + $this->quoteMock->expects($this->once())->method('getId')->willReturn(100); + $this->assertEquals(100, $this->service->create()); } /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage There is no cart with provided ID. + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + * @expectedExceptionMessage Cannot create quote */ - public function testAssignCustomerNoSuchEntityExceptionByStoreId() + public function testCreateWithException() { - $cartId = 956; - $customerId = 125; - $storeId = 12; + $storeId = 345; $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue($cartId)); - $this->quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue(99)); - $this->customerRegistryMock->expects($this->never())->method('retrieve'); + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('setStoreId')->with($storeId); + $this->quoteMock->expects($this->once())->method('save') + ->will($this->throwException(new CouldNotSaveException('Cannot create quote'))); - $this->service->assignCustomer($cartId, $customerId); + $this->service->create(); } /** @@ -192,11 +260,8 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue($cartId)); - $this->quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId)); + $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId) + ->will($this->returnValue($this->quoteMock)); $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); $this->customerRegistryMock->expects($this->once()) ->method('retrieve')->with($customerId)->will($this->returnValue($customerMock)); @@ -215,13 +280,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $customerId = 125; $storeId = 12; + $this->quoteRepositoryMock->expects($this->once())->method('get')->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)); - $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue($cartId)); - $this->quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId)); $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); $this->customerRegistryMock->expects($this->once()) ->method('retrieve')->with($customerId)->will($this->returnValue($customerMock)); @@ -232,6 +294,38 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $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('get')->with($cartId)->will($this->returnValue($this->quoteMock)); + + $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); + $this->customerRegistryMock->expects($this->once()) + ->method('retrieve')->with($customerId)->will($this->returnValue($customerMock)); + $customerMock->expects($this->once())->method('getSharedStoreIds')->will($this->returnValue([$storeId])); + $this->quoteMock->expects($this->once())->method('getCustomerId')->will($this->returnValue(null)); + + $customerQuoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $customerQuoteMock->expects($this->once())->method('loadByCustomer')->with($customerMock) + ->will($this->returnSelf()); + $customerQuoteMock->expects($this->once())->method('getId')->will($this->returnValue(1)); + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($customerQuoteMock)); + + $this->quoteMock->expects($this->never())->method('setCustomer'); + + $this->service->assignCustomer($cartId, $customerId); + } + public function testAssignCustomer() { $cartId = 956; @@ -240,11 +334,8 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteFactoryMock->expects($this->at(0))->method('create')->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue($cartId)); - $this->quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId)); + $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId) + ->will($this->returnValue($this->quoteMock)); $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); $this->customerRegistryMock->expects($this->once()) ->method('retrieve')->with($customerId)->will($this->returnValue($customerMock)); @@ -252,7 +343,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $customerQuoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); $customerQuoteMock->expects($this->once())->method('loadByCustomer')->with($customerMock) ->will($this->returnSelf()); - $this->quoteFactoryMock->expects($this->at(1))->method('create')->will($this->returnValue($customerQuoteMock)); + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($customerQuoteMock)); $customerMock->expects($this->once())->method('getSharedStoreIds')->will($this->returnValue([$storeId])); $this->quoteMock->expects($this->once())->method('getCustomerId')->will($this->returnValue(false)); @@ -265,4 +356,18 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->service->assignCustomer($cartId, $customerId)); } -} \ No newline at end of file + public function testOrder() + { + $cartId = 123; + $quoteService = $this->getMock('Magento\Sales\Model\Service\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId) + ->will($this->returnValue($this->quoteMock)); + $this->quoteServiceFactory->expects($this->once())->method('create')->with(['quote' => $this->quoteMock]) + ->will($this->returnValue($quoteService)); + $orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $orderMock->expects($this->any())->method('getId')->will($this->returnValue(5)); + $quoteService->expects($this->once())->method('submitOrderWithDataObject') + ->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 index c88416c1b27a85e3df642c8e1e1ddaf0cb2ed978..96564334b58bd10dee44cfde928547645e8ce1bb 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php @@ -37,32 +37,25 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteLoaderMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $couponBuilderMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\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', [ - 'quoteLoader' => $this->quoteLoaderMock, + 'quoteRepository' => $this->quoteRepositoryMock, 'couponBuilder' => $this->couponBuilderMock, - 'storeManager' => $this->storeManagerMock ] ); } @@ -70,18 +63,14 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase public function testGetCoupon() { $cartId = 11; - $storeId = 12; $couponCode = 'test_coupon_code'; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', ['getCouponCode', '__wakeup'], [], '', false); $quoteMock->expects($this->any())->method('getCouponCode')->will($this->returnValue($couponCode)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $data = [Coupon::COUPON_CODE => $couponCode]; diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php index 584de65681b697f808347c125c67adcd0537710f..3052a61480bcdb79882cab3711d5c4adf97bf916 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php @@ -35,7 +35,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteLoaderMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -47,11 +47,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ protected $couponBuilderMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -70,8 +65,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $this->couponBuilderMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CouponBuilder', [], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); @@ -104,9 +98,8 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->service = $objectManager->getObject( 'Magento\Checkout\Service\V1\Coupon\WriteService', [ - 'quoteLoader' => $this->quoteLoaderMock, + 'quoteRepository' => $this->quoteRepositoryMock, 'couponBuilder' => $this->couponBuilderMock, - 'storeManager' => $this->storeManagerMock ] ); } @@ -117,13 +110,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ public function testSetWhenCartDoesNotContainsProducts() { - $storeId = 10; $cartId = 33; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(0)); $this->service->set($cartId, $this->couponCodeDataMock); @@ -135,14 +125,11 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ public function testSetWhenCouldNotApplyCoupon() { - $storeId = 10; $cartId = 33; $couponCode = '153a-ABC'; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12)); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); @@ -164,14 +151,11 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ public function testSetWhenCouponCodeIsInvalid() { - $storeId = 10; $cartId = 33; $couponCode = '153a-ABC'; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12)); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); @@ -188,14 +172,11 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testSet() { - $storeId = 10; $cartId = 33; $couponCode = '153a-ABC'; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12)); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); @@ -216,13 +197,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ public function testDeleteWhenCartDoesNotContainsProducts() { - $storeId = 24; $cartId = 65; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(0)); $this->quoteMock->expects($this->never())->method('getShippingAddress'); @@ -235,13 +213,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ public function testDeleteWhenCouldNotDeleteCoupon() { - $storeId = 24; $cartId = 65; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12)); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); @@ -262,13 +237,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase */ public function testDeleteWhenCouponIsNotEmpty() { - $storeId = 24; $cartId = 65; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12)); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); @@ -284,13 +256,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testDelete() { - $storeId = 24; $cartId = 65; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12)); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); @@ -304,4 +273,3 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->service->delete($cartId)); } } - \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php index 09d3eb7aa2131610fd388ce424dc36f5ea0b621e..56ed22b04a3e5381542d5a2012030f08fc03d1c0 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php @@ -65,8 +65,13 @@ class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); - $this->builderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', [], [], '', false); + $this->builderMock = $this->getMock( + '\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', + ['populateWithArray', 'create'], + [], + '', + false + ); $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->currencyMock = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $this->shippingMethodMock = 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 index f9f5da840385cef59768b63c00f1a257026bbe28..37657627ce6fecbfe580302f7dcc51da4942f919 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/CartMapperTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/CartMapperTest.php @@ -30,17 +30,106 @@ class CartMapperTest extends \PHPUnit_Framework_TestCase */ 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->mapper = new \Magento\Checkout\Service\V1\Data\CartMapper(); + $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', - '__wakeUp']; + 'getAllItems', '__wakeUp']; $quoteMock = $this->getMock('Magento\Sales\Model\Quote', $methods, [], '', false); + $itemMock = $this->getMock('Magento\Sales\Model\Quote\Item', [], [], '', false); + $quoteMock->expects($this->once())->method('getAllItems')->will($this->returnValue([$itemMock])); $expected = [ Cart::ID => 12, Cart::STORE_ID => 1, @@ -72,7 +161,28 @@ class CartMapperTest extends \PHPUnit_Framework_TestCase 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->assertEquals($expected, $this->mapper->map($quoteMock)); + $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 index 27f65b8895d47f36398a205166da94d0c7d38f88..958fe08ac3c35ff65b6d0cde86060f3bb53cff07 100644 --- 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 @@ -47,7 +47,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->paymentMethodBuilderMock = $this->getMock( - '\Magento\Checkout\Service\V1\Data\PaymentMethodBuilder', [], [], '', false + '\Magento\Checkout\Service\V1\Data\PaymentMethodBuilder', ['populateWithArray', 'create'], [], '', false ); $this->converter = $this->objectManager->getObject( diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php index fe9d54fe9bf1ab503c783b197fe0718d2a701eb9..a6a4935947fd88d31b13fe5f418e45f35e9781cd 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php @@ -36,16 +36,10 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase * @var \Magento\TestFramework\Helper\ObjectManager */ protected $objectManager; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteLoaderMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -65,8 +59,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $this->quoteMethodConverterMock = $this->getMock( '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter', [], [], '', false ); @@ -78,8 +71,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->service = $this->objectManager->getObject( '\Magento\Checkout\Service\V1\PaymentMethod\ReadService', [ - 'quoteLoader' => $this->quoteLoaderMock, - 'storeManager' => $this->storeManagerMock, + 'quoteRepository' => $this->quoteRepositoryMock, 'quoteMethodConverter' => $this->quoteMethodConverterMock, 'paymentMethodConverter' => $this->paymentMethodConverterMock, 'methodList' => $this->methodListMock, @@ -90,19 +82,14 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase public function testGetPaymentIfPaymentMethodNotSet() { $cartId = 11; - $storeId = 12; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); $paymentMock = $this->getMock('\Magento\Sales\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->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $this->assertNull($this->service->getPayment($cartId)); @@ -111,10 +98,6 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase public function testGetPaymentSuccess() { $cartId = 11; - $storeId = 12; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $paymentMock = $this->getMock('\Magento\Sales\Model\Quote\Payment', [], [], '', false); $paymentMock->expects($this->once())->method('getId')->will($this->returnValue(1)); @@ -122,9 +105,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); @@ -140,16 +123,11 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase public function testGetList() { $cartId = 10; - $storeId = 12; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $methodList = [ @@ -176,4 +154,3 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedResult, $this->service->getList($cartId)); } } - \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php index 28767afa9877436d5e5cc030c4a3444efe29bf7a..5c55444d16b122c461660fd12c2be9210e193f54 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php @@ -40,12 +40,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteLoaderMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -65,8 +60,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $this->paymentMethodBuilderMock = $this->getMock( '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder', [], [], '', false ); @@ -76,8 +70,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->service = $this->objectManager->getObject( '\Magento\Checkout\Service\V1\PaymentMethod\WriteService', [ - 'quoteLoader' => $this->quoteLoaderMock, - 'storeManager' => $this->storeManagerMock, + 'quoteRepository' => $this->quoteRepositoryMock, 'paymentMethodBuilder' => $this->paymentMethodBuilderMock, 'methodList' => $this->methodListMock, 'zeroTotalValidator' => $this->validatorMock, @@ -92,10 +85,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testSetVirtualQuotePaymentThrowsExceptionIfBillingAdressNotSet() { $cartId = 11; - $storeId = 12; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $paymentsCollectionMock = $this->getMock( '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false @@ -110,9 +99,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $billingAddressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); @@ -123,12 +112,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testSetVirtualQuotePaymentSuccess() { $cartId = 11; - $storeId = 12; $paymentId = 13; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $paymentsCollectionMock = $this->getMock( '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false ); @@ -164,9 +148,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); @@ -188,10 +172,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testSetVirtualQuotePaymentFail() { $cartId = 11; - $storeId = 12; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $paymentsCollectionMock = $this->getMock( '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false @@ -229,9 +209,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $quoteMock->expects($this->never())->method('getPayment'); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); @@ -253,11 +233,6 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testSetNotVirtualQuotePaymentThrowsExceptionIfShippingAddressNotSet() { $cartId = 11; - $storeId = 12; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); - $quoteMock = $this->getMock( '\Magento\Sales\Model\Quote', ['__wakeup', 'getPaymentsCollection', 'isVirtual', 'getShippingAddress'], [], '', false @@ -275,9 +250,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->method('getShippingAddress') ->will($this->returnValue($this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false))); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); @@ -294,11 +269,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testSetNotVirtualQuotePaymentSuccess() { $cartId = 11; - $storeId = 12; $paymentId = 13; - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $paymentsCollectionMock = $this->getMock( '\Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false @@ -336,9 +307,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load') - ->with($cartId, $storeId) + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->with($cartId) ->will($this->returnValue($quoteMock)); $paymentMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/QuoteLoaderTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/QuoteLoaderTest.php deleted file mode 100644 index 50e3eb8b9f7177ed01fc66c227f8e6aa1db39791..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/QuoteLoaderTest.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Checkout\Service\V1; - -class QuoteLoaderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var QuoteLoader - */ - protected $quoteLoader; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteFactoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteMock; - - protected function setUp() - { - $this->quoteFactoryMock = $this->getMock('\Magento\Sales\Model\QuoteFactory', ['create'], [], '', false); - $this->quoteMock = - $this->getMock( - '\Magento\Sales\Model\Quote', - ['setStoreId', 'load', 'getId', '__wakeup', 'getIsActive'], - [], - '', - false - ); - $this->quoteLoader = new QuoteLoader($this->quoteFactoryMock); - } - - public function testLoadWithId() - { - $storeId = 1; - $cartId = 45; - $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('setStoreId')->with($storeId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('load')->with($cartId); - $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue(33)); - $this->quoteMock->expects($this->once())->method('getIsActive')->will($this->returnValue(true)); - - $this->assertEquals($this->quoteMock, $this->quoteLoader->load($cartId, $storeId)); - } - - /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage No such entity with cartId = 34 - */ - public function testLoadWithoutId() - { - $storeId = 12; - $cartId = 34; - $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('setStoreId')->with($storeId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once())->method('load')->with($cartId); - $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue(false)); - $this->quoteLoader->load($cartId, $storeId); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php index 8d805647cca9295fc06c5e057c73dbfc96d0dd00..4ce1ee8c402b70d2eb936aa606372022fb87f705 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php @@ -38,17 +38,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteLoaderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -78,10 +68,14 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); - $this->methodBuilderMock = - $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', [], [], '', false); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\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\Sales\Model\Quote', @@ -123,8 +117,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->service = $this->objectManager->getObject( '\Magento\Checkout\Service\V1\ShippingMethod\ReadService', [ - 'quoteLoader' => $this->quoteLoaderMock, - 'storeManager' => $this->storeManagerMock, + 'quoteRepository' => $this->quoteRepositoryMock, 'methodBuilder' => $this->methodBuilderMock, 'converter' => $this->converterMock, ] @@ -137,13 +130,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase */ public function testGetMethodWhenShippingAddressIsNotSet() { - $storeId = 12; $cartId = 666; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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)); @@ -157,13 +146,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase */ public function testGetMethodWhenShippingMethodIsInvalid() { - $storeId = 12; $cartId = 884; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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)); @@ -176,14 +161,10 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase public function testGetMethod() { - $storeId = 12; $cartId = 666; $countryId = 1; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); $this->shippingAddressMock->expects($this->any()) @@ -212,15 +193,28 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->service->getMethod($cartId); } + public function testGetMethodIfMethodIsNotSet() + { + $cartId = 666; + $countryId = 1; + + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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() { - $storeId = 12; $cartId = 834; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('isVirtual')->will($this->returnValue(true)); @@ -229,13 +223,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase public function testGetListForEmptyCart() { - $storeId = 12; $cartId = 834; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('isVirtual')->will($this->returnValue(false)); $this->quoteMock->expects($this->once()) @@ -250,13 +240,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase */ public function testGetListWhenShippingAddressIsNotSet() { - $storeId = 12; $cartId = 834; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('isVirtual')->will($this->returnValue(false)); $this->quoteMock->expects($this->once()) @@ -270,13 +256,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase public function testGetList() { - $storeId = 12; $cartId = 834; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('isVirtual')->will($this->returnValue(false)); $this->quoteMock->expects($this->once()) diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php index cdea76c91af328fadd205eb4a2e77793d201e1a3..910da9ef2cbb1f199c816abd8e1df164e35a8845 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php @@ -40,23 +40,13 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $quoteLoaderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManagerMock; + protected $quoteRepositoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $quoteMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storeMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -66,8 +56,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase { $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->addressFactoryMock = $this->getMock('\Magento\Sales\Model\Quote\AddressFactory', [], [], '', false); - $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); + $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); $this->quoteMock = $this->getMock( '\Magento\Sales\Model\Quote', [ @@ -83,7 +72,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->shippingAddressMock = $this->getMock( '\Magento\Sales\Model\Quote\Address', [ @@ -102,8 +91,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase 'Magento\Checkout\Service\V1\ShippingMethod\WriteService', [ 'addressFactory' => $this->addressFactoryMock, - 'quoteLoader' => $this->quoteLoaderMock, - 'storeManager' => $this->storeManagerMock + 'quoteRepository' => $this->quoteRepositoryMock ] ); } @@ -117,12 +105,8 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 12; $carrierCode = 34; $methodCode = 56; - $storeId = 78; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(0)); $this->quoteMock->expects($this->never())->method('isVirtual'); @@ -138,12 +122,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 12; $carrierCode = 34; $methodCode = 56; - $storeId = 78; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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)); @@ -159,12 +140,8 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 12; $carrierCode = 34; $methodCode = 56; - $storeId = 78; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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()) @@ -183,13 +160,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 12; $carrierCode = 34; $methodCode = 56; - $storeId = 78; $countryId = 1; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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()) @@ -219,13 +193,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 12; $carrierCode = 34; $methodCode = 56; - $storeId = 78; $countryId = 1; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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()) @@ -260,13 +230,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 12; $carrierCode = 34; $methodCode = 56; - $storeId = 78; $countryId = 1; - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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()) @@ -306,12 +273,8 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 12; $carrierCode = 34; $methodCode = 56; - $storeId = 78; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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()) @@ -326,13 +289,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $cartId = 12; $carrierCode = 34; $methodCode = 56; - $storeId = 78; $countryId = 1; - - $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); - $this->quoteLoaderMock->expects($this->once()) - ->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get')->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()) diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php index 767a09888348813a397ff6e5e1935ae62480743f..b24e9ab0c2b91ed3021a20f291be36c3db7bfd12 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php @@ -121,7 +121,8 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase array(), '', false - ) + ), + 'priceCurrency' => $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock() ); $childItem = $objectManagerHelper->getObject('Magento\Sales\Model\Quote\Item', $arguments); $childItem->setData('product', $childProduct); diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php index 02a376721264830fb6db5db3d31f4e11f632fb3b..18b0466a3b6b76a8aa883eb3c59126c6c2c9d1b3 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php @@ -75,6 +75,11 @@ class AttributePriceTest extends \PHPUnit_Framework_TestCase */ protected $attributeMock; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + /** * Test setUp */ @@ -114,12 +119,14 @@ class AttributePriceTest extends \PHPUnit_Framework_TestCase '', false ); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $this->attribute = new AttributePrice( $this->saleableItemMock, $qty, $this->calculatorMock, $this->priceModifier, - $this->storeManagerMock + $this->storeManagerMock, + $this->priceCurrency ); } @@ -131,7 +138,8 @@ class AttributePriceTest extends \PHPUnit_Framework_TestCase $qty, $this->calculatorMock, $this->priceModifier, - $this->storeManagerMock + $this->storeManagerMock, + $this->priceCurrency ); $this->assertInstanceOf('Magento\ConfigurableProduct\Pricing\Price\AttributePrice', $object); } @@ -223,8 +231,8 @@ class AttributePriceTest extends \PHPUnit_Framework_TestCase $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') ->disableOriginalConstructor() ->getMock(); - $storeMock->expects($this->once()) - ->method('convertPrice') + $this->priceCurrency->expects($this->once()) + ->method('convert') ->with($this->equalTo($modifiedValue)) ->will($this->returnArgument(0)); @@ -309,7 +317,8 @@ class AttributePriceTest extends \PHPUnit_Framework_TestCase ->with( $this->equalTo(55), $this->equalTo($this->saleableItemMock), - $this->equalTo(\Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE) + null, + [\Magento\Catalog\Pricing\Price\CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true] ) ->will($this->returnValue(57.55)); $this->assertEquals( @@ -341,7 +350,8 @@ class AttributePriceTest extends \PHPUnit_Framework_TestCase ->with( $this->equalTo(77.67), $this->equalTo($this->saleableItemMock), - $this->equalTo(\Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE) + null, + [\Magento\Catalog\Pricing\Price\CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true] ) ->will($this->returnValue(80.99)); $this->assertEquals( diff --git a/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php b/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php index 627a354c85daf5d3730ddfe0f298f2bd37d45873..9dcab9c90aea6902d275ba9c88ffe689958c40cd 100644 --- a/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php +++ b/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php @@ -89,10 +89,18 @@ class CarrierTest extends \PHPUnit_Framework_TestCase false ); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); + $priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $priceCurrency->expects($this->once()) + ->method('round') + ->willReturnCallback( + function ($price) { + round($price, 2); + } + ); $rateMethod = $this->getMock( 'Magento\Sales\Model\Quote\Address\RateResult\Method', null, - ['storeManager' => $storeManager] + ['priceCurrency' => $priceCurrency] ); $rateMethodFactory = $this->getMock( 'Magento\Sales\Model\Quote\Address\RateResult\MethodFactory', diff --git a/dev/tests/unit/testsuite/Magento/Framework/Acl/BuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Acl/BuilderTest.php index b3873a96ca3d0b86a839cdb953b05a6e84f9aaf1..43ceaf4285327a344f374c850bc8bc9168379240 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Acl/BuilderTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Acl/BuilderTest.php @@ -78,17 +78,6 @@ class BuilderTest extends \PHPUnit_Framework_TestCase ); } - protected function tearDown() - { - unset($this->_aclMock); - unset($this->_aclFactoryMock); - unset($this->_ruleLoader); - unset($this->_roleLoader); - unset($this->_resourceLoader); - unset($this->_model); - unset($this->_aclCacheMock); - } - public function testGetAclUsesLoadersProvidedInConfigurationToPopulateAclIfCacheIsEmpty() { $this->_aclCacheMock->expects($this->at(1))->method('has')->will($this->returnValue(false)); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Authorization/Policy/AclTest.php b/dev/tests/unit/testsuite/Magento/Framework/Authorization/Policy/AclTest.php index a2381f5b82c60d509e0062d6bbbeba9eee2257cc..95c488de2092f97fa17491a23ef0a373a17f6f56 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Authorization/Policy/AclTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Authorization/Policy/AclTest.php @@ -30,8 +30,14 @@ class AclTest extends \PHPUnit_Framework_TestCase */ protected $_model; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ protected $_aclMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ protected $_aclBuilderMock; protected function setUp() diff --git a/dev/tests/unit/testsuite/Magento/Framework/Math/CalculatorTest.php b/dev/tests/unit/testsuite/Magento/Framework/Math/CalculatorTest.php index 2c631b8969e527a97f1127ffdf727818b1296ba5..89f3ad21dd51fd2c89a183f65d65fec7e7dd5b77 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Math/CalculatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Math/CalculatorTest.php @@ -33,18 +33,18 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject */ - protected $_scopeMock; + protected $priceCurrency; public function setUp() { - $this->_scopeMock = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); - $this->_scopeMock->expects($this->any()) - ->method('roundPrice') + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->priceCurrency->expects($this->any()) + ->method('round') ->will($this->returnCallback(function ($argument) { return round($argument, 2); })); - $this->_model = new \Magento\Framework\Math\Calculator($this->_scopeMock); + $this->_model = new \Magento\Framework\Math\Calculator($this->priceCurrency); } /** diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Element/Text/TextList/ItemTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Element/Text/TextList/ItemTest.php index 478add800fd09307758add53927caf20cbcf6957..4b4ca98a0312b191904c90288ba32f7d9d2046c7 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Element/Text/TextList/ItemTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Element/Text/TextList/ItemTest.php @@ -56,6 +56,11 @@ class ItemTest extends \PHPUnit_Framework_TestCase /** * @dataProvider toHtmlDataProvider + * + * @param array $liParams + * @param string $attrName + * @param string $attrValue + * @param string $innerText */ public function testToHtml($liParams, $attrName, $attrValue, $innerText) { @@ -75,7 +80,8 @@ class ItemTest extends \PHPUnit_Framework_TestCase 'attrName' => 'class', 'attrValue' => 'some-css-class', 'innerText' => 'text', - ], [ + ], + [ 'liParams' => 'class="some-css-class"', 'attrName' => 'class', 'attrValue' => 'some-css-class', diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php index 083dcd1530576f65e802bfb2dd92942a9893ee23..8d7a5abfdf0625399256101b979945a00822e962 100644 --- a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/ReadServiceTest.php @@ -42,11 +42,6 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase */ protected $messageFactoryMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $builderMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -86,7 +81,6 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase [], '', false); - $this->builderMock = $this->getMock('\Magento\GiftMessage\Service\V1\Data\MessageBuilder', [], [], '', false); $this->messageMapperMock = $this->getMock( '\Magento\GiftMessage\Service\V1\Data\MessageMapper', [ @@ -122,7 +116,6 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase [ 'quoteRepository' => $this->quoteRepositoryMock, 'messageFactory' => $this->messageFactoryMock, - 'builderMock' => $this->builderMock, 'messageMapper' => $this->messageMapperMock, ] ); diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts/ListAssociatedProductsTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts/ListAssociatedProductsTest.php index d47fb7d6069b46d7001662ebe004d80a7bcb6284..5dbab9fa71d18650a594593b2540b9b526d7f3c5 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts/ListAssociatedProductsTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts/ListAssociatedProductsTest.php @@ -60,6 +60,11 @@ class ListAssociatedProductsTest extends \PHPUnit_Framework_TestCase */ protected $block; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + protected function setUp() { $this->contextMock = $this->getMock('Magento\Backend\Block\Template\Context', array(), array(), '', false); @@ -83,7 +88,9 @@ class ListAssociatedProductsTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->storeManagerMock) ); - $this->block = new ListAssociatedProducts($this->contextMock, $this->registryMock); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + + $this->block = new ListAssociatedProducts($this->contextMock, $this->registryMock, $this->priceCurrency); } /** @@ -92,10 +99,10 @@ class ListAssociatedProductsTest extends \PHPUnit_Framework_TestCase */ public function testGetAssociatedProducts() { - $this->storeMock->expects( + $this->priceCurrency->expects( $this->any() )->method( - 'formatPrice' + 'format' )->with( '1.00', false diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/FlushAllCacheTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/FlushAllCacheTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3c7e3cc971a26e23d7c9b59098e221eb1746253b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/FlushAllCacheTest.php @@ -0,0 +1,74 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Observer; + +class FlushAllCacheTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\PageCache\Model\Observer\FlushAllCache */ + protected $_model; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\PageCache\Model\Config */ + protected $_configMock; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\PageCache\Cache */ + protected $_cacheMock; + + /** + * Set up all mocks and data for test + */ + public function setUp() + { + $this->_configMock = $this->getMock( + 'Magento\PageCache\Model\Config', + array('getType', 'isEnabled'), + array(), + '', + false + ); + $this->_cacheMock = $this->getMock('Magento\Framework\App\PageCache\Cache', array('clean'), array(), '', false); + + $this->_model = new \Magento\PageCache\Model\Observer\FlushAllCache( + $this->_configMock, + $this->_cacheMock + ); + } + + /** + * Test case for flushing all the cache + */ + public function testExecute() + { + $this->_configMock->expects( + $this->once() + )->method( + 'getType' + )->will( + $this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN) + ); + + $this->_cacheMock->expects($this->once())->method('clean'); + $this->_model->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/FlushCacheByTagsTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/FlushCacheByTagsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4e51b8808f843b7a7efa06deb772d156a67e0185 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/FlushCacheByTagsTest.php @@ -0,0 +1,99 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Observer; + +class FlushCacheByTagsTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\PageCache\Model\Observer\FlushCacheByTags */ + protected $_model; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\PageCache\Model\Config */ + protected $_configMock; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\PageCache\Cache */ + protected $_cacheMock; + + /** + * Set up all mocks and data for test + */ + public function setUp() + { + $this->_configMock = $this->getMock( + 'Magento\PageCache\Model\Config', + array('getType', 'isEnabled'), + array(), + '', + false + ); + $this->_cacheMock = $this->getMock('Magento\Framework\App\PageCache\Cache', array('clean'), array(), '', false); + + $this->_model = new \Magento\PageCache\Model\Observer\FlushCacheByTags( + $this->_configMock, + $this->_cacheMock + ); + } + + /** + * Test case for cache invalidation + * + * @dataProvider flushCacheByTagsDataProvider + * @param $cacheState + */ + public function testExecute($cacheState) + { + $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState)); + $observerObject = $this->getMock('Magento\Framework\Event\Observer'); + $observedObject = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + + if ($cacheState) { + $tags = array('cache_1', 'cache_group'); + $expectedTags = array('cache_1', 'cache_group', 'cache'); + + $eventMock = $this->getMock('Magento\Framework\Event', array('getObject'), array(), '', false); + $eventMock->expects($this->once())->method('getObject')->will($this->returnValue($observedObject)); + $observerObject->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock)); + $this->_configMock->expects( + $this->once() + )->method( + 'getType' + )->will( + $this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN) + ); + $observedObject->expects($this->once())->method('getIdentities')->will($this->returnValue($tags)); + + $this->_cacheMock->expects($this->once())->method('clean')->with($this->equalTo($expectedTags)); + } + + $this->_model->execute($observerObject); + } + + public function flushCacheByTagsDataProvider() + { + return array( + 'full_page cache type is enabled' => array(true), + 'full_page cache type is disabled' => array(false) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/InvalidateCacheTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/InvalidateCacheTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2aa9cf52f76262b5a8dddb673c63e9201336decb --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/InvalidateCacheTest.php @@ -0,0 +1,77 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Observer; + +class InvalidateCacheTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\PageCache\Model\Observer\InvalidateCache */ + protected $_model; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\PageCache\Model\Config */ + protected $_configMock; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Cache\TypeListInterface */ + protected $_typeListMock; + + /** + * Set up all mocks and data for test + */ + public function setUp() + { + $this->_configMock = $this->getMock( + 'Magento\PageCache\Model\Config', + array('getType', 'isEnabled'), + array(), + '', + false + ); + $this->_typeListMock = $this->getMock('Magento\Framework\App\Cache\TypeList', array(), array(), '', false); + + $this->_model = new \Magento\PageCache\Model\Observer\InvalidateCache( + $this->_configMock, + $this->_typeListMock + ); + } + + /** + * @dataProvider invalidateCacheDataProvider + * @param bool $cacheState + */ + public function testExecute($cacheState) + { + $this->_configMock->expects($this->once())->method('isEnabled')->will($this->returnValue($cacheState)); + + if ($cacheState) { + $this->_typeListMock->expects($this->once())->method('invalidate')->with($this->equalTo('full_page')); + } + $this->_model->execute(); + } + + public function invalidateCacheDataProvider() + { + return array(array(true), array(false)); + } + +} diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/ProcessLayoutRenderElementTest.php similarity index 55% rename from dev/tests/unit/testsuite/Magento/PageCache/Model/ObserverTest.php rename to dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/ProcessLayoutRenderElementTest.php index 369230ae419a45d053e6ccbd6d47e140ae9471ac..b34e1ac22a3b7da3bee57cfe80528b33ec1e5635 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/ProcessLayoutRenderElementTest.php @@ -1,5 +1,6 @@ <?php /** + * * Magento * * NOTICE OF LICENSE @@ -21,49 +22,31 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\PageCache\Model; +namespace Magento\PageCache\Model\Observer; -class ObserverTest extends \PHPUnit_Framework_TestCase +class ProcessLayoutRenderElementTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\PageCache\Model\Observer */ + /** @var \Magento\PageCache\Model\Observer\ProcessLayoutRenderElement */ protected $_model; /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\PageCache\Model\Config */ protected $_configMock; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\PageCache\Cache */ - protected $_cacheMock; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Element\AbstractBlock */ protected $_blockMock; + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\PageCache\Helper\Data */ + protected $_helperMock; + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Layout */ protected $_layoutMock; /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Event\Observer */ protected $_observerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\PageCache\Helper\Data */ - protected $_helperMock; - - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Cache\TypeListInterface */ - protected $_typeListMock; - /** @var \Magento\Framework\Object */ protected $_transport; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\PageCache\Model\Observer */ - protected $_observerObject; - - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\PageCache\FormKey */ - protected $_formKey; - - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Session\Generic */ - protected $_session; - - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Escaper */ - protected $_escaper; - /** * Set up all mocks and data for test */ @@ -76,21 +59,11 @@ class ObserverTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_cacheMock = $this->getMock('Magento\Framework\App\PageCache\Cache', array('clean'), array(), '', false); $this->_helperMock = $this->getMock('Magento\PageCache\Helper\Data', array(), array(), '', false); - $this->_typeListMock = $this->getMock('Magento\Framework\App\Cache\TypeList', array(), array(), '', false); - $this->_formKey = $this->getMock('Magento\Framework\App\PageCache\FormKey', array(), array(), '', false); - $this->_session = $this->getMock('Magento\Framework\Session\Generic', array('setData'), array(), '', false); - $this->_escaper = $this->getMock('\Magento\Framework\Escaper', array('escapeHtml'), array(), '', false); - $this->_model = new \Magento\PageCache\Model\Observer( + $this->_model = new \Magento\PageCache\Model\Observer\ProcessLayoutRenderElement( $this->_configMock, - $this->_cacheMock, - $this->_helperMock, - $this->_typeListMock, - $this->_formKey, - $this->_session, - $this->_escaper + $this->_helperMock ); $this->_observerMock = $this->getMock( 'Magento\Framework\Event\Observer', @@ -116,7 +89,6 @@ class ObserverTest extends \PHPUnit_Framework_TestCase array('getData', 'isScopePrivate', 'getNameInLayout', 'getUrl') ); $this->_transport = new \Magento\Framework\Object(array('output' => 'test output html')); - $this->_observerObject = $this->getMock('\Magento\Store\Model\Store', array(), array(), '', false); } /** @@ -127,7 +99,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase * @param string $expectedOutput * @dataProvider processLayoutRenderDataProvider */ - public function testProcessLayoutRenderElement( + public function testExecute( $cacheState, $varnishIsEnabled, $scopeIsPrivate, @@ -155,10 +127,10 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->_layoutMock->expects( $this->once() )->method( - 'getBlock' - )->will( - $this->returnValue($this->_blockMock) - ); + 'getBlock' + )->will( + $this->returnValue($this->_blockMock) + ); if ($varnishIsEnabled) { $this->_blockMock->expects($this->once()) @@ -173,21 +145,21 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->_blockMock->expects( $this->once() )->method( - 'getNameInLayout' - )->will( - $this->returnValue('testBlockName') - ); + 'getNameInLayout' + )->will( + $this->returnValue('testBlockName') + ); $this->_blockMock->expects( $this->once() )->method( - 'isScopePrivate' - )->will( - $this->returnValue($scopeIsPrivate) - ); + 'isScopePrivate' + )->will( + $this->returnValue($scopeIsPrivate) + ); } $this->_configMock->expects($this->any())->method('getType')->will($this->returnValue($varnishIsEnabled)); } - $this->_model->processLayoutRenderElement($this->_observerMock); + $this->_model->execute($this->_observerMock); $this->assertEquals($expectedOutput, $this->_transport['output']); } @@ -238,103 +210,4 @@ class ObserverTest extends \PHPUnit_Framework_TestCase 'full_page type is disabled, Varnish enabled' => array(false, true, false, null, 'test output html') ); } - - /** - * Test case for cache invalidation - * - * @dataProvider flushCacheByTagsDataProvider - * @param $cacheState - */ - public function testFlushCacheByTags($cacheState) - { - $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState)); - - if ($cacheState) { - $tags = array('cache_1', 'cache_group'); - $expectedTags = array('cache_1', 'cache_group', 'cache'); - - $eventMock = $this->getMock('Magento\Framework\Event', array('getObject'), array(), '', false); - $eventMock->expects($this->once())->method('getObject')->will($this->returnValue($this->_observerObject)); - $this->_observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock)); - $this->_configMock->expects( - $this->once() - )->method( - 'getType' - )->will( - $this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN) - ); - $this->_observerObject->expects($this->once())->method('getIdentities')->will($this->returnValue($tags)); - - $this->_cacheMock->expects($this->once())->method('clean')->with($this->equalTo($expectedTags)); - } - - $this->_model->flushCacheByTags($this->_observerMock); - } - - public function flushCacheByTagsDataProvider() - { - return array( - 'full_page cache type is enabled' => array(true), - 'full_page cache type is disabled' => array(false) - ); - } - - /** - * Test case for flushing all the cache - */ - public function testFlushAllCache() - { - $this->_configMock->expects( - $this->once() - )->method( - 'getType' - )->will( - $this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN) - ); - - $this->_cacheMock->expects($this->once())->method('clean'); - $this->_model->flushAllCache($this->_observerMock); - } - - /** - * @dataProvider invalidateCacheDataProvider - * @param bool $cacheState - */ - public function testInvalidateCache($cacheState) - { - $this->_configMock->expects($this->once())->method('isEnabled')->will($this->returnValue($cacheState)); - - if ($cacheState) { - $this->_typeListMock->expects($this->once())->method('invalidate')->with($this->equalTo('full_page')); - } - $this->_model->invalidateCache(); - } - - public function invalidateCacheDataProvider() - { - return array(array(true), array(false)); - } - - public function testRegisterFormKeyFromCookie() - { - //Data - $formKey = '<asdfaswqrwqe12>'; - $escapedFormKey = 'asdfaswqrwqe12'; - - //Verification - $this->_formKey->expects($this->once()) - ->method('get') - ->will($this->returnValue($formKey)); - - $this->_escaper->expects($this->once()) - ->method('escapeHtml') - ->with($formKey) - ->will($this->returnValue($escapedFormKey)); - - $this->_session->expects($this->once()) - ->method('setData') - ->with(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $escapedFormKey); - - $this->_model->registerFormKeyFromCookie($this->_observerMock); - } } diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/RegisterFormKeyFromCookieTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/RegisterFormKeyFromCookieTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1e872be55b8e92337be7d176751776cbc2a3c43b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/Observer/RegisterFormKeyFromCookieTest.php @@ -0,0 +1,79 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Observer; + +class RegisterFormKeyFromCookieTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\PageCache\Model\Observer\RegisterFormKeyFromCookie */ + protected $_model; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\PageCache\FormKey */ + protected $_formKey; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Session\Generic */ + protected $_session; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Escaper */ + protected $_escaper; + + /** + * Set up all mocks and data for test + */ + public function setUp() + { + $this->_formKey = $this->getMock('Magento\Framework\App\PageCache\FormKey', array(), array(), '', false); + $this->_session = $this->getMock('Magento\Framework\Session\Generic', array('setData'), array(), '', false); + $this->_escaper = $this->getMock('\Magento\Framework\Escaper', array('escapeHtml'), array(), '', false); + + $this->_model = new \Magento\PageCache\Model\Observer\RegisterFormKeyFromCookie( + $this->_formKey, + $this->_session, + $this->_escaper + ); + } + + public function testExecute() + { + //Data + $formKey = '<asdfaswqrwqe12>'; + $escapedFormKey = 'asdfaswqrwqe12'; + + //Verification + $this->_formKey->expects($this->once()) + ->method('get') + ->will($this->returnValue($formKey)); + + $this->_escaper->expects($this->once()) + ->method('escapeHtml') + ->with($formKey) + ->will($this->returnValue($escapedFormKey)); + + $this->_session->expects($this->once()) + ->method('setData') + ->with(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $escapedFormKey); + + $this->_model->execute(); + } +} 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 d85615fdb7d9d9e930007268ae0f626e6c9742d3..4b067037cf5d867bf2db677a91c7d6d521cd4d6b 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php @@ -32,7 +32,7 @@ class FreeTest extends \PHPUnit_Framework_TestCase protected $scopeConfig; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $storeManager; + protected $currencyPrice; protected function setUp() { @@ -40,14 +40,14 @@ class FreeTest extends \PHPUnit_Framework_TestCase $paymentData = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); $logAdapterFactory = $this->getMock('Magento\Framework\Logger\AdapterFactory', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); + $this->currencyPrice = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $this->methodFree = new \Magento\Payment\Model\Method\Free( $eventManager, $paymentData, $this->scopeConfig, $logAdapterFactory, - $this->storeManager + $this->currencyPrice ); } @@ -89,14 +89,9 @@ class FreeTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($grandTotal)); } - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $store->expects($this->any()) - ->method('roundPrice') - ->will($this->returnArgument(0)); - - $this->storeManager->expects($this->any()) - ->method('getStore') - ->will($this->returnValue($store)); + $this->currencyPrice->expects($this->any()) + ->method('round') + ->willReturnArgument(0); $this->scopeConfig->expects($this->any()) ->method('getValue') diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/Observer/RestrictAdminBillingAgreementUsageTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/Observer/RestrictAdminBillingAgreementUsageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4935a81c6302fb6b3ce5cfcf0d3035d9a943b2c6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/Observer/RestrictAdminBillingAgreementUsageTest.php @@ -0,0 +1,112 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Paypal\Model\Observer; + +class RestrictAdminBillingAgreementUsageTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var RestrictAdminBillingAgreementUsage + */ + protected $_model; + + /** + * @var \Magento\Framework\Event\Observer + */ + protected $_observer; + + /** + * @var \Magento\Framework\Object + */ + protected $_event; + + /** + * @var \Magento\Framework\AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_authorization; + + protected function setUp() + { + $this->_event = new \Magento\Framework\Object(); + + $this->_observer = new \Magento\Framework\Event\Observer(); + $this->_observer->setEvent($this->_event); + + $this->_authorization = $this->getMockForAbstractClass('Magento\Framework\AuthorizationInterface'); + + $this->_model = new \Magento\Paypal\Model\Observer\RestrictAdminBillingAgreementUsage($this->_authorization); + } + + public function restrictAdminBillingAgreementUsageDataProvider() + { + return array( + array(new \stdClass(), false, true), + array( + $this->getMockForAbstractClass( + 'Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement', + array(), + '', + false + ), + true, + true + ), + array( + $this->getMockForAbstractClass( + 'Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement', + array(), + '', + false + ), + false, + false + ) + ); + } + + /** + * @param object $methodInstance + * @param bool $isAllowed + * @param bool $isAvailable + * @dataProvider restrictAdminBillingAgreementUsageDataProvider + */ + public function testExecute($methodInstance, $isAllowed, $isAvailable) + { + $this->_event->setMethodInstance($methodInstance); + $this->_authorization->expects( + $this->any() + )->method( + 'isAllowed' + )->with( + 'Magento_Paypal::use' + )->will( + $this->returnValue($isAllowed) + ); + $result = new \stdClass(); + $result->isAvailable = true; + $this->_event->setResult($result); + $this->_model->execute($this->_observer); + $this->assertEquals($isAvailable, $result->isAvailable); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php index af13ef68e42f7a4a6f6cbf6b4bd956da6d10b27b..4ebab2db2d6d5a3b1df5db695fbf2e21dd068576 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php @@ -133,58 +133,6 @@ class ObserverTest extends \PHPUnit_Framework_TestCase } } - /** - * @param object $methodInstance - * @param bool $isAllowed - * @param bool $isAvailable - * @dataProvider restrictAdminBillingAgreementUsageDataProvider - */ - public function testRestrictAdminBillingAgreementUsage($methodInstance, $isAllowed, $isAvailable) - { - $this->_event->setMethodInstance($methodInstance); - $this->_authorization->expects( - $this->any() - )->method( - 'isAllowed' - )->with( - 'Magento_Paypal::use' - )->will( - $this->returnValue($isAllowed) - ); - $result = new \stdClass(); - $result->isAvailable = true; - $this->_event->setResult($result); - $this->_model->restrictAdminBillingAgreementUsage($this->_observer); - $this->assertEquals($isAvailable, $result->isAvailable); - } - - public function restrictAdminBillingAgreementUsageDataProvider() - { - return array( - array(new \stdClass(), false, true), - array( - $this->getMockForAbstractClass( - 'Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement', - array(), - '', - false - ), - true, - true - ), - array( - $this->getMockForAbstractClass( - 'Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement', - array(), - '', - false - ), - false, - false - ) - ); - } - public function testAddBillingAgreementToSessionNoData() { $payment = $this->getMock('Magento\Sales\Model\Order\Payment', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ApplyBlockPersistentDataTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ApplyBlockPersistentDataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7d44fc7e3a947e2423298ff7909691f72d24f301 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ApplyBlockPersistentDataTest.php @@ -0,0 +1,180 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model\Observer; + +class ApplyBlockPersistentDataTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @var \Magento\Persistent\Model\Observer\ApplyBlockPersistentData + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $persistentHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $blockMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $persistentConfigMock; + + protected function setUp() + { + $eventMethods = ['getConfigFilePath', 'getBlock', '__wakeUp']; + $this->sessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->persistentHelperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->configMock = + $this->getMock('\Magento\Persistent\Model\Persistent\ConfigFactory', ['create'], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->eventMock = $this->getMock('Magento\Framework\Event', $eventMethods, [], '', false); + $this->blockMock = $this->getMock('Magento\Framework\View\Element\AbstractBlock', [], [], '', false); + $this->persistentConfigMock = $this->getMock('\Magento\Persistent\Model\Persistent\Config', [], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\ApplyBlockPersistentData( + $this->sessionMock, + $this->persistentHelperMock, + $this->customerSessionMock, + $this->configMock + ); + } + + public function testExecuteWhenSessionNotPersistent() + { + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false)); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteForLoggedInAndPersistentCustomer() + { + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenBlockDoesNotExist() + { + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getBlock')->will($this->returnValue(null)); + $this->eventMock->expects($this->never())->method('getConfigFilePath'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenConfigFilePathDoesNotExist() + { + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->observerMock + ->expects($this->any()) + ->method('getEvent') + ->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getBlock')->will($this->returnValue($this->blockMock)); + $this->eventMock->expects($this->once())->method('getConfigFilePath')->will($this->returnValue(false)); + $this->persistentHelperMock + ->expects($this->once()) + ->method('getPersistentConfigFilePath') + ->will($this->returnValue('path1/path2')); + $this->configMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->persistentConfigMock)); + $this->persistentConfigMock->expects($this->once())->method('setConfigFilePath')->with('path1/path2'); + $this->persistentConfigMock + ->expects($this->once()) + ->method('getBlockConfigInfo') + ->with(get_class($this->blockMock)) + ->will($this->returnValue(['persistentConfigInfo'])); + $this->persistentConfigMock + ->expects($this->once()) + ->method('fireOne') + ->with('persistentConfigInfo', $this->blockMock); + $this->model->execute($this->observerMock); + } + + public function testExecute() + { + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->observerMock + ->expects($this->any()) + ->method('getEvent') + ->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getBlock')->will($this->returnValue($this->blockMock)); + $this->eventMock->expects($this->once())->method('getConfigFilePath')->will($this->returnValue('path1/path2')); + $this->persistentHelperMock + ->expects($this->never()) + ->method('getPersistentConfigFilePath'); + $this->configMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->persistentConfigMock)); + $this->persistentConfigMock->expects($this->once())->method('setConfigFilePath')->with('path1/path2'); + $this->persistentConfigMock + ->expects($this->once()) + ->method('getBlockConfigInfo') + ->with(get_class($this->blockMock)) + ->will($this->returnValue(['persistentConfigInfo'])); + $this->persistentConfigMock + ->expects($this->once()) + ->method('fireOne') + ->with('persistentConfigInfo', $this->blockMock); + $this->model->execute($this->observerMock); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ApplyPersistentDataTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ApplyPersistentDataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..66a010f29bf2cce37034157065927241ff1586c5 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ApplyPersistentDataTest.php @@ -0,0 +1,142 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class ApplyPersistentDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\ApplyPersistentData + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $persistentHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $persistentConfigMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + protected function setUp() + { + $this->sessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->persistentHelperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->persistentConfigMock = $this->getMock('\Magento\Persistent\Model\Persistent\Config', [], [], '', false); + $this->configMock = + $this->getMock('\Magento\Persistent\Model\Persistent\ConfigFactory', ['create'], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\ApplyPersistentData( + $this->sessionMock, + $this->persistentHelperMock, + $this->customerSessionMock, + $this->configMock + ); + } + + public function testExecuteWhenCanNotApplyPersistentData() + { + $this->persistentHelperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(false)); + $this->configMock->expects($this->never())->method('create'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenCustomerIsNotPersistent() + { + $this->persistentHelperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false)); + $this->configMock->expects($this->never())->method('create'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenCustomerIsLoggedIn() + { + $this->persistentHelperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); + $this->configMock->expects($this->never())->method('create'); + $this->model->execute($this->observerMock); + } + + public function testExecute() + { + $this->persistentHelperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->configMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->persistentConfigMock)); + $this->persistentHelperMock + ->expects($this->once()) + ->method('getPersistentConfigFilePath') + ->will($this->returnValue('path/path1')); + $this->persistentConfigMock + ->expects($this->once()) + ->method('setConfigFilePath') + ->with('path/path1') + ->will($this->returnSelf()); + $this->persistentConfigMock->expects($this->once())->method('fire'); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/CheckExpirePersistentQuoteTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/CheckExpirePersistentQuoteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..202768f45e94b033899726daa2da234ad5409f3a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/CheckExpirePersistentQuoteTest.php @@ -0,0 +1,133 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class CheckExpirePersistentQuoteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\CheckExpirePersistentQuote + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $persistentHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + protected function setUp() + { + $this->sessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->persistentHelperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->observerMock + = $this->getMock('Magento\Framework\Event\Observer', ['getControllerAction', '__wakeUp'], [], '', false); + $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); + $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\CheckExpirePersistentQuote( + $this->sessionMock, + $this->persistentHelperMock, + $this->quoteManagerMock, + $this->eventManagerMock, + $this->customerSessionMock, + $this->checkoutSessionMock + ); + } + + public function testExecuteWhenCanNotApplyPersistentData() + { + $this->persistentHelperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(false)); + $this->persistentHelperMock->expects($this->never())->method('isEnabled'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenPersistentIsNotEnabled() + { + $this->persistentHelperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->persistentHelperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); + $this->eventManagerMock->expects($this->never())->method('dispatch'); + $this->model->execute($this->observerMock); + } + public function testExecuteWhenPersistentIsEnabled() + { + $this->persistentHelperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->persistentHelperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); + $this->sessionMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->checkoutSessionMock->expects($this->once())->method('getQuoteId')->will($this->returnValue(10)); + $this->observerMock->expects($this->once())->method('getControllerAction'); + $this->eventManagerMock->expects($this->once())->method('dispatch'); + $this->quoteManagerMock->expects($this->once())->method('expire'); + $this->customerSessionMock + ->expects($this->once()) + ->method('setCustomerId') + ->with(null) + ->will($this->returnSelf()); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ClearExpiredCronJobTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ClearExpiredCronJobTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5ba083e716564eba46b71662408d76d93bdddbbd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/ClearExpiredCronJobTest.php @@ -0,0 +1,104 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class ClearExpiredCronJobTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\ClearExpiredCronJob + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $collectionFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scheduleMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $websiteCollectionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + protected function setUp() + { + $this->collectionFactoryMock = + $this->getMock('Magento\Store\Model\Resource\Website\CollectionFactory', ['create']); + $this->sessionFactoryMock = $this->getMock('Magento\Persistent\Model\SessionFactory', ['create']); + $this->scheduleMock = $this->getMock('\Magento\Cron\Model\Schedule', [], [], '', false); + $this->sessionMock = $this->getMock('\Magento\Persistent\Model\Session', [], [], '', false); + $this->websiteCollectionMock + = $this->getMock('\Magento\Store\Model\Resource\Website\Collection', [], [], '', false); + + $this->model = new \Magento\Persistent\Model\Observer\ClearExpiredCronJob( + $this->collectionFactoryMock, + $this->sessionFactoryMock + ); + } + + public function testExecute() + { + $this->collectionFactoryMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->websiteCollectionMock)); + $this->websiteCollectionMock->expects($this->once())->method('getAllIds')->will($this->returnValue([1])); + $this->sessionFactoryMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->sessionMock)); + $this->sessionMock->expects($this->once())->method('deleteExpired')->with(1); + $this->model->execute($this->scheduleMock); + } + + public function testExecuteForNotExistingWebsite() + { + $this->collectionFactoryMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->websiteCollectionMock)); + $this->websiteCollectionMock->expects($this->once())->method('getAllIds'); + $this->sessionFactoryMock + ->expects($this->never()) + ->method('create'); + $this->model->execute($this->scheduleMock); + } + +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/CustomerAuthenticatedEventTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/CustomerAuthenticatedEventTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0dd92ebdea61ab7e6411a4b47b745dd8c78ab873 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/CustomerAuthenticatedEventTest.php @@ -0,0 +1,112 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class CustomerAuthenticatedEventTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\CustomerAuthenticatedEvent + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + + protected function setUp() + { + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); + $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->model = new \Magento\Persistent\Model\Observer\CustomerAuthenticatedEvent( + $this->customerSessionMock, + $this->requestMock, + $this->quoteManagerMock + ); + } + + public function testExecute() + { + $this->customerSessionMock + ->expects($this->once()) + ->method('setCustomerId') + ->with(null) + ->will($this->returnSelf()); + $this->customerSessionMock + ->expects($this->once()) + ->method('setCustomerGroupId') + ->with(null) + ->will($this->returnSelf()); + $this->requestMock + ->expects($this->once()) + ->method('getParam') + ->with('context') + ->will($this->returnValue('not_checkout')); + $this->quoteManagerMock->expects($this->once())->method('expire'); + $this->quoteManagerMock->expects($this->never())->method('setGuest'); + $this->model->execute($this->observerMock); + } + + public function testExecuteDuringCheckout() + { + $this->customerSessionMock + ->expects($this->once()) + ->method('setCustomerId') + ->with(null) + ->will($this->returnSelf()); + $this->customerSessionMock + ->expects($this->once()) + ->method('setCustomerGroupId') + ->with(null) + ->will($this->returnSelf()); + $this->requestMock + ->expects($this->once()) + ->method('getParam') + ->with('context') + ->will($this->returnValue('checkout')); + $this->quoteManagerMock->expects($this->never())->method('expire'); + $this->quoteManagerMock->expects($this->once())->method('setGuest'); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/DisableGuestCheckoutTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/DisableGuestCheckoutTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b742d85d02e1958c8777cc57b3b023e1349a7cfa --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/DisableGuestCheckoutTest.php @@ -0,0 +1,80 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class DisableGuestCheckoutTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\DisableGuestCheckout + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + protected function setUp() + { + $this->eventManagerMock = + $this->getMock('Magento\Framework\Event\ManagerInterface', ['getResult', 'dispatch', '__wakeUp']); + $this->sessionHelperMock = $this->getMock('\Magento\Persistent\Helper\Session', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\DisableGuestCheckout( + $this->sessionHelperMock + ); + } + + public function testExecuteWithNotPersistentSession() + { + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false)); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWithPersistentSession() + { + $resultMock = $this->getMock('Magento\Framework\Object', ['setIsAllowed', '__wakeUp'], [], '', false); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock->expects($this->once())->method('getResult')->will($this->returnValue($resultMock)); + $resultMock->expects($this->once())->method('setIsAllowed')->with(false); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/EmulateCustomerTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/EmulateCustomerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..988c5269fc0a1738004aabc7426856c1e1779987 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/EmulateCustomerTest.php @@ -0,0 +1,147 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class EmulateCustomerTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @var \Magento\Persistent\Model\Observer\EmulateCustomer + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerAccountMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + protected function setUp() + { + $this->customerAccountMock = $this->getMock('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\EmulateCustomer( + $this->sessionHelperMock, + $this->helperMock, + $this->customerSessionMock, + $this->customerAccountMock + ); + } + + public function testExecuteWhenCannotProcessPersistentData() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(false)); + $this->helperMock->expects($this->never())->method('isShoppingCartPersist'); + $this->sessionHelperMock->expects($this->never())->method('isPersistent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenShoppingCartNotPersist() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(false)); + $this->sessionHelperMock->expects($this->never())->method('isPersistent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenSessionPersistAndCustomerNotLoggedIn() + { + $customerId = 1; + $customerGroupId = 2; + $sessionMock = $this->getMock('Magento\Persistent\Model\Session', ['getCustomerId', '__wakeUp'], [], '', false); + $customerMock = $this->getMock('\Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->sessionHelperMock->expects($this->once())->method('getSession')->will($this->returnValue($sessionMock)); + $sessionMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId)); + $this->customerAccountMock + ->expects($this->once()) + ->method('getCustomer') + ->with(1) + ->will($this->returnValue($customerMock)); + $customerMock->expects($this->once())->method('getId')->will($this->returnValue($customerId)); + $customerMock->expects($this->once())->method('getGroupId')->will($this->returnValue($customerGroupId)); + $this->customerSessionMock + ->expects($this->once()) + ->method('setCustomerId') + ->with($customerId) + ->will($this->returnSelf()); + $this->customerSessionMock->expects($this->once())->method('setCustomerGroupId')->with($customerGroupId); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenSessionNotPersist() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); + $this->customerAccountMock + ->expects($this->never()) + ->method('getCustomer'); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/EmulateQuoteTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/EmulateQuoteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..27165b4af19f16185089e823c82b485e74ad9023 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/EmulateQuoteTest.php @@ -0,0 +1,259 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class EmulateQuoteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\EmulateQuote + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerAccountMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + protected function setUp() + { + $eventMethods = ['getRequest', 'dispatch', '__wakeUp']; + $this->customerAccountMock = $this->getMock('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->checkoutSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); + $this->eventMock = $this->getMock('Magento\Framework\Event', $eventMethods, [], '', false); + $this->requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); + $this->customerMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $this->sessionMock = + $this->getMock('\Magento\Persistent\Model\Session', ['getCustomerId', '__wakeUp'], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\EmulateQuote( + $this->sessionHelperMock, + $this->helperMock, + $this->checkoutSessionMock, + $this->customerSessionMock, + $this->customerAccountMock + ); + } + + public function testExecuteWhenCannotProcess() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(false)); + $this->sessionHelperMock->expects($this->never())->method('isPersistent'); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenSessionIsNotPersistent() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false)); + $this->checkoutSessionMock->expects($this->never())->method('isLoggedIn'); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenCustomerLoggedIn() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenActionIsStop() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock)); + $this->requestMock + ->expects($this->once()) + ->method('getFullActionName') + ->will($this->returnValue('persistent_index_saveMethod')); + $this->helperMock->expects($this->never())->method('isShoppingCartPersist'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenShoppingCartIsPersistent() + { + $customerId = 1; + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock)); + $this->requestMock + ->expects($this->once()) + ->method('getFullActionName') + ->will($this->returnValue('method_name')); + $this->helperMock + ->expects($this->once()) + ->method('isShoppingCartPersist') + ->will($this->returnValue(true)); + $this->sessionHelperMock + ->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->sessionMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId)); + $this->customerAccountMock + ->expects($this->once()) + ->method('getCustomer') + ->with($customerId) + ->will($this->returnValue($this->customerMock)); + $this->checkoutSessionMock->expects($this->once())->method('hasQuote')->will($this->returnValue(false)); + $this->checkoutSessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); + $this->checkoutSessionMock->expects($this->once())->method('setCustomerData')->with($this->customerMock); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenShoppingCartIsNotPersistent() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock)); + $this->requestMock + ->expects($this->once()) + ->method('getFullActionName') + ->will($this->returnValue('method_name')); + $this->helperMock + ->expects($this->once()) + ->method('isShoppingCartPersist') + ->will($this->returnValue(false)); + $this->checkoutSessionMock->expects($this->never())->method('setCustomerData'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenShoppingCartIsPersistentAndQuoteExist() + { + $customerId = 1; + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock)); + $this->requestMock + ->expects($this->once()) + ->method('getFullActionName') + ->will($this->returnValue('method_name')); + $this->helperMock + ->expects($this->once()) + ->method('isShoppingCartPersist') + ->will($this->returnValue(true)); + $this->sessionHelperMock + ->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->sessionMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId)); + $this->customerAccountMock + ->expects($this->once()) + ->method('getCustomer') + ->with($customerId) + ->will($this->returnValue($this->customerMock)); + $this->checkoutSessionMock->expects($this->once())->method('hasQuote')->will($this->returnValue(true)); + $this->checkoutSessionMock->expects($this->once())->method('setCustomerData')->with($this->customerMock); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/MakePersistentQuoteGuestTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/MakePersistentQuoteGuestTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c08acde5c22c971e879540613f4ae45cc550df35 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/MakePersistentQuoteGuestTest.php @@ -0,0 +1,130 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class MakePersistentQuoteGuestTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\MakePersistentQuoteGuest + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionMock; + + protected function setUp() + { + $this->actionMock = $this->getMock('Magento\Persistent\Controller\Index', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); + $this->eventManagerMock = + $this->getMock('Magento\Framework\Event', ['getControllerAction', '__wakeUp'], [], '', false); + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->model = new \Magento\Persistent\Model\Observer\MakePersistentQuoteGuest( + $this->sessionHelperMock, + $this->helperMock, + $this->customerSessionMock, + $this->quoteManagerMock + ); + } + + public function testExecute() + { + $this->eventManagerMock + ->expects($this->once()) + ->method('getControllerAction') + ->will($this->returnValue($this->actionMock)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->helperMock->expects($this->never())->method('isShoppingCartPersist'); + $this->quoteManagerMock->expects($this->once())->method('setGuest')->with(true); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenShoppingCartIsPersist() + { + $this->eventManagerMock + ->expects($this->once()) + ->method('getControllerAction') + ->will($this->returnValue($this->actionMock)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(true)); + $this->quoteManagerMock->expects($this->once())->method('setGuest')->with(true); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenShoppingCartIsNotPersist() + { + $this->eventManagerMock + ->expects($this->once()) + ->method('getControllerAction') + ->will($this->returnValue($this->actionMock)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(false)); + $this->quoteManagerMock->expects($this->never())->method('setGuest'); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/PreventClearCheckoutSessionTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/PreventClearCheckoutSessionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..061b324a620146bb9d8b3c9abfd036121c9d1fb0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/PreventClearCheckoutSessionTest.php @@ -0,0 +1,123 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class PreventClearCheckoutSessionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\PreventClearCheckoutSession + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerMock; + + protected function setUp() + { + $eventMethods = ['getControllerAction', 'dispatch', '__wakeUp']; + $this->customerAccountMock = $this->getMock('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->eventMock = $this->getMock('Magento\Framework\Event', $eventMethods, [], '', false); + $this->actionMock = $this->getMock('Magento\Persistent\Controller\Index', [], [], '', false); + $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->model = new \Magento\Persistent\Model\Observer\PreventClearCheckoutSession( + $this->sessionHelperMock, + $this->helperMock, + $this->customerSessionMock + ); + } + + public function testExecuteWhenSessionIsPersist() + { + $this->eventMock + ->expects($this->once()) + ->method('getControllerAction') + ->will($this->returnValue($this->actionMock)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->helperMock->expects($this->never())->method('isShoppingCartPersist'); + $this->actionMock->expects($this->once())->method('setClearCheckoutSession')->with(false); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenShoppingCartIsPersist() + { + $this->eventMock + ->expects($this->once()) + ->method('getControllerAction') + ->will($this->returnValue($this->actionMock)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(false)); + $this->actionMock->expects($this->once())->method('setClearCheckoutSession')->with(false); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenActionIsNotPersistent() + { + $this->eventMock + ->expects($this->once()) + ->method('getControllerAction'); + $this->sessionHelperMock->expects($this->never())->method('isPersistent'); + $this->actionMock->expects($this->never())->method('setClearCheckoutSession'); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/PreventExpressCheckoutTest.php similarity index 91% rename from dev/tests/unit/testsuite/Magento/Persistent/Model/ObserverTest.php rename to dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/PreventExpressCheckoutTest.php index 32d57115ac44297f7a2e869169564cf4ed43de4d..1c84c33c4ff3f0785d911608e2e08da9e5c31ce9 100644 --- a/dev/tests/unit/testsuite/Magento/Persistent/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/PreventExpressCheckoutTest.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Persistent\Model; +namespace Magento\Persistent\Model\Observer; -class ObserverTest extends \PHPUnit_Framework_TestCase +class PreventExpressCheckoutTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Persistent\Model\Observer + * @var \Magento\Persistent\Model\Observer\PreventExpressCheckout */ protected $_model; @@ -111,7 +111,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase )->getMock(); $this->_model = $helper->getObject( - 'Magento\Persistent\Model\Observer', + 'Magento\Persistent\Model\Observer\PreventExpressCheckout', array( 'customerSession' => $this->_customerSession, 'persistentSession' => $this->_persistentSession, @@ -126,7 +126,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase { $this->_customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); $this->_persistentSession->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); - $this->_model->preventExpressCheckout($this->_observer); + $this->_model->execute($this->_observer); } public function testPreventExpressCheckoutEmpty() @@ -135,10 +135,10 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->_persistentSession->expects($this->any())->method('isPersistent')->will($this->returnValue(true)); $this->_event->setControllerAction(null); - $this->_model->preventExpressCheckout($this->_observer); + $this->_model->execute($this->_observer); $this->_event->setControllerAction(new \StdClass()); - $this->_model->preventExpressCheckout($this->_observer); + $this->_model->execute($this->_observer); $expectedActionName = 'realAction'; $unexpectedActionName = 'notAction'; @@ -165,7 +165,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->returnValue($expectedActionName) ); $this->_event->setControllerAction($expressRedirectMock); - $this->_model->preventExpressCheckout($this->_observer); + $this->_model->execute($this->_observer); $expectedAuthUrl = 'expectedAuthUrl'; $request->setActionName($expectedActionName); @@ -178,6 +178,6 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $expressRedirectMock, $expectedAuthUrl ); - $this->_model->preventExpressCheckout($this->_observer); + $this->_model->execute($this->_observer); } } diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SessionTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SessionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a930be9c1647999fb300c76d7189d59d7b0deaba --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SessionTest.php @@ -0,0 +1,316 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class SessionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\Session + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + protected function setUp() + { + $this->requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); + $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $checkoutMethods = ['setRememberMeChecked', '__wakeUp']; + $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', $checkoutMethods, [], '', false); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->sessionFactoryMock = + $this->getMock('Magento\Persistent\Model\SessionFactory', ['create'], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $eventMethods = ['getRequest', '__wakeUp']; + $this->eventManagerMock = $this->getMock('\Magento\Framework\Event', $eventMethods, [], '', false); + $this->customerMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $this->sessionMock = $this->getMock('Magento\Persistent\Model\Session', [], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\Session( + $this->helperMock, + $this->sessionHelperMock, + $this->checkoutSessionMock, + $this->customerSessionMock, + $this->sessionFactoryMock + ); + } + + public function testSynchronizePersistentOnLogoutWhenPersistentDataNotEnabled() + { + $this->helperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); + $this->sessionFactoryMock->expects($this->never())->method('create'); + $this->model->synchronizePersistentOnLogout($this->observerMock); + } + + public function testSynchronizePersistentOnLogoutWhenPersistentDataIsEnabled() + { + $this->helperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('getClearOnLogout')->will($this->returnValue(true)); + $this->sessionFactoryMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->sessionMock)); + $this->sessionMock->expects($this->once())->method('removePersistentCookie'); + $this->sessionHelperMock->expects($this->once())->method('setSession')->with(null); + $this->model->synchronizePersistentOnLogout($this->observerMock); + } + + public function testSynchronizePersistentInfoWhenPersistentDataNotEnabled() + { + $this->helperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); + $this->sessionHelperMock->expects($this->never())->method('getSession'); + $this->model->synchronizePersistentInfo($this->observerMock); + } + + public function testSynchronizePersistentInfoWhenPersistentDataIsEnabled() + { + $this->helperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->sessionHelperMock + ->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock + ->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->requestMock->expects($this->once())->method('getActionName')->will($this->returnValue('logout')); + $this->requestMock->expects($this->once())->method('getControllerName')->will($this->returnValue('account')); + $this->sessionMock->expects($this->once())->method('save'); + $this->model->synchronizePersistentInfo($this->observerMock); + } + + public function testSetRememberMeCheckedStatusWhenPersistentDataCannotProcess() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(false)); + $this->helperMock->expects($this->never())->method('isEnabled'); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->setRememberMeCheckedStatus($this->observerMock); + } + + public function testSetRememberMeCheckedStatusWhenPersistentDataCanProcess() + { + $rememberMeCheckbox = 1; + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isRememberMeEnabled')->will($this->returnValue(true)); + + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock + ->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->requestMock + ->expects($this->once()) + ->method('getPost') + ->with('persistent_remember_me') + ->will($this->returnValue($rememberMeCheckbox)); + $this->sessionHelperMock + ->expects($this->once()) + ->method('setRememberMeChecked') + ->with((bool)$rememberMeCheckbox); + $this->requestMock + ->expects($this->once()) + ->method('getFullActionName') + ->will($this->returnValue('checkout_onepage_saveBilling')); + $this->checkoutSessionMock + ->expects($this->once()) + ->method('setRememberMeChecked') + ->with((bool)$rememberMeCheckbox); + $this->model->setRememberMeCheckedStatus($this->observerMock); + } + + public function testSetRememberMeCheckedStatusWhenActionNameIncorrect() + { + $rememberMeCheckbox = 1; + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isRememberMeEnabled')->will($this->returnValue(true)); + + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock + ->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->requestMock + ->expects($this->once()) + ->method('getPost') + ->with('persistent_remember_me') + ->will($this->returnValue($rememberMeCheckbox)); + $this->sessionHelperMock + ->expects($this->once()) + ->method('setRememberMeChecked') + ->with((bool)$rememberMeCheckbox); + $this->requestMock + ->expects($this->exactly(2)) + ->method('getFullActionName') + ->will($this->returnValue('method_name')); + $this->checkoutSessionMock + ->expects($this->never()) + ->method('setRememberMeChecked'); + $this->model->setRememberMeCheckedStatus($this->observerMock); + } + + public function testSetRememberMeCheckedStatusWhenRequestNotExist() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isRememberMeEnabled')->will($this->returnValue(true)); + + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock + ->expects($this->once()) + ->method('getRequest'); + $this->model->setRememberMeCheckedStatus($this->observerMock); + } + + public function testRenewCookie() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(true)); + $this->helperMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock + ->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->requestMock + ->expects($this->once()) + ->method('getFullActionName') + ->will($this->returnValue('customer_account_logout')); + $this->helperMock->expects($this->once())->method('getLifeTime')->will($this->returnValue(60)); + $this->customerSessionMock + ->expects($this->once())->method('getCookiePath')->will($this->returnValue('path/cookie')); + $this->sessionFactoryMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->sessionMock)); + $this->sessionMock->expects($this->once())->method('renewPersistentCookie')->with(60, 'path/cookie'); + $this->model->renewCookie($this->observerMock); + } + + public function testRenewCookieWhenCannotProcessPersistentData() + { + $this->helperMock + ->expects($this->once()) + ->method('canProcess') + ->with($this->observerMock) + ->will($this->returnValue(false)); + $this->helperMock->expects($this->never())->method('isEnabled'); + + $this->observerMock + ->expects($this->never()) + ->method('getEvent'); + + $this->model->renewCookie($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SetLoadPersistentQuoteTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SetLoadPersistentQuoteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b7b89986141bb854c5a7e29886b9192bae386211 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SetLoadPersistentQuoteTest.php @@ -0,0 +1,91 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class SetLoadPersistentQuoteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\SetLoadPersistentQuote + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + protected function setUp() + { + $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + + $this->model = new \Magento\Persistent\Model\Observer\SetLoadPersistentQuote( + $this->sessionHelperMock, + $this->helperMock, + $this->customerSessionMock, + $this->checkoutSessionMock + ); + } + + public function testExecuteWhenSessionIsNotPersistent() + { + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false)); + $this->checkoutSessionMock->expects($this->never())->method('setLoadInactive'); + $this->model->execute($this->observerMock); + } + + public function testExecute() + { + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(true)); + $this->checkoutSessionMock->expects($this->never())->method('setLoadInactive'); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SetQuotePersistentDataTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SetQuotePersistentDataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d05d0c8d5a1e3129890d24d3af4c06ccf11b5a9a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/SetQuotePersistentDataTest.php @@ -0,0 +1,127 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + + +class SetQuotePersistentDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\SetQuotePersistentData + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + + protected function setUp() + { + $quoteMethods = ['setIsActive', 'setIsPersistent', '__wakeUp']; + $eventMethods = ['getQuote', '__wakeUp']; + $this->quoteMock = $this->getMock('Magento\Sales\Model\Quote', $quoteMethods, [], '', false); + $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->eventManagerMock = $this->getMock('\Magento\Framework\Event', $eventMethods, [], '', false); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\SetQuotePersistentData( + $this->sessionHelperMock, + $this->helperMock, + $this->quoteManagerMock, + $this->customerSessionMock + ); + } + + public function testExecuteWhenSessionIsNotPersistent() + { + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false)); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenQuoteNotExist() + { + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock->expects($this->once())->method('getQuote'); + $this->customerSessionMock->expects($this->never())->method('isLoggedIn'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenSessionIsPersistent() + { + $this->sessionHelperMock->expects($this->exactly(2))->method('isPersistent')->will($this->returnValue(true)); + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock + ->expects($this->once()) + ->method('getQuote') + ->will($this->returnValue($this->quoteMock)); + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); + $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(false)); + $this->quoteManagerMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->quoteMock->expects($this->once())->method('setIsActive')->with(false)->will($this->returnSelf()); + $this->quoteMock->expects($this->once())->method('setIsPersistent')->with(true); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/UpdateCustomerCookiesTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/UpdateCustomerCookiesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9ceaf4225b5627ff23aff4ff329281dcbc9e0a90 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/Observer/UpdateCustomerCookiesTest.php @@ -0,0 +1,124 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model\Observer; + +class UpdateCustomerCookiesTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer\UpdateCustomerCookies + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $accountServiceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerMock; + + protected function setUp() + { + $eventMethods = ['getCustomerCookies', '__wakeUp']; + $sessionMethods = ['getId', 'getGroupId', 'getCustomerId', '__wakeUp']; + $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->accountServiceMock = $this->getMock('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->eventManagerMock = $this->getMock('\Magento\Framework\Event', $eventMethods, [], '', false); + $this->sessionMock = $this->getMock('Magento\Persistent\Model\Session', $sessionMethods, [], '', false); + $this->customerMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $this->model = new \Magento\Persistent\Model\Observer\UpdateCustomerCookies( + $this->sessionHelperMock, + $this->accountServiceMock + ); + } + + public function testExecuteWhenSessionNotPersistent() + { + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false)); + $this->observerMock->expects($this->never())->method('getEvent'); + $this->model->execute($this->observerMock); + } + + public function testExecuteWhenCustomerCookieExist() + { + $customerId = 1; + $customerGroupId = 2; + $cookieMock = + $this->getMock('Magento\Framework\Object', + ['setCustomerId', 'setCustomerGroupId', '__wakeUp'], + [], '', false); + $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); + $this->observerMock + ->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventManagerMock)); + $this->eventManagerMock + ->expects($this->once()) + ->method('getCustomerCookies') + ->will($this->returnValue($cookieMock)); + $this->sessionHelperMock + ->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->sessionMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId)); + $this->accountServiceMock + ->expects($this->once()) + ->method('getCustomer') + ->will($this->returnValue($this->customerMock)); + $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue($customerId)); + $this->customerMock->expects($this->once())->method('getGroupId')->will($this->returnValue($customerGroupId)); + $cookieMock->expects($this->once())->method('setCustomerId')->with($customerId)->will($this->returnSelf()); + $cookieMock + ->expects($this->once()) + ->method('setCustomerGroupId') + ->with($customerGroupId) + ->will($this->returnSelf()); + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/AddFormExcludedAttributeTest.php b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/AddFormExcludedAttributeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3af846ceb3f5eb699cb560ca2c8a6c36784dd842 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/AddFormExcludedAttributeTest.php @@ -0,0 +1,82 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\RecurringPayment\Model\Observer; + +class AddFormExcludedAttributeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Event\Observer + */ + protected $_observer; + + /** + * @var \Magento\RecurringPayment\Model\Observer\AddFormExcludedAttribute + */ + protected $_testModel; + + + /** + * @var \Magento\Framework\Event + */ + protected $_event; + + /** + * @var \Magento\RecurringPayment\Model\Payment + */ + protected $_payment; + + protected function setUp() + { + $this->_observer = $this->getMock('Magento\Framework\Event\Observer', array(), array(), '', false); + + $this->_testModel = new \Magento\RecurringPayment\Model\Observer\AddFormExcludedAttribute(); + + $this->_event = $this->getMock( + 'Magento\Framework\Event', + array('getProductElement', 'getProduct', 'getResult', 'getBuyRequest', 'getQuote', 'getApi', 'getObject'), + array(), + '', + false + ); + + $this->_observer->expects($this->any())->method('getEvent')->will($this->returnValue($this->_event)); + } + + public function testExecute() + { + $block = $this->getMock( + 'Magento\Backend\Block\Template', + array('getFormExcludedFieldList', 'setFormExcludedFieldList'), + array(), + '', + false + ); + $block->expects($this->once())->method('getFormExcludedFieldList')->will($this->returnValue(array('field'))); + $block->expects($this->once())->method('setFormExcludedFieldList')->with(array('field', 'recurring_payment')); + + $this->_event->expects($this->once())->method('getObject')->will($this->returnValue($block)); + $this->_testModel->execute($this->_observer); + } +} diff --git a/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/PrepareProductRecurringPaymentOptionsTest.php similarity index 76% rename from dev/tests/unit/testsuite/Magento/RecurringPayment/Model/ObserverTest.php rename to dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/PrepareProductRecurringPaymentOptionsTest.php index 84083ba40c36472336562f630ab8ee862b00ac4d..199efb4f8c3a66190aaa4c9fa4bbe174301f47b4 100644 --- a/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/PrepareProductRecurringPaymentOptionsTest.php @@ -1,5 +1,6 @@ <?php /** + * * Magento * * NOTICE OF LICENSE @@ -18,12 +19,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\RecurringPayment\Model; +namespace Magento\RecurringPayment\Model\Observer; -class ObserverTest extends \PHPUnit_Framework_TestCase +class PrepareProductRecurringPaymentOptionsTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Framework\Event\Observer @@ -31,7 +32,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase protected $_observer; /** - * @var \Magento\RecurringPayment\Model\Observer + * @var \Magento\RecurringPayment\Model\Observer\PrepareProductRecurringPaymentOptions */ protected $_testModel; @@ -88,7 +89,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_testModel = $helper->getObject( - 'Magento\RecurringPayment\Model\Observer', + 'Magento\RecurringPayment\Model\Observer\PrepareProductRecurringPaymentOptions', array( 'recurringPaymentFactory' => $this->_recurringPaymentFactory, 'fields' => $this->_fieldsBlock, @@ -123,7 +124,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase ); } - public function testPrepareProductRecurringPaymentOptions() + public function testExecute() { $payment = $this->getMock( 'Magento\Framework\Object', @@ -145,12 +146,12 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $payment->expects( $this->once() )->method( - 'exportScheduleInfo' - )->will( - $this->returnValue( - array(new \Magento\Framework\Object(array('title' => 'Title', 'schedule' => 'schedule'))) - ) - ); + 'exportScheduleInfo' + )->will( + $this->returnValue( + array(new \Magento\Framework\Object(array('title' => 'Title', 'schedule' => 'schedule'))) + ) + ); $this->_fieldsBlock->expects($this->once())->method('getFieldLabel')->will($this->returnValue('Field Label')); @@ -173,30 +174,14 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $product->expects( $this->at(2) )->method( - 'addCustomOption' - )->with( - 'additional_options', - serialize($infoOptions) - ); + 'addCustomOption' + )->with( + 'additional_options', + serialize($infoOptions) + ); $this->_event->expects($this->any())->method('getProduct')->will($this->returnValue($product)); - $this->_testModel->prepareProductRecurringPaymentOptions($this->_observer); - } - - public function testAddFormExcludedAttribute() - { - $block = $this->getMock( - 'Magento\Backend\Block\Template', - array('getFormExcludedFieldList', 'setFormExcludedFieldList'), - array(), - '', - false - ); - $block->expects($this->once())->method('getFormExcludedFieldList')->will($this->returnValue(array('field'))); - $block->expects($this->once())->method('setFormExcludedFieldList')->with(array('field', 'recurring_payment')); - - $this->_event->expects($this->once())->method('getObject')->will($this->returnValue($block)); - $this->_testModel->addFormExcludedAttribute($this->_observer); + $this->_testModel->execute($this->_observer); } } diff --git a/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/SetFormRecurringElementRendererTest.php b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/SetFormRecurringElementRendererTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d5b78fc7336b87603d0c1e39d34dff1231e5c8e1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/SetFormRecurringElementRendererTest.php @@ -0,0 +1,121 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\RecurringPayment\Model\Observer; + +class SetFormRecurringElementRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var SetFormRecurringElementRenderer + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $formMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $elementFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutInterfaceElementMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $recurringPaymentBlockMock; + + protected function setUp() + { + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->eventMock = + $this->getMock('Magento\Framework\Event', ['getForm', 'getLayout', '__wakeup'], [], '', false); + $this->elementFactoryMock = + $this->getMock('Magento\Framework\Data\Form\Element\Factory', ['setRenderer', '__wakeup'], [], '', false); + $this->formMock = $this->getMock('Magento\Framework\Data\Form', ['getElement', '__wakeup'], [], '', false); + $this->layoutInterfaceElementMock = $this->getMock('Magento\Framework\View\LayoutInterface'); + $this->recurringPaymentBlockMock = + $this->getMock( + 'Magento\RecurringPayment\Block\Adminhtml\Product\Edit\Tab\Price\Recurring', + [], + [], + '', + false); + + $this->model = new SetFormRecurringElementRenderer(); + } + + public function testExecuteWithoutRecurringPaymentElement() + { + $this->observerMock->expects($this->exactly(2))->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getForm')->will($this->returnValue($this->formMock)); + $this->formMock->expects($this->once()) + ->method('getElement')->with('recurring_payment')->will($this->returnValue(null)); + $this->eventMock->expects($this->once())->method('getLayout') + ->will($this->returnValue($this->layoutInterfaceElementMock)); + $this->layoutInterfaceElementMock->expects($this->once()) + ->method('createBlock') + ->with('Magento\RecurringPayment\Block\Adminhtml\Product\Edit\Tab\Price\Recurring') + ->will($this->returnValue($this->recurringPaymentBlockMock)); + $this->elementFactoryMock->expects($this->never())->method('setRenderer'); + + $this->model->execute($this->observerMock); + } + + public function testExecute() + { + $this->observerMock->expects($this->exactly(2))->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once())->method('getForm')->will($this->returnValue($this->formMock)); + $this->formMock->expects($this->once()) + ->method('getElement') + ->with('recurring_payment') + ->will($this->returnValue($this->elementFactoryMock)); + $this->eventMock->expects($this->once()) + ->method('getLayout')->will($this->returnValue($this->layoutInterfaceElementMock)); + $this->layoutInterfaceElementMock->expects($this->once()) + ->method('createBlock') + ->with('Magento\RecurringPayment\Block\Adminhtml\Product\Edit\Tab\Price\Recurring') + ->will($this->returnValue($this->recurringPaymentBlockMock)); + $this->elementFactoryMock->expects($this->once()) + ->method('setRenderer')->with($this->recurringPaymentBlockMock); + + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/SetIsRecurringToQuoteTest.php b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/SetIsRecurringToQuoteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d61651b891cb378a7683f461869434c8746f26a4 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/SetIsRecurringToQuoteTest.php @@ -0,0 +1,80 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\RecurringPayment\Model\Observer; + +class SetIsRecurringToQuoteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var SetIsRecurringToQuote + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteItemMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventMock; + + protected function setUp() + { + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->quoteItemMock = + $this->getMock('Magento\Sales\Model\Quote\Item', ['setIsRecurring', '__wakeup'], [], '', false); + $this->eventMock = + $this->getMock('Magento\Framework\Event', ['getQuoteItem', 'getProduct', '__wakeup'], [], '', false); + $this->productMock = + $this->getMock('Magento\Catalog\Model\Product', ['getIsRecurring', '__wakeup'], [], '', false); + + $this->model = new SetIsRecurringToQuote(); + } + + public function testExecute() + { + $this->observerMock->expects($this->exactly(2)) + ->method('getEvent')->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once()) + ->method('getQuoteItem')->will($this->returnValue($this->quoteItemMock)); + $this->eventMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock)); + $this->productMock->expects($this->once())->method('getIsRecurring')->will($this->returnValue(true)); + $this->quoteItemMock->expects($this->once())->method('setIsRecurring')->with(true); + + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/UnserializeProductRecurringPaymentTest.php b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/UnserializeProductRecurringPaymentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..dbc0617784e5d7cc1ae2115245a6cb98d64f1e5d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Observer/UnserializeProductRecurringPaymentTest.php @@ -0,0 +1,140 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\RecurringPayment\Model\Observer; + +class UnserializeProductRecurringPaymentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var UnserializeProductRecurringPayment + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $collectionMock; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->eventMock = $this->getMock('Magento\Framework\Event', ['getCollection', '__wakeup'], [], '', false); + $this->productMock = $this->getMock( + 'Magento\Catalog\Model\Resource\Product', + [ + 'getIsRecurring', + 'getRecurringPayment', + 'setRecurringPayment', + '__wakeup', + '__sleep' + ], + [], + '', + false); + $this->collectionMock = $objectManager->getCollectionMock( + 'Magento\Catalog\Model\Resource\Product\Collection', + [$this->productMock]); + + $this->model = new UnserializeProductRecurringPayment(); + } + + public function testExecute() + { + $payment = new \stdClass(); + $this->observerMock->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once()) + ->method('getCollection')->will($this->returnValue($this->collectionMock)); + $this->productMock + ->expects($this->once()) + ->method('getIsRecurring') + ->will($this->returnValue(true)); + $this->productMock->expects($this->once()) + ->method('getRecurringPayment') + ->will($this->returnValue(serialize($payment))); + $this->productMock->expects($this->once()) + ->method('setRecurringPayment')->with($payment); + + $this->model->execute($this->observerMock); + } + + public function testExecuteWithoutRecurring() + { + $payment = new \stdClass(); + $this->observerMock->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once()) + ->method('getCollection')->will($this->returnValue($this->collectionMock)); + $this->productMock + ->expects($this->once()) + ->method('getIsRecurring') + ->will($this->returnValue(false)); + $this->productMock->expects($this->once()) + ->method('getRecurringPayment') + ->will($this->returnValue(serialize($payment))); + $this->productMock->expects($this->never()) + ->method('setRecurringPayment'); + + $this->model->execute($this->observerMock); + } + + public function testExecuteWithoutPayment() + { + $this->observerMock->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($this->eventMock)); + $this->eventMock->expects($this->once()) + ->method('getCollection')->will($this->returnValue($this->collectionMock)); + $this->productMock + ->expects($this->once()) + ->method('getIsRecurring') + ->will($this->returnValue(true)); + $this->productMock->expects($this->once()) + ->method('getRecurringPayment') + ->will($this->returnValue(null)); + $this->productMock->expects($this->never()) + ->method('setRecurringPayment'); + + $this->model->execute($this->observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php index 89b00655ed2927d5051c195eedb77ad5b63b335b..d383b8894f24675560ee8d1aac322acd3ee74ace 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php @@ -51,6 +51,11 @@ class GridTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Quote\Item */ protected $itemMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + /** * Initialize required data */ @@ -58,6 +63,7 @@ class GridTest extends \PHPUnit_Framework_TestCase { $orderCreateMock = $this->getMock('Magento\Sales\Model\AdminOrder\Create', ['__wakeup'], [], '', false); $taxData = $this->getMockBuilder('Magento\Tax\Helper\Data')->disableOriginalConstructor()->getMock(); + $this->priceCurrency = $this->getMockBuilder('\Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $coreData = $this->getMockBuilder('Magento\Core\Helper\Data')->disableOriginalConstructor()->getMock(); $sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') ->disableOriginalConstructor() @@ -71,9 +77,11 @@ class GridTest extends \PHPUnit_Framework_TestCase $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') ->disableOriginalConstructor() - ->setMethods(array('__wakeup', 'convertPrice')) + ->setMethods(array('__wakeup')) ->getMock(); - $storeMock->expects($this->any())->method('convertPrice')->will($this->returnArgument(0)); + $this->priceCurrency->expects($this->any()) + ->method('convertAndFormat') + ->will($this->returnArgument(0)); $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); $sessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); $wishlistFactoryMock = $this->getMockBuilder('Magento\Wishlist\Model\WishlistFactory') @@ -104,6 +112,7 @@ class GridTest extends \PHPUnit_Framework_TestCase 'taxData' => $taxData, 'sessionQuote' => $sessionMock, 'orderCreate' => $orderCreateMock, + 'priceCurrency' => $this->priceCurrency, 'coreData' => $coreData, 'stockItemService' => $this->stockItemService ) diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Totals/TaxTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Totals/TaxTest.php index 84b1dbe72ebd1d195e88f80fc363486ec4770290..48e2691a5d5efd1a664b6fe7ba14fdb4d2789bba 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Totals/TaxTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Totals/TaxTest.php @@ -34,23 +34,19 @@ class TaxTest extends \PHPUnit_Framework_TestCase * * @param \Magento\Sales\Model\Order $source * @param array $getCalculatedTax - * @param array $getShippingTax * @param array $expectedResult * * @dataProvider getFullTaxInfoDataProvider */ - public function testGetFullTaxInfo($source, $getCalculatedTax, $getShippingTax, $expectedResult) + public function testGetFullTaxInfo($source, $getCalculatedTax, $expectedResult) { $taxHelperMock = $this->getMockBuilder('Magento\Tax\Helper\Data') - ->setMethods(array('getCalculatedTaxes', 'getShippingTax')) + ->setMethods(array('getCalculatedTaxes')) ->disableOriginalConstructor() ->getMock(); $taxHelperMock->expects($this->any()) ->method('getCalculatedTaxes') ->will($this->returnValue($getCalculatedTax)); - $taxHelperMock->expects($this->any()) - ->method('getShippingTax') - ->will($this->returnValue($getShippingTax)); $mockObject = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Totals\Tax') ->setConstructorArgs($this->_getConstructArguments($taxHelperMock)) @@ -98,17 +94,13 @@ class TaxTest extends \PHPUnit_Framework_TestCase 'tax' => 'tax', 'shipping_tax' => 'shipping_tax' ); - $getShippingTax = array( - 'shipping_tax' => 'shipping_tax', - 'shipping_and_handing' => 'shipping_and_handing' - ); return array( 'source is not an instance of \Magento\Sales\Model\Order' => - array($notAnInstanceOfASalesModelOrder, $getCalculatedTax, $getShippingTax, array()), + array($notAnInstanceOfASalesModelOrder, $getCalculatedTax, array()), 'source is an instance of \Magento\Sales\Model\Order and has reasonable data' => - array($salesModelOrderMock, $getCalculatedTax, $getShippingTax, array('tax' => 'tax', - 'shipping_tax' => 'shipping_tax', 'shipping_and_handing' => 'shipping_and_handing')) + array($salesModelOrderMock, $getCalculatedTax, array('tax' => 'tax', + 'shipping_tax' => 'shipping_tax')) ); } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/CancelTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/CancelTest.php index d8f6b8053a93743a95fe0641b9a9eeac2c3ef10d..d9d2e30943d5d2c9087b4b7a693e963c931f85ba 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/CancelTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/CancelTest.php @@ -92,7 +92,7 @@ class CancelTest extends \PHPUnit_Framework_TestCase { $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') ->disableOriginalConstructor() - ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId']) + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', '__wakeUp']) ->getMock(); $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php index 01fb6bbe984af654eb5e4f032bce666e245ca5bd..96e4db2f2d175cd45a45ac0a89e574d5d407dddf 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php @@ -97,7 +97,7 @@ class PrintActionTest extends \PHPUnit_Framework_TestCase { $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') ->disableOriginalConstructor() - ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId']) + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', '__wakeup']) ->getMock(); $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php index 550e79e87cc238f830617cb00f4b7d0f7d457a46..99d41c83adcdb81cefd58f05f226342b7a7d2231 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php @@ -92,7 +92,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase { $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') ->disableOriginalConstructor() - ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId']) + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', '__wakeup']) ->getMock(); $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/ViewTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/ViewTest.php index b5f4f3c74535479c2f056c302f2bf60dfac1df10..de583046573a2e70e87ef44d466be8e92d6e48c6 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/ViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/ViewTest.php @@ -101,7 +101,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') ->disableOriginalConstructor() - ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId']) + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', '__wakeup']) ->getMock(); $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/VoidTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/VoidTest.php index dd37a95be9e8bfe5a8111f7ea0ae9da87abf0f81..5a2479f69b95f4f3b1d74a02c303647e474e3303 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/VoidTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/VoidTest.php @@ -97,7 +97,7 @@ class VoidTest extends \PHPUnit_Framework_TestCase { $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') ->disableOriginalConstructor() - ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', 'void']) + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', 'void', '__wakeup']) ->getMock(); $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CancelTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CancelTest.php index 1f5b91328c61c26c6d62b3a10585d24810fd3134..24804a033d4af35445a307213ed63934a8cb7a13 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CancelTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CancelTest.php @@ -169,7 +169,7 @@ class CancelTest extends \PHPUnit_Framework_TestCase $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') ->disableOriginalConstructor() - ->setMethods(['setIsInProcess']) + ->setMethods(['setIsInProcess', '__wakeup']) ->getMock(); $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CaptureTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CaptureTest.php index acaf5a8db42be9b73e28fc59c7d5f65c01824af6..503d8c90e3f67c53fdf5a9d15ca38569186466db 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CaptureTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CaptureTest.php @@ -169,7 +169,7 @@ class CaptureTest extends \PHPUnit_Framework_TestCase $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') ->disableOriginalConstructor() - ->setMethods(['setIsInProcess']) + ->setMethods(['setIsInProcess', '__wakeup']) ->getMock(); $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/VoidTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/VoidTest.php index 946fbd308365fea3252d4d21f2fad7fced13b1a6..bfe5b4ae22612482473d8bd3990169c8cd782eb4 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/VoidTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/VoidTest.php @@ -183,7 +183,7 @@ class VoidTest extends \PHPUnit_Framework_TestCase $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') ->disableOriginalConstructor() - ->setMethods(['setIsInProcess']) + ->setMethods(['setIsInProcess', '__wakeup']) ->getMock(); $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoaderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoaderTest.php index 9801d8416650e458d0a8d5552786a73970703f5e..512fd5db983e5e521233feb1777f2090b0d6b475 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoaderTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoaderTest.php @@ -99,7 +99,7 @@ class InvoiceLoaderTest extends \PHPUnit_Framework_TestCase $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') ->disableOriginalConstructor() - ->setMethods(['load', 'getId']) + ->setMethods(['load', 'getId', '__wakeup']) ->getMock(); $orderMock->expects($this->once()) ->method('load') @@ -119,7 +119,7 @@ class InvoiceLoaderTest extends \PHPUnit_Framework_TestCase $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') ->disableOriginalConstructor() - ->setMethods(['load', 'getId', 'canInvoice']) + ->setMethods(['load', 'getId', 'canInvoice', '__wakeup']) ->getMock(); $orderMock->expects($this->once()) ->method('load') @@ -149,7 +149,7 @@ class InvoiceLoaderTest extends \PHPUnit_Framework_TestCase $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') ->disableOriginalConstructor() - ->setMethods(['load', 'getId', 'canInvoice']) + ->setMethods(['load', 'getId', 'canInvoice', '__wakeup']) ->getMock(); $orderMock->expects($this->once()) ->method('load') @@ -168,7 +168,7 @@ class InvoiceLoaderTest extends \PHPUnit_Framework_TestCase $serviceOrderMock = $this->getMockBuilder('Magento\Sales\Model\Service\Order') ->disableOriginalConstructor() - ->setMethods(['prepareInvoice']) + ->setMethods(['prepareInvoice', '__wakeup']) ->getMock(); $serviceOrderMock->expects($this->once()) ->method('prepareInvoice') @@ -194,7 +194,7 @@ class InvoiceLoaderTest extends \PHPUnit_Framework_TestCase $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') ->disableOriginalConstructor() - ->setMethods(['load', 'getId']) + ->setMethods(['load', 'getId', '__wakeup']) ->getMock(); $invoiceMock->expects($this->once()) ->method('load') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php index e894cf00b6b025b33ab015a82127ae29979949f6..5079c64c683b042ebb002708124c0cda714d578f 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php @@ -57,6 +57,11 @@ class AdminTest extends \PHPUnit_Framework_TestCase */ protected $adminHelper; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + protected function setUp() { $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Helper\Context') @@ -68,6 +73,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase $this->salesConfigMock = $this->getMockBuilder('Magento\Sales\Model\Config') ->disableOriginalConstructor() ->getMock(); + $this->priceCurrency = $this->getMockBuilder('\Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $this->adminHelper = (new ObjectManager($this))->getObject( 'Magento\Sales\Helper\Admin', @@ -75,6 +81,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase 'context' => $this->contextMock, 'storeManager' => $this->storeManagerMock, 'salesConfig' => $this->salesConfigMock, + 'priceCurrency' => $this->priceCurrency, ] ); @@ -123,8 +130,8 @@ class AdminTest extends \PHPUnit_Framework_TestCase $this->storeManagerMock->expects($this->any()) ->method('getStore') ->will($this->returnValue($storeMock)); - $storeMock->expects($this->any()) - ->method('formatPrice') + $this->priceCurrency->expects($this->any()) + ->method('format') ->will($this->returnValue('storeFormattedPrice')); $dataObject = $this->orderMock; if (!$dataObjectIsOrder) { @@ -171,8 +178,8 @@ class AdminTest extends \PHPUnit_Framework_TestCase $this->storeManagerMock->expects($this->any()) ->method('getStore') ->will($this->returnValue($storeMock)); - $storeMock->expects($this->any()) - ->method('formatPrice') + $this->priceCurrency->expects($this->any()) + ->method('format') ->will($this->returnValue('storeFormattedPrice')); $dataObject = $this->orderMock; if (!$dataObjectIsOrder) { diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/Total/SubtotalTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/Total/SubtotalTest.php index 4e05c179c9fe58fc3b402da71bc73a60eca26822..12fcac75dfdd4450cdf2e8b68663266a10bfc320 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/Total/SubtotalTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/Total/SubtotalTest.php @@ -89,10 +89,19 @@ class SubtotalTest extends \PHPUnit_Framework_TestCase ->method('getStockItem') ->will($this->returnValue($stockItemDoMock)); + $priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $priceCurrency->expects($this->any()) + ->method('convert') + ->willReturn(1231313); + //@todo this is a wrong test and it does not check methods. Any digital value will be correct + /** @var \Magento\Sales\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $quoteItem */ $quoteItem = $this->objectManager->getObject( 'Magento\Sales\Model\Quote\Item', - ['stockItemService' => $stockItemServiceMock] + [ + 'stockItemService' => $stockItemServiceMock, + 'priceCurrency' => $priceCurrency, + ] ); /** @var \Magento\Sales\Model\Quote\Address|\PHPUnit_Framework_MockObject_MockObject $address */ $address = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php index ea2fe33f3c9ff762df67f7aba80fd3475fb04233..e36fa1b2a262dde8462f6d466577009f787b26ee 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php @@ -71,7 +71,8 @@ class DiscountTest extends \PHPUnit_Framework_TestCase 'setSkipActionsValidation', 'process', 'processShippingAmount', - 'canApplyDiscount' + 'canApplyDiscount', + '__wakeup' ] ) ->getMock(); @@ -94,7 +95,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase { $itemNoDiscount = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') ->disableOriginalConstructor() - ->setMethods(['getNoDiscount']) + ->setMethods(['getNoDiscount', '__wakeup']) ->getMock(); $itemNoDiscount->expects($this->once()) ->method('getNoDiscount') @@ -106,7 +107,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') ->disableOriginalConstructor() - ->setMethods(['getStore']) + ->setMethods(['getStore', '__wakeup']) ->getMock(); $this->storeManagerMock->expects($this->any()) ->method('getStore') @@ -117,7 +118,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->getMock(); $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount']) + ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount', '__wakeup']) ->getMock(); $addressMock->expects($this->any()) ->method('getQuote') @@ -139,7 +140,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase { $itemWithParentId = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') ->disableOriginalConstructor() - ->setMethods(['getNoDiscount', 'getParentItemId']) + ->setMethods(['getNoDiscount', 'getParentItemId', '__wakeup']) ->getMock(); $itemWithParentId->expects($this->once()) ->method('getNoDiscount') @@ -158,7 +159,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') ->disableOriginalConstructor() - ->setMethods(['getStore']) + ->setMethods(['getStore', '__wakeup']) ->getMock(); $this->storeManagerMock->expects($this->any()) ->method('getStore') @@ -169,7 +170,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->getMock(); $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount']) + ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount', '__wakeup']) ->getMock(); $addressMock->expects($this->any()) ->method('getQuote') @@ -204,7 +205,16 @@ class DiscountTest extends \PHPUnit_Framework_TestCase $itemWithChildren = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') ->disableOriginalConstructor() - ->setMethods(['getNoDiscount', 'getParentItemId', 'getHasChildren', 'isChildrenCalculated', 'getChildren']) + ->setMethods( + [ + 'getNoDiscount', + 'getParentItemId', + 'getHasChildren', + 'isChildrenCalculated', + 'getChildren', + '__wakeup' + ] + ) ->getMock(); $itemWithChildren->expects($this->once()) ->method('getNoDiscount') @@ -235,7 +245,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') ->disableOriginalConstructor() - ->setMethods(['getStore']) + ->setMethods(['getStore', '__wakeup']) ->getMock(); $this->storeManagerMock->expects($this->any()) ->method('getStore') @@ -246,7 +256,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->getMock(); $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount']) + ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount', '__wakeup']) ->getMock(); $addressMock->expects($this->any()) ->method('getQuote') @@ -268,7 +278,16 @@ class DiscountTest extends \PHPUnit_Framework_TestCase { $itemWithChildren = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') ->disableOriginalConstructor() - ->setMethods(['getNoDiscount', 'getParentItemId', 'getHasChildren', 'isChildrenCalculated', 'getChildren']) + ->setMethods( + [ + 'getNoDiscount', + 'getParentItemId', + 'getHasChildren', + 'isChildrenCalculated', + 'getChildren', + '__wakeup' + ] + ) ->getMock(); $itemWithChildren->expects($this->once()) ->method('getNoDiscount') @@ -290,7 +309,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') ->disableOriginalConstructor() - ->setMethods(['getStore']) + ->setMethods(['getStore', '__wakeup']) ->getMock(); $this->storeManagerMock->expects($this->any()) ->method('getStore') @@ -301,7 +320,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->getMock(); $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount']) + ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount', '__wakeup']) ->getMock(); $addressMock->expects($this->any()) ->method('getQuote') @@ -323,7 +342,7 @@ class DiscountTest extends \PHPUnit_Framework_TestCase { $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getDiscountAmount', 'getDiscountDescription', 'addTotal']) + ->setMethods(['getDiscountAmount', 'getDiscountDescription', 'addTotal', '__wakeup']) ->getMock(); $addressMock->expects($this->once()) ->method('getDiscountAmount') diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Rule/Action/Discount/CartFixedTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Rule/Action/Discount/CartFixedTest.php index c34196d6b0496ace2ad560f3b14b4a01d6ca07ff..a414256e105a6a3cbd634894bf1df3e1f4fe746c 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Rule/Action/Discount/CartFixedTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Rule/Action/Discount/CartFixedTest.php @@ -60,6 +60,11 @@ class CartFixedTest extends \PHPUnit_Framework_TestCase */ protected $model; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + protected function setUp() { $this->rule = $this->getMock('Magento\Framework\Object', null, array(), 'Rule', true); @@ -86,7 +91,8 @@ class CartFixedTest extends \PHPUnit_Framework_TestCase false ); $dataFactory->expects($this->any())->method('create')->will($this->returnValue($this->data)); - $this->model = new CartFixed($this->validator, $dataFactory); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->model = new CartFixed($this->validator, $dataFactory, $this->priceCurrency); } /** @@ -98,8 +104,8 @@ class CartFixedTest extends \PHPUnit_Framework_TestCase $this->address->expects($this->any())->method('getCartFixedRules')->will($this->returnValue(array())); $store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); - $store->expects($this->atLeastOnce())->method('convertPrice')->will($this->returnArgument(0)); - $store->expects($this->atLeastOnce())->method('roundPrice')->will($this->returnArgument(0)); + $this->priceCurrency->expects($this->atLeastOnce())->method('convert')->will($this->returnArgument(0)); + $this->priceCurrency->expects($this->atLeastOnce())->method('round')->will($this->returnArgument(0)); $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($store)); /** validators data */ diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/UtilityTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/UtilityTest.php index 5aaa87e3afb851d95ffd08c4d0e1b078437720f3..6198cc8e76cf19f250593780020b060408996419 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/UtilityTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/UtilityTest.php @@ -84,6 +84,11 @@ class UtilityTest extends \PHPUnit_Framework_TestCase */ protected $utility; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + public function setUp() { $this->usageFactory = $this->getMock( @@ -174,11 +179,14 @@ class UtilityTest extends \PHPUnit_Framework_TestCase false ); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->utility = new Utility( $this->usageFactory, $this->couponFactory, $this->customerFactory, - $this->objectFactory + $this->objectFactory, + $this->priceCurrency ); } @@ -492,9 +500,9 @@ class UtilityTest extends \PHPUnit_Framework_TestCase ->method('getQuote') ->will($this->returnValue($this->quote)); - $store = $this->getMock('Magento\Store\Model\Store', ['roundPrice', '__wakeup'], [], '', false); - $store->expects($this->any()) - ->method('roundPrice') + $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->priceCurrency->expects($this->any()) + ->method('round') ->will($this->returnValueMap([ [$discountAmount, $roundedDiscount], [$baseDiscountAmount, $roundedBaseDiscount], diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php index e17c3f188d92e8d37e5a9a992a92664943d61572..91fab6970b17625654a1bce955962a05038cb266 100644 --- a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php @@ -77,35 +77,35 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase { $this->shipmentLoaderMock = $this->getMock( 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', - ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load', '__wakeup'], [], '', false ); $this->shipmentSenderMock = $this->getMock( 'Magento\Sales\Model\Order\Email\Sender\ShipmentSender', - ['send'], + ['send', '__wakeup'], [], '', false ); $this->requestMock = $this->getMock( 'Magento\Framework\App\Request\Http', - ['getParam', 'getPost', 'setParam'], + ['getParam', 'getPost', 'setParam', '__wakeup'], [], '', false ); $this->responseMock = $this->getMock( 'Magento\Framework\App\Response\Http', - ['setBody', 'representJson'], + ['setBody', 'representJson', '__wakeup'], [], '', false ); $this->titleMock = $this->getMock( 'Magento\Framework\App\Action\Title', - ['add'], + ['add', '__wakeup'], [], '', false @@ -119,14 +119,14 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ); $this->viewMock = $this->getMock( 'Magento\Backend\Model\View', - ['getLayout', 'loadLayout'], + ['getLayout', 'loadLayout', '__wakeup'], [], '', false ); $this->objectManagerMock = $this->getMock( 'Magento\Framework\ObjectManager', - ['create', 'get', 'configure'], + ['create', 'get', 'configure', '__wakeup'], [], '', false @@ -134,7 +134,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase $contextMock = $this->getMock( 'Magento\Backend\App\Action\Context', - ['getRequest', 'getResponse', 'getTitle', 'getView', 'getObjectManager'], + ['getRequest', 'getResponse', 'getTitle', 'getView', 'getObjectManager', '__wakeup'], [], '', false diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabelTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabelTest.php index 7f3fa60c2ca30b055d8765886d6cf3652908424d..0b9387bb6f7b932e6d61bf7d0b00379a16066dec 100644 --- a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabelTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabelTest.php @@ -72,7 +72,7 @@ class CreateLabelTest extends \PHPUnit_Framework_TestCase { $this->shipmentLoaderMock = $this->getMock( 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', - ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load', '__wakeup'], [], '', false @@ -84,25 +84,37 @@ class CreateLabelTest extends \PHPUnit_Framework_TestCase '', false ); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', ['getParam'], [], '', false); - $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', ['representJson'], [], '', false); + $this->requestMock = $this->getMock( + 'Magento\Framework\App\Request\Http', + ['getParam', '__wakeup'], + [], + '', + false + ); + $this->responseMock = $this->getMock( + 'Magento\Framework\App\Response\Http', + ['representJson', '__wakeup'], + [], + '', + false + ); $this->objectManagerMock = $this->getMock( 'Magento\Framework\ObjectManager', - ['create', 'get', 'configure'], + ['create', 'get', 'configure', '__wakeup'], [], '', false ); $this->messageManagerMock = $this->getMock( 'Magento\Framework\Message\Manager', - ['addSuccess', 'addError'], + ['addSuccess', 'addError', '__wakeup'], [], '', false ); $this->labelGenerator = $this->getMock( 'Magento\Shipping\Model\Shipping\LabelGenerator', - ['create'], + ['create', '__wakeup'], [], '', false @@ -110,7 +122,7 @@ class CreateLabelTest extends \PHPUnit_Framework_TestCase $contextMock = $this->getMock( 'Magento\Backend\App\Action\Context', - ['getRequest', 'getResponse', 'getMessageManager', 'getActionFlag', 'getObjectManager'], + ['getRequest', 'getResponse', 'getMessageManager', 'getActionFlag', 'getObjectManager', '__wakeup'], [], '', false @@ -214,7 +226,7 @@ class CreateLabelTest extends \PHPUnit_Framework_TestCase { $logerMock = $this->getMock( 'Magento\Framework\Logger', - ['logException'], + ['logException', '__wakeup'], [], '', false diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGridTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGridTest.php index dddb916c7f676b172bae51134b047f93383b1d6b..f0b9b329dd7e89e829413414a9aa845d7f1e526a 100644 --- a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGridTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGridTest.php @@ -57,28 +57,28 @@ class GetShippingItemsGridTest extends \PHPUnit_Framework_TestCase { $this->requestMock = $this->getMock( 'Magento\Framework\App\Request\Http', - ['getParam'], + ['getParam', '__wakeup'], [], '', false ); $this->shipmentLoaderMock = $this->getMock( 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', - ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load', '__wakeup'], [], '', false ); $this->viewMock = $this->getMock( 'Magento\Backend\Model\View', - ['getLayout', 'renderLayout'], + ['getLayout', 'renderLayout', '__wakeup'], [], '', false ); $this->responseMock = $this->getMock( 'Magento\Framework\App\Response\Http', - ['setBody'], + ['setBody', '__wakeup'], [], '', false @@ -86,7 +86,7 @@ class GetShippingItemsGridTest extends \PHPUnit_Framework_TestCase $contextMock = $this->getMock( 'Magento\Backend\App\Action\Context', - ['getRequest', 'getResponse', 'getView'], + ['getRequest', 'getResponse', 'getView', '__wakeup'], [], '', false diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php index 30993b8d447d352f3a6ad205aadd028ee3235252..142a798e971ca16547b58f1196b98ccc0f6c57c2 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php @@ -375,40 +375,6 @@ class StoreTest extends \PHPUnit_Framework_TestCase ]; } - public function testGetPriceFilter() - { - /** @var \Magento\Store\Model\Store $model */ - $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store'); - $model->setData('base_currency', false); - $model->setData('current_currency', false); - $model->setData('default_currency', false); - $this->assertInstanceOf('\Magento\Framework\Filter\Sprintf', $model->getPriceFilter()); - - $filter = $this->getMock('\Magento\Directory\Model\Currency\Filter', [], [], '', false); - - $defaultCurrency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); - $defaultCurrency->expects($this->any())->method('getFilter')->will($this->returnValue($filter)); - - $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store'); - $model->setData('base_currency', false); - $model->setData('current_currency', false); - $model->setData('default_currency', $defaultCurrency); - $this->assertEquals($filter, $model->getPriceFilter()); - - $filter->expects($this->any())->method('setRate')->with(2.1)->will($this->returnSelf()); - - $currentCurrency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); - $currentCurrency->expects($this->any())->method('getFilter')->will($this->returnValue($filter)); - - $baseCurrency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); - $baseCurrency->expects($this->any())->method('getRate')->with($currentCurrency)->will($this->returnValue(2.1)); - - $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store'); - $model->setData('base_currency', $baseCurrency); - $model->setData('current_currency', $currentCurrency); - $this->assertEquals($filter, $model->getPriceFilter()); - } - /** * @dataProvider getBaseCurrencyDataProvider * diff --git a/dev/tests/unit/testsuite/Magento/Tax/Block/Checkout/Shipping/PriceTest.php b/dev/tests/unit/testsuite/Magento/Tax/Block/Checkout/Shipping/PriceTest.php index 56acf3d7be556c98553bd6e0d779c64316c936d7..2c6b6a533c674fc9d2dac156ffaf96e190b20dd6 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Block/Checkout/Shipping/PriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Block/Checkout/Shipping/PriceTest.php @@ -47,13 +47,19 @@ class PriceTest extends \PHPUnit_Framework_TestCase */ protected $taxHelper; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->store = $this->getMockBuilder('Magento\Store\Model\Store') ->disableOriginalConstructor() - ->setMethods(['convertPrice', '__wakeup']) ->getMock(); $this->quote = $this->getMockBuilder('Magento\Sales\Model\Quote') @@ -86,6 +92,7 @@ class PriceTest extends \PHPUnit_Framework_TestCase [ 'checkoutSession' => $checkoutSession, 'taxHelper' => $this->taxHelper, + 'priceCurrency' => $this->priceCurrency, ] ); } @@ -118,10 +125,10 @@ class PriceTest extends \PHPUnit_Framework_TestCase ->method('getShippingPrice') ->will($this->returnValue($shippingPriceExclTax)); - $this->store->expects($this->once()) - ->method('convertPrice') - ->with($shippingPriceExclTax, true, true) - ->will($this->returnValue($convertedPrice)); + $this->priceCurrency->expects($this->once()) + ->method('convertAndFormat') + ->with($this->logicalOr($shippingPriceExclTax, true, $this->store)) + ->willReturn($convertedPrice); $this->priceObj->setShippingRate($shippingRateMock); $this->assertEquals($convertedPrice, $this->priceObj->getShippingPriceExclTax()); @@ -139,9 +146,9 @@ class PriceTest extends \PHPUnit_Framework_TestCase ->method('getShippingPrice') ->will($this->returnValue($shippingPriceInclTax)); - $this->store->expects($this->once()) - ->method('convertPrice') - ->with($shippingPriceInclTax, true, true) + $this->priceCurrency->expects($this->once()) + ->method('convertAndFormat') + ->with($this->logicalOr($shippingPriceInclTax, true, $this->store)) ->will($this->returnValue($convertedPrice)); $this->priceObj->setShippingRate($shippingRateMock); diff --git a/dev/tests/unit/testsuite/Magento/Tax/Block/Item/Price/RendererTest.php b/dev/tests/unit/testsuite/Magento/Tax/Block/Item/Price/RendererTest.php index 5fdd6366134f56cf05e37c1c8b830faa2a8d80f3..bb504b0050c6213f4a08dbb64800e176211cf87e 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Block/Item/Price/RendererTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Block/Item/Price/RendererTest.php @@ -38,10 +38,16 @@ class RendererTest extends \PHPUnit_Framework_TestCase */ protected $taxHelper; + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); $this->taxHelper = $this->getMockBuilder('\Magento\Tax\Helper\Data') ->disableOriginalConstructor() ->setMethods([ @@ -58,6 +64,7 @@ class RendererTest extends \PHPUnit_Framework_TestCase '\Magento\Tax\Block\Item\Price\Renderer', [ 'taxHelper' => $this->taxHelper, + 'priceCurrency' => $this->priceCurrency, 'data' => [ 'zone' => Render::ZONE_CART, ] @@ -234,8 +241,8 @@ class RendererTest extends \PHPUnit_Framework_TestCase ->setMethods(['formatPrice', '__wakeup']) ->getMock(); - $storeMock->expects($this->once()) - ->method('formatPrice') + $this->priceCurrency->expects($this->once()) + ->method('format') ->with($price, true) ->will($this->returnValue($formattedPrice)); @@ -259,7 +266,6 @@ class RendererTest extends \PHPUnit_Framework_TestCase $orderMock = $this->getMockBuilder('\Magento\Sales\Model\Order') ->disableOriginalConstructor() - ->setMethods(['formatPrice', '__wakeup']) ->getMock(); $orderMock->expects($this->once()) diff --git a/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php index 37139df950ca62469028469ef0b4110025ec7a5a..22948240bfcdcc1420a475bd45d6598eeddcded1 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php @@ -27,10 +27,7 @@ namespace Magento\Tax\Helper; use Magento\TestFramework\Helper\ObjectManager; use Magento\Tax\Service\V1\Data\OrderTaxDetails\AppliedTax; use Magento\Tax\Service\V1\Data\OrderTaxDetails\Item; -use Magento\Tax\Service\V1\Data\OrderTaxDetails\AppliedTaxBuilder; -use Magento\Tax\Service\V1\Data\OrderTaxDetails\ItemBuilder; use Magento\Tax\Service\V1\Data\OrderTaxDetails; -use Magento\Tax\Service\V1\Data\OrderTaxDetailsBuilder; /** * Test tax helper */ @@ -48,6 +45,9 @@ class DataTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Registry */ private $coreRegistry; + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\PriceCurrencyInterface */ + private $priceCurrency; + public function setUp() { $objectManager = new ObjectManager($this); @@ -61,11 +61,21 @@ class DataTest extends \PHPUnit_Framework_TestCase ->setMethods(['getOrderTaxDetails']) ->getMock(); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->priceCurrency->expects($this->any()) + ->method('round') + ->will($this->returnCallback( + function ($argument) { + return round($argument, 2); + } + )); + $this->taxHelper = $objectManager->getObject( 'Magento\Tax\Helper\Data', [ 'coreRegistry' => $this->coreRegistry, 'orderTaxService' => $this->orderTaxService, + 'priceCurrency' => $this->priceCurrency, ] ); @@ -93,15 +103,7 @@ class DataTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store */ $store = $this->getMockBuilder('\Magento\Store\Model\Store') ->disableOriginalConstructor() - ->setMethods(['roundPrice', '__wakeup']) ->getMock(); - $store->expects($this->any()) - ->method('roundPrice') - ->will($this->returnCallback( - function ($argument) { - return round($argument, 2); - } - )); $objectManager = new ObjectManager($this); $this->orderTaxDetailsBuilder = $objectManager->getObject('Magento\Tax\Service\V1\Data\OrderTaxDetailsBuilder'); @@ -214,14 +216,6 @@ class DataTest extends \PHPUnit_Framework_TestCase ->method('registry') ->with('current_invoice') ->will($this->returnValue($invoice)); - $this->coreRegistry->expects($this->at(2)) - ->method('registry') - ->with('current_invoice') - ->will($this->returnValue($invoice)); - $this->coreRegistry->expects($this->at(3)) - ->method('registry') - ->with('current_invoice') - ->will($this->returnValue($invoice)); $this->commonTestGetCalculatedTaxesInvoiceCreditmemo($source, $orderTaxDetails, $expectedResults); } @@ -246,18 +240,6 @@ class DataTest extends \PHPUnit_Framework_TestCase ->method('registry') ->with('current_creditmemo') ->will($this->returnValue($creditmemo)); - $this->coreRegistry->expects($this->at(3)) - ->method('registry') - ->with('current_invoice') - ->will($this->returnValue(null)); - $this->coreRegistry->expects($this->at(4)) - ->method('registry') - ->with('current_creditmemo') - ->will($this->returnValue($creditmemo)); - $this->coreRegistry->expects($this->at(5)) - ->method('registry') - ->with('current_creditmemo') - ->will($this->returnValue($creditmemo)); $this->commonTestGetCalculatedTaxesInvoiceCreditmemo($source, $orderTaxDetails, $expectedResults); } @@ -270,15 +252,7 @@ class DataTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store */ $store = $this->getMockBuilder('\Magento\Store\Model\Store') ->disableOriginalConstructor() - ->setMethods(['roundPrice', '__wakeup']) ->getMock(); - $store->expects($this->any()) - ->method('roundPrice') - ->will($this->returnCallback( - function ($argument) { - return round($argument, 2); - } - )); $objectManager = new ObjectManager($this); $this->orderTaxDetailsBuilder = $objectManager->getObject('Magento\Tax\Service\V1\Data\OrderTaxDetailsBuilder'); @@ -421,6 +395,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'qty_not_changed' => [ 'source' => new \Magento\Framework\Object( [ + 'shipping_tax_amount' => '2.6', 'id' => '19', 'store' => $store, ] @@ -460,8 +435,8 @@ class DataTest extends \PHPUnit_Framework_TestCase [ 'tax_amount' => '2.6', 'base_tax_amount' => '5.21', - 'title' => 'Shipping & Handling Tax', - 'percent' => '', + 'title' => 'Shipping', + 'percent' => '21', ], [ 'title' => 'US-CA-*-Rate 1', diff --git a/dev/tests/unit/testsuite/Magento/Weee/Block/Item/Price/RendererTest.php b/dev/tests/unit/testsuite/Magento/Weee/Block/Item/Price/RendererTest.php index 8541ade33bd75453ba74da49f21ebb69f4bfd578..53980d902194de191a99e4ab9039b8baa3e2d865 100644 --- a/dev/tests/unit/testsuite/Magento/Weee/Block/Item/Price/RendererTest.php +++ b/dev/tests/unit/testsuite/Magento/Weee/Block/Item/Price/RendererTest.php @@ -110,7 +110,7 @@ class RendererTest extends \PHPUnit_Framework_TestCase /** * @param bool $isWeeeEnabled - * @param bool #showWeeeDetails + * @param bool $showWeeeDetails * @param bool $hasWeeeAmount * @param bool $expectedValue * @dataProvider testDisplayPriceWithWeeeDetailsDataProvider diff --git a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php index 1b0f41196f49113e4a1c79cb05034a92b2e4fdec..bdf62398994adf203dfa6044346cf52fe4896ea3 100644 --- a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php +++ b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php @@ -27,6 +27,11 @@ use Magento\Tax\Model\Calculation; class WeeeTest extends \PHPUnit_Framework_TestCase { + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + /** * Setup tax helper with an array of methodName, returnValue * @@ -141,8 +146,10 @@ class WeeeTest extends \PHPUnit_Framework_TestCase ); $quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); - $storeMock = $this->getMock('Magento\Store\Model\Store', ['__wakeup', 'convertPrice'], [], '', false); - $storeMock->expects($this->any())->method('convertPrice')->will($this->returnArgument(0)); + $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->priceCurrency->expects($this->any())->method('round')->willReturnArgument(0); + $this->priceCurrency->expects($this->any())->method('convert')->willReturnArgument(0); $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); $addressMock->expects($this->any())->method('getAllNonNominalItems')->will($this->returnValue([$itemMock])); @@ -201,6 +208,7 @@ class WeeeTest extends \PHPUnit_Framework_TestCase 'taxData' => $taxHelper, 'calculation' => $calculator, 'weeeData' => $weeeHelper, + 'priceCurrency' => $this->priceCurrency, ]; $helper = new \Magento\TestFramework\Helper\ObjectManager($this); diff --git a/lib/internal/Magento/Framework/Acl/Builder.php b/lib/internal/Magento/Framework/Acl/Builder.php index bd4dd368ea66d4f1f856105f4853d330250827b3..42d9f3e0aad52fea19d7022f2245c31c63d9127c 100644 --- a/lib/internal/Magento/Framework/Acl/Builder.php +++ b/lib/internal/Magento/Framework/Acl/Builder.php @@ -50,6 +50,11 @@ class Builder */ protected $_cache; + /** + * @var \Magento\Framework\AclFactory + */ + protected $_aclFactory; + /** * @param \Magento\Framework\AclFactory $aclFactory * @param \Magento\Framework\Acl\CacheInterface $cache diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index e6d138d1454474763ddc42ffc9ea346b04f9c2fd..76f026d1fb48a34a3c708deefe6f7f1d7ebce3de 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -108,7 +108,12 @@ class ObjectManagerFactory $definitions, $appArguments->get() ); - + if ($appArguments->get('MAGE_PROFILER') == 2) { + $this->factory = new \Magento\Framework\ObjectManager\Profiler\FactoryDecorator( + $this->factory, + \Magento\Framework\ObjectManager\Profiler\Log::getInstance() + ); + } $className = $this->_locatorClassName; $sharedInstances = [ diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index 6acd25180d6b8a19082294a7c06dbe934f0e67fa..dce0e23d1c11b590c229503ac1d885c0fd48bad8 100644 --- a/lib/internal/Magento/Framework/AppInterface.php +++ b/lib/internal/Magento/Framework/AppInterface.php @@ -35,7 +35,7 @@ interface AppInterface /** * Magento version */ - const VERSION = '0.1.0-alpha95'; + const VERSION = '0.1.0-alpha96'; /** * Launch application diff --git a/lib/internal/Magento/Framework/Math/Calculator.php b/lib/internal/Magento/Framework/Math/Calculator.php index 9371a13f721724e3b8340128608466636fd4e44e..ed2204ae3d9ca59e267bc9ad2c8da7bb06a1237f 100644 --- a/lib/internal/Magento/Framework/Math/Calculator.php +++ b/lib/internal/Magento/Framework/Math/Calculator.php @@ -36,20 +36,16 @@ class Calculator protected $_delta = 0.0; /** - * Store instance - * - * @var \Magento\Framework\App\ScopeInterface|null + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|null */ - protected $_scope = null; + protected $priceCurrency; /** - * Initialize calculator - * - * @param \Magento\Framework\App\ScopeInterface $scope + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency */ - public function __construct(\Magento\Framework\App\ScopeInterface $scope) + public function __construct(\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency) { - $this->_scope = $scope; + $this->priceCurrency = $priceCurrency; } /** @@ -67,7 +63,7 @@ class Calculator $this->_delta = -$this->_delta; } $price += $this->_delta; - $roundedPrice = $this->_scope->roundPrice($price); + $roundedPrice = $this->priceCurrency->round($price); $this->_delta = $price - $roundedPrice; if ($negative) { $this->_delta = -$this->_delta; diff --git a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php index 912c316846998abcb09855c336b70ffe15bd2705..1a5335a836eb36c5920736bd9712fd7b554a57ca 100644 --- a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php @@ -36,6 +36,7 @@ use Magento\Framework\Service\Code\Generator\Mapper as MapperGenerator; use Magento\Framework\ObjectManager\Code\Generator\Converter as ConverterGenerator; use Magento\Framework\Service\Code\Generator\SearchResults; use Magento\Framework\Service\Code\Generator\SearchResultsBuilder; +use Magento\Framework\ObjectManager\Profiler\Code\Generator as ProfilerGenerator; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -126,6 +127,7 @@ class DefinitionFactory $autoloader, $generatorIo, array( + SearchResultsBuilder::ENTITY_TYPE => '\Magento\Framework\Service\Code\Generator\SearchResultsBuilder', Generator\Factory::ENTITY_TYPE @@ -144,6 +146,8 @@ class DefinitionFactory => '\Magento\Framework\Service\Code\Generator\SearchResults', ConverterGenerator::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Converter', + ProfilerGenerator\Logger::ENTITY_TYPE + => '\Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger' ) ); $autoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php new file mode 100644 index 0000000000000000000000000000000000000000..a106bd4762edfd9d8eb1c3b6330eb9a45a9e4600 --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php @@ -0,0 +1,235 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\ObjectManager\Profiler\Code\Generator; + +class Logger extends \Magento\Framework\Code\Generator\EntityAbstract +{ + /** + * Entity type + */ + const ENTITY_TYPE = 'logger'; + + /** + * @param string $modelClassName + * @return string + */ + protected function _getDefaultResultClassName($modelClassName) + { + return $modelClassName . '\\' . ucfirst(static::ENTITY_TYPE); + } + + /** + * Returns list of properties for class generator + * + * @return array + */ + protected function _getClassProperties() + { + return array( + array( + 'name' => 'log', + 'visibility' => 'protected', + 'docblock' => array( + 'shortDescription' => 'Object Manager factory log', + 'tags' => array( + array('name' => 'var', 'description' => '\Magento\Framework\ObjectManager\Factory\Log') + ) + ), + ), + array( + 'name' => 'subject', + 'visibility' => 'protected', + 'docblock' => array( + 'shortDescription' => 'Object Manager instance', + 'tags' => array( + array('name' => 'var', 'description' => '\Magento\Framework\ObjectManager') + ) + ), + ), + ); + } + + /** + * Get default constructor definition for generated class + * + * @return array + */ + protected function _getDefaultConstructorDefinition() + { + return array( + 'name' => '__construct', + 'parameters' => array( + array('name' => 'subject'), + array('name' => 'log') + ), + 'body' => "\$this->log = \$log;" + . "\n\$this->subject = \$subject;" + ); + } + + /** + * Returns list of methods for class generator + * + * @return mixed + */ + protected function _getClassMethods() + { + $methods = array($this->_getDefaultConstructorDefinition()); + $methods[] = array( + 'name'=> '_invoke', + 'visibility' => 'protected', + 'parameters' => array( + array('name' => 'methodName'), + array('name' => 'methodArguments', 'type' => 'array', 'passedByReference' => true), + ), + 'body' => $this->_getInvokeMethodBody(), + 'docblock' => array( + 'shortDescription' => 'Invoke method', + 'tags' => array( + array('name' => 'param', 'description' => 'string $methodName'), + array('name' => 'param', 'description' => 'array $methodArguments'), + array('name' => 'return', 'description' => 'mixed'), + ), + ), + ); + $methods[] = array( + 'name' => '__clone', + 'body' => "\$this->subject = clone \$this->subject;" + . "\n\$this->log->add(\$this->subject);", + 'docblock' => array( + 'shortDescription' => 'Clone subject instance', + ), + ); + + $methods[] = array( + 'name' => '__sleep', + 'body' => "return array('subject');", + ); + + $methods[] = array( + 'name' => '__wakeUp', + 'body' => "\$this->log = \\Magento\\Framework\\ObjectManager\\Profiler\\Log::getInstance();" + ."\n\$this->log->add(\$this->subject);", + ); + + $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); + $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); + foreach ($publicMethods as $method) { + if (!($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) + && !in_array($method->getName(), array('__sleep', '__wakeup', '__clone')) + ) { + $methods[] = $this->_getMethodInfo($method); + } + } + + return $methods; + } + + /** + * Retrieve body of the _invoke method + * + * @return string + */ + protected function _getInvokeMethodBody() + { + return "\n\$this->log->invoked(\$this->subject, \$methodName);" + . "\n\$result = call_user_func_array(array(\$this->subject, \$methodName), \$methodArguments);" + . "\nif (\$result === \$this->subject) {" + . "\n return \$this;" + . "\n}" + . "\nreturn \$result;"; + } + + /** + * Retrieve method info + * + * @param \ReflectionMethod $method + * @return array + */ + protected function _getMethodInfo(\ReflectionMethod $method) + { + $parameters = array(); + foreach ($method->getParameters() as $parameter) { + $parameters[] = $this->_getMethodParameterInfo($parameter); + } + + $body = "\$args = func_get_args();"; + foreach ($parameters as $key => $parameter) { + if ($parameter['passedByReference']) { + $body .= "\$args[$key] = &\$" . $parameter['name'] . ';'; + } + } + + $methodInfo = array( + 'name' => $method->getName(), + 'parameters' => $parameters, + 'body' => $body . "\nreturn \$this->_invoke('{$method->getName()}', \$args);", + 'docblock' => array( + 'shortDescription' => '{@inheritdoc}', + ), + ); + + return $methodInfo; + } + + /** + * Generate resulting class source code + * + * @return string + */ + protected function _generateCode() + { + $typeName = $this->_getFullyQualifiedClassName($this->_getSourceClassName()); + $reflection = new \ReflectionClass($typeName); + + if ($reflection->isInterface()) { + $this->_classGenerator->setImplementedInterfaces(array($typeName)); + } else { + $this->_classGenerator->setExtendedClass($typeName); + } + return parent::_generateCode(); + } + + /** + * {@inheritdoc} + */ + protected function _validateData() + { + $result = parent::_validateData(); + + if ($result) { + $sourceClassName = $this->_getSourceClassName(); + $resultClassName = $this->_getResultClassName(); + + if ($resultClassName !== $sourceClassName . '\\Logger') { + $this->_addError( + 'Invalid Logger class name [' . $resultClassName . ']. Use ' . $sourceClassName . '\\Logger' + ); + $result = false; + } + } + return $result; + } +} diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php new file mode 100644 index 0000000000000000000000000000000000000000..f53f160cfb95fadf8412a3fcd0dc49ff174ad552 --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php @@ -0,0 +1,71 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\ObjectManager\Profiler; + +class FactoryDecorator implements \Magento\Framework\ObjectManager\Factory +{ + /** + * @var \Magento\Framework\ObjectManager\Factory + */ + protected $subject; + + /** + * @var Log + */ + protected $log; + + /** + * @param \Magento\Framework\ObjectManager\Factory $subject + * @param Log $log + */ + public function __construct(\Magento\Framework\ObjectManager\Factory $subject, Log $log) + { + $this->subject = $subject; + $this->log = $log; + } + + /** + * @param \Magento\Framework\ObjectManager $objectManager + * + * @return void + */ + public function setObjectManager(\Magento\Framework\ObjectManager $objectManager) + { + $this->subject->setObjectManager($objectManager); + } + + /** + * {@inheritdoc} + */ + public function create($requestedType, array $arguments = array()) + { + $this->log->startCreating($requestedType); + $result = $this->subject->create($requestedType, $arguments); + $loggerClassName = get_class($result) . "\\Logger"; + $wrappedResult = new $loggerClassName($result, $this->log); + $this->log->stopCreating($result); + return $wrappedResult; + } +} diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php new file mode 100644 index 0000000000000000000000000000000000000000..66dd749bef15f1fe6c8184c5967efed9d4102ccf --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php @@ -0,0 +1,183 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\ObjectManager\Profiler; + +use Magento\Framework\ObjectManager\Profiler\Tree\Item as Item; + +class Log +{ + /** + * @var $this + */ + protected static $instance; + + /** + * @var Item + */ + protected $currentItem = null; + + /** + * @var array + */ + protected $data = array(); + + /** + * @var array + */ + protected $roots = array(); + + /** + * @var array + */ + protected $used = array(); + + /** + * @var array + */ + protected $stats = array('total' => 0, 'used' => 0, 'unused' => 0); + + /** + * Constructor + */ + public function __construct() + { + register_shutdown_function(array($this, 'display')); + } + + /** + * Retrieve instance + * + * @return Log + */ + public static function getInstance() + { + if (!self::$instance) { + self::$instance = new Log(); + } + return self::$instance; + } + + /** + * Log object instantiation + * + * @param string $class + * @return void + */ + public function startCreating($class) + { + $this->stats['total']++; + $parent = empty($this->currentItem) ? null : $this->currentItem; + $item = new Item($class, $parent); + + if (!$parent) { + $this->roots[] = $item; + } + + $this->currentItem = $item; + } + + /** + * Log object instantiation + * + * @param mixed $object + * @return void + */ + public function stopCreating($object) + { + $this->currentItem->setHash(spl_object_hash($object)); + $this->currentItem = $this->currentItem->getParent(); + } + + /** + * Monitor object + * + * @param mixed $object + * @return void + */ + public function add($object) + { + $this->stats['total']++; + if ($this->currentItem) { + $item = new Item(get_class($object), $this->currentItem); + $this->currentItem->addChild($item); + } else { + $item = new Item(get_class($object), null); + $this->roots[] = $item; + } + $item->setHash(spl_object_hash($object)); + + } + + /** + * Object was invoked + * + * @param mixed $object + * @return void + */ + public function invoked($object) + { + $this->used[spl_object_hash($object)] = 1; + } + + /** + * Display results + * + * @return void + */ + public function display() + { + $this->stats['used'] = count($this->used); + $this->stats['unused'] = $this->stats['total'] - $this->stats['used']; + echo '<table border="1" cellspacing="0" cellpadding="2">' . PHP_EOL; + echo "<caption>Creation chain (Red items are never used) Total: {$this->stats['total']}\n"; + echo "Used: {$this->stats['used']} Not used: {$this->stats['unused']}</caption>"; + echo '<tbody>'; + echo "<tr><th>Instance class</th></tr>"; + foreach ($this->roots as $root) { + $this->displayItem($root); + } + echo '</tbody>'; + echo '</table>'; + } + + /** + * Display item + * + * @param Item $item + * @param int $level + * @return void + */ + protected function displayItem(Item $item, $level = 0) + { + $colorStyle = isset($this->used[$item->getHash()]) ? '' : ' style="color:red" '; + + echo "<tr><td $colorStyle>" . str_repeat('· ', $level) . $item->getClass() + . ' - ' . $item->getHash() . '</td></tr>'; + + foreach ($item->getChildren() as $child) { + $this->displayItem($child, $level + 1); + } + } +} diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/Tree/Item.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/Tree/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..d9a08a3f5127926d848bb9c38b70fd25045ccbb4 --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/Tree/Item.php @@ -0,0 +1,124 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\ObjectManager\Profiler\Tree; + +class Item +{ + /** + * @var string + */ + protected $class; + + /** + * @var Item|null + */ + protected $parent = null; + + /** + * @var string + */ + protected $hash = null; + + /** + * @var array + */ + protected $children = array(); + + /** + * @param string $class + * @param Item $parent + */ + public function __construct($class, Item $parent = null) + { + $this->class = $class; + $this->parent = $parent; + + if ($parent) { + $parent->addChild($this); + } + } + + /** + * Retrieve class + * + * @return string + */ + public function getClass() + { + return $this->class; + } + + /** + * Add child + * + * @param Item $item + * @return void + */ + public function addChild(Item $item) + { + $this->children[] = $item; + } + + /** + * Retrieve list of children + * + * @return array[Item] + */ + public function getChildren() + { + return $this->children; + } + + /** + * Retrieve parent + * + * @return Item|null + */ + public function getParent() + { + return $this->parent; + } + + /** + * Set hash + * + * @param string $hash + * @return void + */ + public function setHash($hash) + { + $this->hash = $hash; + } + + /** + * Retrieve hash + * + * @return string + */ + public function getHash() + { + return $this->hash; + } +} diff --git a/lib/internal/Magento/Framework/Pricing/Adjustment/AdjustmentInterface.php b/lib/internal/Magento/Framework/Pricing/Adjustment/AdjustmentInterface.php index a5398106eb74a0b650cf53ca45861e0992d3691a..c6f7ddea3f849d47760059327b780f6ab0527cb1 100644 --- a/lib/internal/Magento/Framework/Pricing/Adjustment/AdjustmentInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Adjustment/AdjustmentInterface.php @@ -58,18 +58,20 @@ interface AdjustmentInterface * * @param float $amount * @param SaleableInterface $saleableItem + * @param null|array $context * @return float */ - public function extractAdjustment($amount, SaleableInterface $saleableItem); + public function extractAdjustment($amount, SaleableInterface $saleableItem, $context = []); /** * Apply adjustment amount and return result value * * @param float $amount * @param SaleableInterface $saleableItem + * @param null|array $context * @return float */ - public function applyAdjustment($amount, SaleableInterface $saleableItem); + public function applyAdjustment($amount, SaleableInterface $saleableItem, $context = []); /** * Check if adjustment should be excluded from calculations along with the given adjustment diff --git a/lib/internal/Magento/Framework/Pricing/Adjustment/Calculator.php b/lib/internal/Magento/Framework/Pricing/Adjustment/Calculator.php index e99d7601fe0159e4ce3722d2dbb502ef383bbdb6..030032eb32f91da575d448bc015e3519694f6296 100644 --- a/lib/internal/Magento/Framework/Pricing/Adjustment/Calculator.php +++ b/lib/internal/Magento/Framework/Pricing/Adjustment/Calculator.php @@ -52,9 +52,10 @@ class Calculator implements CalculatorInterface * @param float|string $amount * @param SaleableInterface $saleableItem * @param null|bool|string $exclude + * @param null|array $context * @return \Magento\Framework\Pricing\Amount\AmountInterface */ - public function getAmount($amount, SaleableInterface $saleableItem, $exclude = null) + public function getAmount($amount, SaleableInterface $saleableItem, $exclude = null, $context = []) { $baseAmount = $fullAmount = $amount; $adjustments = []; @@ -65,9 +66,9 @@ class Calculator implements CalculatorInterface $toExclude = true; } if ($adjustment->isIncludedInBasePrice()) { - $adjust = $adjustment->extractAdjustment($baseAmount, $saleableItem); + $adjust = $adjustment->extractAdjustment($baseAmount, $saleableItem, $context); $baseAmount -= $adjust; - $fullAmount = $adjustment->applyAdjustment($fullAmount, $saleableItem); + $fullAmount = $adjustment->applyAdjustment($fullAmount, $saleableItem, $context); $adjust = $fullAmount - $baseAmount; if (!$toExclude) { $adjustments[$code] = $adjust; @@ -76,7 +77,7 @@ class Calculator implements CalculatorInterface if ($toExclude) { continue; } - $newAmount = $adjustment->applyAdjustment($fullAmount, $saleableItem); + $newAmount = $adjustment->applyAdjustment($fullAmount, $saleableItem, $context); $adjust = $newAmount - $fullAmount; $adjustments[$code] = $adjust; $fullAmount = $newAmount; diff --git a/lib/internal/Magento/Framework/Pricing/Adjustment/CalculatorInterface.php b/lib/internal/Magento/Framework/Pricing/Adjustment/CalculatorInterface.php index c7dca4ea6afa8b00b10906965f1358a4598309a4..584f15df9c901ee39749c61902f1fca5ae822955 100644 --- a/lib/internal/Magento/Framework/Pricing/Adjustment/CalculatorInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Adjustment/CalculatorInterface.php @@ -35,7 +35,8 @@ interface CalculatorInterface * @param float|string $amount * @param SaleableInterface $saleableItem * @param null|bool|string $exclude + * @param null|array $context * @return \Magento\Framework\Pricing\Amount\AmountInterface */ - public function getAmount($amount, SaleableInterface $saleableItem, $exclude = null); + public function getAmount($amount, SaleableInterface $saleableItem, $exclude = null, $context = []); } diff --git a/lib/internal/Magento/Framework/Pricing/Price/AbstractPrice.php b/lib/internal/Magento/Framework/Pricing/Price/AbstractPrice.php index d00f8f38eb21ba478a0564586ebce6ebf82ec022..700a22c12cdd22bf556dd9557e6967f6f91c4b86 100644 --- a/lib/internal/Magento/Framework/Pricing/Price/AbstractPrice.php +++ b/lib/internal/Magento/Framework/Pricing/Price/AbstractPrice.php @@ -114,12 +114,13 @@ abstract class AbstractPrice implements PriceInterface /** * @param float $amount * @param null|bool|string $exclude + * @param null|array $context * @return AmountInterface|bool|float */ - public function getCustomAmount($amount = null, $exclude = null) + public function getCustomAmount($amount = null, $exclude = null, $context = []) { $amount = (null === $amount) ? $this->getValue() : $amount; - return $this->calculator->getAmount($amount, $this->product, $exclude); + return $this->calculator->getAmount($amount, $this->product, $exclude, $context); } /** diff --git a/lib/internal/Magento/Framework/Pricing/Price/PriceInterface.php b/lib/internal/Magento/Framework/Pricing/Price/PriceInterface.php index 2f745cba3f33722419a6969a19082be5e773e369..e04a77d344f9e688843a16af7d2f0e22c47e06ea 100644 --- a/lib/internal/Magento/Framework/Pricing/Price/PriceInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Price/PriceInterface.php @@ -58,7 +58,8 @@ interface PriceInterface * * @param float $amount * @param null|bool|string $exclude + * @param null|array $context * @return AmountInterface */ - public function getCustomAmount($amount = null, $exclude = null); + public function getCustomAmount($amount = null, $exclude = null, $context = []); } diff --git a/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php b/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php index 621bc80d65da2c2a4f98a8985a639946ceb05422..c2331005300afb01d2a958ea9709173b3ce610a9 100644 --- a/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php +++ b/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php @@ -79,4 +79,12 @@ interface PriceCurrencyInterface $store = null, $currency = null ); + + /** + * Round price + * + * @param float $price + * @return float + */ + public function round($price); } diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index fa8a2103ab530df44a4057a5f57a5fef0f251b5d..fed8d58717c22e62b5ee99702b8e10749d6eda09 100644 --- a/lib/internal/Magento/Framework/composer.json +++ b/lib/internal/Magento/Framework/composer.json @@ -2,7 +2,7 @@ "name": "magento/framework", "description": "N/A", "type": "magento2-library", - "version": "0.1.0-alpha95", + "version": "0.1.0-alpha96", "require": { "php": "~5.4.11|~5.5.0", "ext-spl": "*", @@ -13,7 +13,8 @@ "ext-curl": "*", "ext-iconv": "*", "ext-gd": "*", - "lib-libxml": "*" + "lib-libxml": "*", + "magento/magento-composer-installer": "*" }, "suggest": { "ext-imagick": "Use Image Magick >=3.0.0 as an optional alternative image processing library" diff --git a/setup/index.php b/setup/index.php index b16368bfe991221cc7c60f3d76dbc01d8733dd85..de0298447cbea59a63b226703b82e7af24e25070 100644 --- a/setup/index.php +++ b/setup/index.php @@ -22,7 +22,26 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -include "vendor/autoload.php"; +$autoload = __DIR__ . '/vendor/autoload.php'; + +if (!file_exists($autoload)) { + if (PHP_SAPI == 'cli') { + echo "Dependencies not installed. Please run 'composer install' under /setup directory.\n"; + } else { + echo <<<HTML +<div style="font:12px/1.35em arial, helvetica, sans-serif;"> + <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"> + <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;"> + Whoops, it looks like setup tool dependencies are not installed.</h3> + </div> + <p>Please run 'composer install' under /setup directory.</p> +</div> +HTML; + } + exit(1); +} + +require $autoload; use Zend\Mvc\Service\ServiceManagerConfig; use Zend\ServiceManager\ServiceManager; diff --git a/setup/module/Magento/Setup/src/Mvc/Router/Http/Setup.php b/setup/module/Magento/Setup/src/Mvc/Router/Http/Setup.php index 0ed675680d945301bca2a3abb966a76ee9b22370..03f8a63b8e2e32faade9ed42c9860bf7903c1e7c 100644 --- a/setup/module/Magento/Setup/src/Mvc/Router/Http/Setup.php +++ b/setup/module/Magento/Setup/src/Mvc/Router/Http/Setup.php @@ -37,12 +37,7 @@ use Zend\Mvc\Router\Http\RouteMatch; class Setup extends ZendRegex { /** - * factory(): defined by RouteInterface interface. - * - * @see \Zend\Mvc\Router\RouteInterface::factory() - * @param array|Traversable $options - * @return Regex - * @throws \Zend\Mvc\Router\Exception\InvalidArgumentException + * {@inheritdoc} */ public static function factory($options = array()) { @@ -74,18 +69,15 @@ class Setup extends ZendRegex } /** - * match(): defined by RouteInterface interface. - * - * @param Request $request - * @param int $pathOffset - * @return RouteMatch|null + * {@inheritdoc} */ - public function match(Request $request, $pathOffset = null) + public function match(Request $request, $pathOffset = 0) { if (!method_exists($request, 'getUri')) { return null; } + /** @var $uri \Zend\Uri\Http */ $uri = $request->getUri(); $path = $uri->getPath(); @@ -100,10 +92,7 @@ class Setup extends ZendRegex } } - $chunks = explode('/', ltrim($path, '/')); - if ($pathOffset !== null) { - array_shift($chunks); // Extract 'module name' part - } + $chunks = explode('/', substr(ltrim($path, '/'), $pathOffset)); array_shift($chunks); // Extract 'lang' part array_pop($chunks); // Extract 'controller' part