diff --git a/.htaccess b/.htaccess index f1ef8719ba1a8421e3d58aeceee851da731e4f77..a0e18f2633dd90f4e187454aa4cceda66e04e738 100644 --- a/.htaccess +++ b/.htaccess @@ -188,3 +188,4 @@ ## http://developer.yahoo.com/performance/rules.html#etags #FileETag none + diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2a7a7293a913a6ad6a447e556ecb73532a7898..d9c1ce2f9682e1cf00d460a3daaf03bf0e832a4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,65 @@ +0.1.0-alpha95 +============= + * Modularity + * Log module became switchable + * New switchable module TaxImportExport was created + * Sales module improvement: + * Performance was improved + * Complexity of the order persistence logic was reduced + * Unit tests coverage for modules was increased: + * Magento\Rule + * Magento\Contact + * Framework: + * Composite and bundle save/load processors were added + * Support for the complex custom attributes were added + * Generic abstract data objects, that is simple and extensible (supports custom attributes), were created  + * Search Library: + * Approach of matching the fields to table names was implemented + * MySQL Adapter Library for Match and Filtered query types was added + * Ability to filter queries was added + * Response handler for MySQL adapter was added + * XML declarations for full-text search were added + * Functional tests: + * Add Products to Order from Last Ordered Products Section + * Add Products to Order from Products in Comparison List Section + * Add Products to Order from Recently Compared Products Section + * Create Configurable Product + * Create Store + * Create Website + * Delete Product From Customer Wishlist On Backend + * Delete Store + * Delete Website + * Viewed Products Report + * Products In Cart Report + * Manage Product Review from Customer Page + * Mass Assign Customer Group + * New Account Report + * Update Product Review From Product Page + * Update Store + * Manage Product Review From Customer Page + * Other: + * Session.name ini set + * Calls to setPublicCookie became more secured + * Generating the session ID for sensitive data was added + *  Fixed bugs: + * Placing the order from backend + * Redirecting the customer to empty shopping cart instead of displaying credit card iFrame on checkout with for PayPal Payflow Link + * Showing the  message for multiple shipping address checkout in Authorize partial approval flow + * Mess detector failure + * flv_player security vulnerability + * Calling the inexistent method in cart with shopping cart price rules + * Overriding a non-empty custom attribute value with empty value in store view scope + * Editing  in 'WYSIWYG editor' by clicking "Use Default" checkbox when switched to store view scope + * RSS list page vulnerability + * Applying the store View title on frontend for configurable attributes + * Viewing the uploaded sample in downloadable product + * Google Shopping: Problem with publishing products if change value for option 'Update Google Shopping Item when Product is Updated' + * Configuration scope of items' InStock status on order cancellation + * Creating the new customer in admin + * GitHub requests: + * #621 -- Parse error: syntax error, unexpected T_OBJECT_OPERATOR + * #651 -- Multishipping checkout add/edit address page issue + 0.1.0-alpha94 ============= * Implemented API services: @@ -15,7 +77,7 @@ * Create Shopping Cart Gift Message service * Create Shopping Cart Totals service * Fixed bugs: - * Fixed an issue where selecting a shipping method in PayPal Express Checkout resulted in a fatal error + * Fixed an issue where selecting a shipping method in PayPal Express Checkout resulted in a fatal error * Fixed an issue where the information displayed on the Payment Information step of Zero Subtotal Checkout was confusing * Fixed a JavaScript error in shipping label * Fixed an issue with wrong layout of the storefront pages @@ -26,20 +88,20 @@ * Fixed an issue where taxes were not applied in the shopping cart after registering customer on the storefront * Fixed an issue where the wrong html markup was generated on My order pages for the WEEE tax * Fixed an issue where the built-in caching did not work on product pages - * Removed the stream resource usage to avoid errors when the allow_url_fopen PHP option is set to Off + * Removed the stream resource usage to avoid errors when the allow_url_fopen PHP option is set to Off * Fixed the New Return page layout on the backend - * Fixed an issue where it was impossible to apply a specific coupon code when the Apply to Shipping Amount option of the Shopping Cart Rule was set to Yes + * Fixed an issue where it was impossible to apply a specific coupon code when the Apply to Shipping Amount option of the Shopping Cart Rule was set to Yes * Removed file paths/content from test case names in data-driven tests - * Fixed an issue where pagination was absent in the Order Status grid + * Fixed an issue where pagination was absent in the Order Status grid * Fixed an issue where after applying a discount coupon and changing the currency the discount value was incorrect * Fixed an issue where trying to a new rating resulted in a fatal error * Fixed an issue where the minimum order amount was compared with subtotal without taxes * Fixed an issue where it was impossible to open the previous step during Onepage Checkout - * Fixed an issue with Persistent Shopping Cart where an unexpected message was displayed during checkout if a user started the checkout after the short-term cookie had expired + * Fixed an issue with Persistent Shopping Cart where an unexpected message was displayed during checkout if a user started the checkout after the short-term cookie had expired * Fixed an issue where a customer was redirected to the shopping cart after selecting shipping method during checkout with a payment method using 3D Secure * Fixed an issue where the Cart Item service used itemSku instead itemId * Fixed an issue where gift messages for individual items were not saved during backend order creation - * Fixed an issue where the Purchase Order Number input field was not displayed in Onepage Checkout if only one payment method was enabled + * Fixed an issue where the Purchase Order Number input field was not displayed in Onepage Checkout if only one payment method was enabled * GitHub requests: * [#446] (https://github.com/magento/magento2/issues/446) -- Rounding different in order to original quote calculation diff --git a/CONTRIBUTOR_LICENSE_AGREEMENT.html b/CONTRIBUTOR_LICENSE_AGREEMENT.html new file mode 100644 index 0000000000000000000000000000000000000000..58281b8e8aeabeb14a23cf30b43cb78872812e94 --- /dev/null +++ b/CONTRIBUTOR_LICENSE_AGREEMENT.html @@ -0,0 +1,131 @@ +<!DOCTYPE html> +<html> +<head> + <title>CONTRIBUTOR LICENSE AGREEMENT</title> + <style> + body { + font-size: 14px; + } + + ol { + counter-reset: list1; + font-family: Verdana, Arial, Helvetica, sans-serif; + padding-bottom: 12px; + } + li { + list-style-type: none; + padding-top: 12px; + } + ol li:before { + counter-increment: list1; + content: counter(list1) ". "; + } + ol ol { + counter-reset: list2; + } + ol ol li:before { + counter-increment: list2; + content: counter(list1) "." counter(list2) ". "; + } + h2 { + text-align: center; + font-family: Verdana, Arial, Helvetica, sans-serif; + } + p { + font-family: Verdana, Arial, Helvetica, sans-serif; + } + div { + width: 800px; + margin: 0 auto; + } + </style> +</head> +<body> +<div> +<h2> + CONTRIBUTOR LICENSE AGREEMENT +</h2> +<p> + This Contributor License Agreement ("Agreement") is made and entered into as of _______________, 20__ (the "Effective Date"), by and between X.commerce, Inc. dba Magento, Inc., a Delaware corporation with its principal place of business at 10441 Jefferson Blvd., Suite 200, Culver City, CA 90232 ("Magento", "we", "us", or "our"), and ______________________________, a _______________ with its principal place of business at _______________________________________ ("Contributor", "you" or "your", and collectively with Magento, the "Parties"). +</p> +<ol> + <li><strong><u>Definitions:</u></strong> + <ol> + <li> + <strong>"Contribution"</strong> means any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Magento for inclusion in, or documentation of, any of the products or services owned or managed by Magento (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication provided to Magento or its representatives, including, but not limited to, communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Magento for the purpose of discussing, modifying, revising, and improving the Work, including identification of errors and/or issues and the remedy thereof. + </li> + <li> + <strong>"Contributor"</strong>, <strong>"you"</strong>, or <strong>"your"</strong> means the copyright owner or legal entity authorized by the copyright owner that is entering into this Agreement. + </li> + <li> + <strong>"Contributor Affiliate"</strong> means any past, present or future subsidiary, parent company, sister company, or other corporation, firm, business, partnership, joint venture or entity that controls, is controlled by, or is under common control of Contributor or any of its subsidiaries. + </li> + <li> + <strong>"Control"</strong> means (i) the power, direct or indirect, to cause the direction or management of an entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares of an entity, or (iii) beneficial ownership of an entity. + </li> + <li> + <strong>"Magento Affiliate"</strong> means any past, present or future subsidiary, parent company, sister company, or other corporation, firm, business, partnership, joint venture or entity that controls, is controlled by, or is under common control of Magento or any of its subsidiaries. + </li> + </ol> + </li> + <li><strong><u>License Grants:</u></strong> + <ol> + <li><strong>Grant of Copyright License.</strong> Subject to the terms and conditions of this Agreement, Contributor and Contributor Affiliates hereby grant to Magento, Magento Affiliates and all third party recipients of software, services, and all other information distributed by Magento as part of any Magento project, product or service a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Contributions and such derivative works.</li> + <li><strong>Grant of Patent License.</strong> Subject to the terms and conditions of this Agreement, Contributor and Contributor Affiliates hereby grant to Magento, Magento Affiliates, and all third party recipients of software, services, and information distributed by Magento as part of any Magento project, product or service a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Contributions, where such license applies only to those patent claims licensable by Contributor that are necessarily infringed by Contributions alone or by combination with software and/or information related to any Magento project, product or service.</li> + <li><strong>Grant to Magento and Magento Affiliates.</strong> The rights conferred in this Agreement on Magento shall automatically and immediately extend to any entity that later becomes a Magento Affiliate or a part of Magento.</li> + <li><strong>Contributions.</strong> Contributor agrees to the terms and conditions of this Agreement for present and future Contributions, which Contributor submits to Magento. Except for the licenses granted herein, Contributor reserves all right, title, and interest in and to Contributor Contributions.</li> + </ol> + </li> + <li> + <strong><u>Representations:</u></strong> + <ol> + <li><strong>Original Work.</strong> Contributor represents that each Contribution is Contributor’s own original creation and that Contributor is the copyright owner or legal entity authorized by the copyright owner of all Contributions.</li> + <li><strong>Ownership and Authority.</strong> Contributor represents that it is legally entitled to grant the licenses above and that the Contributions do not include any third party copyrights, patents, trade secrets, licenses, or other restrictions ("Third Party IP"), and that Contributor will not declare any dependencies on any open source projects, proprietary software or Third Party IP, unless Contributor has made a Complete Disclosure prior to or at the time of the Contribution submission.</li> + <li><strong>Complete Disclosure.</strong> If applicable, Contributor represents that each and every Contribution submission includes complete details of any third-party license or other restrictions associated with any part of the Contribution.</li> + <li><strong>Support.</strong> Contributor is not expected to provide support for Contributions, except to the extent Contributor desires to provide support. Contributor may provide support for free, for a fee, or not at all.</li> + <li><strong>Notification of any Change.</strong> You agree to notify Magento if any of the facts, circumstances or representations made herein are or become inaccurate in any respect.</li> + </ol> + </li> + <li> + <strong><u>General:</u></strong> + <ol> + <li><strong>Waiver.</strong> Contributor waives all other claims of any nature, including express contract, implied-in-fact contract, or quasi-contract, arising out of any disclosure of the Contributions to Magento. As such, Magento is under no obligation to use or implement the Contributions in any respect.</li> + <li><strong>Competitive or Similar Materials.</strong> In no event shall Magento or Magento Affiliates be precluded from discussing, reviewing, developing for itself, having developed, or developing for third parties, materials which are competitive with those set forth in the Contributions irrespective of their similarity to the information in the Contributions, so long as Magento complies with the terms of this Agreement.</li> + <li><strong>Term.</strong> This Agreement shall remain in effect for a period of five (5) years from the Effective Date or until termination in writing by either party is delivered to the other party.</li> + <li><strong>Governing Law.</strong> This Agreement will be construed as if both parties jointly wrote it, governed by California law except for its conflicts of laws principles, and any cause of action arising under or relating to this Agreement must be brought exclusively in a court in Santa Clara County, California. </li> + <li><strong>Survival.</strong> Upon termination or expiration of this Agreement, all terms of the Agreement, including the license grants, shall remain in full force and effect, except that Contributor will no longer make submissions to Magento.</li> + </ol> + </li> +</ol> +<p><strong>IN WITNESS WHEREOF,</strong> the Parties have caused this Agreement to be executed by their duly authorized representatives as of the Effective Date.</p> +<table border="0" width="100%"> + <tr> + <td width="9%"><strong>Magento, Inc.</strong></td> + <td width="15%"></td> + <td width="6%"></td> + <td width="9%"></td> + <td width="15%"><strong>Contributor</strong><br> + </tr> + <tr> + <td>By:</td> + <td><hr></td> + <td></td> + <td>By:</td> + <td><hr></td> + </tr> + <td>Name:</td> + <td><hr></td> + <td></td> + <td>Name:</td> + <td><hr></td> + </tr> + <tr> + <td>Title:</td> + <td><hr></td> + <td></td> + <td>Title:</td> + <td><hr></td> +</table> +</div> +</body> +</html> \ No newline at end of file diff --git a/app/autoload.php b/app/autoload.php index 073340091ce7a5b81df26b20efd01a702767ddfd..0f6e9f7060f783bb2413b7f1dcfab68b3d11cd09 100644 --- a/app/autoload.php +++ b/app/autoload.php @@ -23,10 +23,25 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -$vendorDir = require __DIR__ . '/etc/vendor_path.php'; -$vendorAutoload = __DIR__ . '/../' . $vendorDir . '/autoload.php'; + +/** + * Shortcut constant for the root directory + */ +define('BP', dirname(__DIR__)); + +$vendorDir = require BP . '/app/etc/vendor_path.php'; +$vendorAutoload = BP . "/{$vendorDir}/autoload.php"; if (file_exists($vendorAutoload)) { require_once $vendorAutoload; } -require_once __DIR__ . '/../lib/internal/Magento/Framework/Autoload/IncludePath.php'; -spl_autoload_register([new \Magento\Framework\Autoload\IncludePath(), 'load']); +require_once BP . '/lib/internal/Magento/Framework/Autoload/IncludePath.php'; +$includePath = new \Magento\Framework\Autoload\IncludePath(); +$includePath->addIncludePath([BP . '/app/code', BP . '/lib/internal']); +spl_autoload_register([$includePath, 'load']); +$classMapPath = BP . '/var/classmap.ser'; +if (file_exists($classMapPath)) { + require_once BP . '/lib/internal/Magento/Framework/Autoload/ClassMap.php'; + $classMap = new \Magento\Framework\Autoload\ClassMap(BP); + $classMap->addMap(unserialize(file_get_contents($classMapPath))); + spl_autoload_register(array($classMap, 'load'), true, true); +} diff --git a/app/bootstrap.php b/app/bootstrap.php index 31abb9bdfa5c7714917afc3533b81c23108d3ae5..58e02598d6f4305750dc0e246330ec79b3d30fbf 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -41,55 +41,16 @@ if (version_compare(phpversion(), '5.4.11', '<') === true) { Whoops, it looks like you have an invalid PHP version.</h3> </div> <p>Magento supports PHP 5.4.11 or newer. - <a href="http://www.magento.com/install" target="">Find out</a> - how to install Magento using PHP-CGI as a work-around. - </p> </div> HTML; } - exit; + exit(1); } -/**#@+ - * Shortcut constants - */ -define('BP', dirname(__DIR__)); -/**#@-*/ - -/** - * Require necessary files - */ -require_once BP . '/app/functions.php'; require_once __DIR__ . '/autoload.php'; -(new \Magento\Framework\Autoload\IncludePath())->addIncludePath(array(BP . '/app/code', BP . '/lib/internal')); -$classMapPath = BP . '/var/classmap.ser'; -if (file_exists($classMapPath)) { - require_once BP . '/lib/internal/Magento/Framework/Autoload/ClassMap.php'; - $classMap = new \Magento\Framework\Autoload\ClassMap(BP); - $classMap->addMap(unserialize(file_get_contents($classMapPath))); - spl_autoload_register(array($classMap, 'load'), true, true); -} - -if (!defined('BARE_BOOTSTRAP')) { - $maintenanceFlag = BP . '/' . \Magento\Framework\App\State\MaintenanceMode::FLAG_DIR . '/' - . \Magento\Framework\App\State\MaintenanceMode::FLAG_FILENAME; - if (file_exists($maintenanceFlag)) { - if (!in_array($_SERVER['REMOTE_ADDR'], explode(",", file_get_contents($maintenanceFlag)))) { - if (PHP_SAPI == 'cli') { - echo 'Service temporarily unavailable due to maintenance downtime.'; - } else { - include_once BP . '/pub/errors/503.php'; - } - exit; - } - } +require_once BP . '/app/functions.php'; - if (!empty($_SERVER['MAGE_PROFILER'])) { - \Magento\Framework\Profiler::applyConfig( - $_SERVER['MAGE_PROFILER'], - dirname(__DIR__), - !empty($_REQUEST['isAjax']) - ); - } +if (!empty($_SERVER['MAGE_PROFILER'])) { + \Magento\Framework\Profiler::applyConfig($_SERVER['MAGE_PROFILER'], BP, !empty($_REQUEST['isAjax'])); } date_default_timezone_set(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE); diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php index 92cc992a3b3a9bddd017ec22cbf45607ab9559a4..ebd9195faa87a4b73bbc69b46f69a7b0f2a87ee9 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php @@ -36,7 +36,7 @@ class Baseurl implements \Magento\Framework\Notification\MessageInterface protected $_config; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -47,13 +47,13 @@ class Baseurl implements \Magento\Framework\Notification\MessageInterface /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\Config\ValueFactory $configValueFactory ) { diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index 8207d4d7ec34d6af8ebc6b8382b07fa829aa2618..834fb0446dc02f1c8a6adbaa9d5cf48d33f4f560 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorization/Model/CompositeUserContext.php b/app/code/Magento/Authorization/Model/CompositeUserContext.php index 5707ac12a3252fd4ca86fcb0d3a4755a952d31d6..37e2df4f6a8668394dcd747ce2bd2cc956a0944e 100644 --- a/app/code/Magento/Authorization/Model/CompositeUserContext.php +++ b/app/code/Magento/Authorization/Model/CompositeUserContext.php @@ -24,6 +24,11 @@ namespace Magento\Authorization\Model; +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + +/** + * Composite user context (implements composite pattern). + */ class CompositeUserContext implements \Magento\Authorization\Model\UserContextInterface { /** @@ -39,19 +44,12 @@ class CompositeUserContext implements \Magento\Authorization\Model\UserContextIn /** * Register user contexts. * + * @param CompositeHelper $compositeHelper * @param UserContextInterface[] $userContexts */ - public function __construct($userContexts = []) + public function __construct(CompositeHelper $compositeHelper, $userContexts = []) { - $userContexts = array_filter( - $userContexts, - function ($item) { - return isset($item['type']) && isset($item['sortOrder']); - } - ); - - uasort($userContexts, array($this, 'compareContextsSortOrder')); - + $userContexts = $compositeHelper->filterAndSortDeclaredComponents($userContexts); foreach ($userContexts as $userContext) { $this->add($userContext['type']); } @@ -106,24 +104,4 @@ class CompositeUserContext implements \Magento\Authorization\Model\UserContextIn } return $this->chosenUserContext; } - - /** - * Compare contexts sortOrder - * - * @param array $contextDataFirst - * @param array $contextDataSecond - * @return int - */ - protected function compareContextsSortOrder($contextDataFirst, $contextDataSecond) - { - if ((int)$contextDataFirst['sortOrder'] == (int)$contextDataSecond['sortOrder']) { - return 0; - } - - if ((int)$contextDataFirst['sortOrder'] < (int)$contextDataSecond['sortOrder']) { - return -1; - } else { - return 1; - } - } } diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json index 3079bd2c3b37e1bb0b10fd8da648c786889a5c28..7df60980708565a5d2eb00b4ee31491064ab9b73 100644 --- a/app/code/Magento/Authorization/composer.json +++ b/app/code/Magento/Authorization/composer.json @@ -3,12 +3,12 @@ "description": "Authorization module provides access to Magento ACL functionality.", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorizenet/Helper/Backend.php b/app/code/Magento/Authorizenet/Helper/Backend.php index fc0d11dc938e5d3cfb4522ebcfdc01d596e0e308..546c7fe8edfe337049cb6fa568f8f88ac2967424 100644 --- a/app/code/Magento/Authorizenet/Helper/Backend.php +++ b/app/code/Magento/Authorizenet/Helper/Backend.php @@ -30,13 +30,13 @@ class Backend extends Data { /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Backend\Model\UrlInterface $backendUrl */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Backend\Model\UrlInterface $backendUrl ) { diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php index 0398481a245a2d458fb636a6fdafabacd3ac3705..3ca32c1028d236bfafaf5d59828ec595fa93486d 100644 --- a/app/code/Magento/Authorizenet/Helper/Data.php +++ b/app/code/Magento/Authorizenet/Helper/Data.php @@ -29,7 +29,7 @@ namespace Magento\Authorizenet\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper implements HelperInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -40,12 +40,12 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper implements Helpe /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\OrderFactory $orderFactory */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\OrderFactory $orderFactory ) { parent::__construct($context); diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php index df8c1202f6eb2bba07c063299b8ada7f149c773e..599e5b3a3edebd9205a09a4cb5b7274923329de7 100644 --- a/app/code/Magento/Authorizenet/Model/Authorizenet.php +++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php @@ -1322,7 +1322,7 @@ class Authorizenet extends \Magento\Payment\Model\Method\Cc $this->_clearAssignedData($quotePayment); $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_LAST_SUCCESS); $quotePayment->setAdditionalInformation($orderPayment->getAdditionalInformation()); - $exceptionMessage = null; + $exceptionMessage = $this->_wrapGatewayError($response->getResponseReasonText()); break; case self::RESPONSE_CODE_DECLINED: case self::RESPONSE_CODE_ERROR: diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index 9d3f76530f6b2cac54969c671b038efa031ba1a8..0d0088aa172a57334268933b224c28549f8d8579 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -73,7 +73,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet /**#@-*/ /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -112,7 +112,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Authorizenet\Helper\Data $authorizenetData - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory * @param \Magento\Authorizenet\Model\Directpost\Response $response @@ -137,7 +137,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Authorizenet\Helper\Data $authorizenetData, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory, \Magento\Authorizenet\Model\Directpost\Response $response, diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Observer.php b/app/code/Magento/Authorizenet/Model/Directpost/Observer.php index 06820ffd10b8d52a759283e60621f92046a711b4..8c82e7dd088d5c6b3c00ef44fd6ae52cbd15456d 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost/Observer.php +++ b/app/code/Magento/Authorizenet/Model/Directpost/Observer.php @@ -62,7 +62,7 @@ class Observer protected $_session; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -72,7 +72,7 @@ class Observer * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Authorizenet\Model\Directpost $payment * @param \Magento\Authorizenet\Model\Directpost\Session $session - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Authorizenet\Helper\Data $authorizenetData, @@ -80,7 +80,7 @@ class Observer \Magento\Framework\Registry $coreRegistry, \Magento\Authorizenet\Model\Directpost $payment, \Magento\Authorizenet\Model\Directpost\Session $session, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_coreRegistry = $coreRegistry; $this->_authorizenetData = $authorizenetData; diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Session.php b/app/code/Magento/Authorizenet/Model/Directpost/Session.php index 06709106c962420c2e2800d43ae9245a7c9c646a..97e56477acc32a95402010a3657fb90c36483d45 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost/Session.php +++ b/app/code/Magento/Authorizenet/Model/Directpost/Session.php @@ -37,7 +37,6 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\Session\StorageInterface $storage * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory - * @param string|null $sessionName * @internal param array $data */ public function __construct( @@ -48,8 +47,7 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Session\ValidatorInterface $validator, \Magento\Framework\Session\StorageInterface $storage, \Magento\Framework\Stdlib\CookieManager $cookieManager, - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - $sessionName = null + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory ) { parent::__construct( $request, @@ -61,7 +59,7 @@ class Session extends \Magento\Framework\Session\SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start($sessionName); + $this->start(); } /** diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json index 7c1b5596205a01ee2b28b4b898d7c7ce686a6b88..d782df28e00dc1230a3c761a5fb31c3e320386c5 100644 --- a/app/code/Magento/Authorizenet/composer.json +++ b/app/code/Magento/Authorizenet/composer.json @@ -3,19 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-centinel": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-centinel": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorizenet/etc/adminhtml/di.xml b/app/code/Magento/Authorizenet/etc/adminhtml/di.xml index 472bd1217608f6ad6ccc40bf35d33aeb35d6b452..c5f39c034f11395a95d5fbc969bfe789be2c4d6e 100644 --- a/app/code/Magento/Authorizenet/etc/adminhtml/di.xml +++ b/app/code/Magento/Authorizenet/etc/adminhtml/di.xml @@ -25,11 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Authorizenet\Helper\HelperInterface" type="Magento\Authorizenet\Helper\Backend" /> - <type name="Magento\Authorizenet\Model\Directpost\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Authorizenet\Model\Directpost"> <arguments> <argument name="session" xsi:type="object">Magento\Backend\Model\Session\Quote</argument> diff --git a/app/code/Magento/Authorizenet/etc/frontend/di.xml b/app/code/Magento/Authorizenet/etc/frontend/di.xml index 59240f40d34a002e14ffc977361a709c8f42d836..dd00831ba939d6976ea263638782786c30ec5a5d 100644 --- a/app/code/Magento/Authorizenet/etc/frontend/di.xml +++ b/app/code/Magento/Authorizenet/etc/frontend/di.xml @@ -25,11 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Authorizenet\Helper\HelperInterface" type="Magento\Authorizenet\Helper\Data" /> - <type name="Magento\Authorizenet\Model\Directpost\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Authorizenet\Model\Directpost"> <arguments> <argument name="session" xsi:type="object">Magento\Checkout\Model\Session</argument> diff --git a/app/code/Magento/Authorizenet/etc/module.xml b/app/code/Magento/Authorizenet/etc/module.xml index 8febaa01797d8408c3fae45b03da5457c93834c6..4315ec971432159b1808eeb8e18c8a977b9c301b 100644 --- a/app/code/Magento/Authorizenet/etc/module.xml +++ b/app/code/Magento/Authorizenet/etc/module.xml @@ -30,7 +30,6 @@ <module name="Magento_Checkout"/> </sequence> <depends> - <module name="Magento_Store"/> <module name="Magento_Sales"/> <module name="Magento_Checkout"/> <module name="Magento_Backend"/> diff --git a/app/code/Magento/Backend/AdminConfig.php b/app/code/Magento/Backend/AdminConfig.php index 01c298023082f5c83832e4e6d3184a9bb95475e0..691cbb9d72ab94cb18704f2bafb28572dd72c0d7 100644 --- a/app/code/Magento/Backend/AdminConfig.php +++ b/app/code/Magento/Backend/AdminConfig.php @@ -35,6 +35,11 @@ use Magento\Framework\Session\Config; */ class AdminConfig extends Config { + /** + * Configuration for admin session name + */ + const SESSION_NAME_ADMIN = 'admin'; + /** * @var FrontNameResolver $frontNameResolver */ @@ -44,7 +49,6 @@ class AdminConfig extends Config * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Stdlib\String $stringHelper * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\Filesystem $filesystem * @param string $scopeType * @param FrontNameResolver $frontNameResolver @@ -52,26 +56,26 @@ class AdminConfig extends Config * @param null|string $savePath * @param null|string $cacheLimiter * @param string $lifetimePath + * @param string $sessionName * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\String $stringHelper, \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\App\State $appState, \Magento\Framework\App\Filesystem $filesystem, $scopeType, FrontNameResolver $frontNameResolver, $saveMethod = \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, $savePath = null, $cacheLimiter = null, - $lifetimePath = self::XML_PATH_COOKIE_LIFETIME + $lifetimePath = self::XML_PATH_COOKIE_LIFETIME, + $sessionName = self::SESSION_NAME_ADMIN ) { parent::__construct( $scopeConfig, $stringHelper, $request, - $appState, $filesystem, $scopeType, $saveMethod, @@ -85,6 +89,7 @@ class AdminConfig extends Config $baseUrl = $this->_httpRequest->getBaseUrl(); $adminPath = $this->extractAdminPath($baseUrl); $this->setCookiePath($adminPath); + $this->setName($sessionName); } /** diff --git a/app/code/Magento/Backend/App/Router.php b/app/code/Magento/Backend/App/Router.php index 23f19e5c6733497ab9506de934cbee87a592bf44..cf3f08516a7067282408b183f31a4936b665bab7 100644 --- a/app/code/Magento/Backend/App/Router.php +++ b/app/code/Magento/Backend/App/Router.php @@ -70,15 +70,14 @@ class Router extends \Magento\Core\App\Router\Base * @param \Magento\Framework\App\DefaultPathInterface $defaultPath * @param \Magento\Framework\App\ResponseFactory $responseFactory * @param \Magento\Framework\App\Route\ConfigInterface $routeConfig - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo * @param string $routerId + * @param \Magento\Framework\Code\NameBuilder $nameBuilder * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig * @param \Magento\Backend\App\ConfigInterface $backendConfig - * @param \Magento\Framework\Code\NameBuilder $nameBuilder * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -88,9 +87,8 @@ class Router extends \Magento\Core\App\Router\Base \Magento\Framework\App\DefaultPathInterface $defaultPath, \Magento\Framework\App\ResponseFactory $responseFactory, \Magento\Framework\App\Route\ConfigInterface $routeConfig, - \Magento\Framework\App\State $appState, \Magento\Framework\UrlInterface $url, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo, $routerId, @@ -104,7 +102,6 @@ class Router extends \Magento\Core\App\Router\Base $defaultPath, $responseFactory, $routeConfig, - $appState, $url, $storeManager, $scopeConfig, diff --git a/app/code/Magento/Backend/Block/Template/Context.php b/app/code/Magento/Backend/Block/Template/Context.php index f28b2f8a0a607dcb31f6ee03e5ff06656106520e..70680f30e22c624d7b79201fba9cbea215960ed1 100644 --- a/app/code/Magento/Backend/Block/Template/Context.php +++ b/app/code/Magento/Backend/Block/Template/Context.php @@ -79,7 +79,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context * @param \Magento\Framework\View\FileSystem $viewFileSystem * @param \Magento\Framework\View\TemplateEnginePool $enginePool * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\AuthorizationInterface $authorization * @param \Magento\Backend\Model\Session $backendSession * @param \Magento\Framework\Math\Random $mathRandom @@ -111,7 +111,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\View\TemplateEnginePool $enginePool, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\AuthorizationInterface $authorization, \Magento\Backend\Model\Session $backendSession, \Magento\Framework\Math\Random $mathRandom, @@ -153,7 +153,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context /** * Get store manager * - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface */ public function getStoreManager() { diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php index daff04fcf5b40424a09e4673d47b590db778fd25..ed612197dab41bda59b47fb4097ae0a71c88d31a 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php @@ -169,7 +169,7 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form * Get catalog entity associated stores * * @return array - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\Model\Exception */ protected function _getEntityStores() { @@ -188,7 +188,7 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form } // @codingStandardsIgnoreStart if (!$entityStores) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\Model\Exception( __( 'We can\'t set up a URL rewrite because the product you chose is not associated with a website.' ) @@ -198,7 +198,7 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form } elseif ($category->getId()) { $entityStores = (array)$category->getStoreIds(); if (!$entityStores) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\Model\Exception( __( 'We can\'t set up a URL rewrite because the category your chose is not associated with a website.' ) diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php index bf68ff4a064c7b81501335c66243c3ce7f4c3f8b..ad42ead070c39b3de0b4544d0d14ed53ffd35452 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php @@ -138,7 +138,7 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form * Get catalog entity associated stores * * @return array - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\Model\Exception */ protected function _getEntityStores() { @@ -151,8 +151,8 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form $this->_requireStoresFilter = !in_array(0, $entityStores); if (!$entityStores) { - throw new \Magento\Store\Model\Exception( - __('Chosen cms page does not associated with any website.') + throw new \Magento\Framework\Model\Exception( + __('Chosen cms page is not associated with any website.') ); } } diff --git a/app/code/Magento/Backend/Block/Widget/Context.php b/app/code/Magento/Backend/Block/Widget/Context.php index f5a65b938eafc21dceedde7c40461e78faeb8671..8ffce8ce30721d3c715e1a347d379021e45f8d09 100644 --- a/app/code/Magento/Backend/Block/Widget/Context.php +++ b/app/code/Magento/Backend/Block/Widget/Context.php @@ -62,7 +62,7 @@ class Context extends \Magento\Backend\Block\Template\Context * @param \Magento\Framework\View\FileSystem $viewFileSystem * @param \Magento\Framework\View\TemplateEnginePool $enginePool * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\AuthorizationInterface $authorization * @param \Magento\Backend\Model\Session $backendSession * @param \Magento\Framework\Math\Random $mathRandom @@ -96,7 +96,7 @@ class Context extends \Magento\Backend\Block\Template\Context \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\View\TemplateEnginePool $enginePool, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\AuthorizationInterface $authorization, \Magento\Backend\Model\Session $backendSession, \Magento\Framework\Math\Random $mathRandom, diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php index d2bf0763a08335035ceae65254fd7f2545c558d1..cc8125c5b7177a1d76d22a57bf5f38d7e9c465bf 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php @@ -45,7 +45,7 @@ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra /** * Application object * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -66,7 +66,7 @@ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency @@ -74,7 +74,7 @@ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, diff --git a/app/code/Magento/Backend/Helper/Dashboard/Data.php b/app/code/Magento/Backend/Helper/Dashboard/Data.php index 5123be8a4c50602e556d53ad34159297e958a48e..83e1283e64568f000aafa3701ac03db45d874d4d 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Data.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Data.php @@ -41,7 +41,7 @@ class Data extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param string $installDate @@ -50,7 +50,7 @@ class Data extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, $installDate, diff --git a/app/code/Magento/Backend/Helper/Dashboard/Order.php b/app/code/Magento/Backend/Helper/Dashboard/Order.php index b19d829710950b9253fd04d48a0bf4a9804806d4..3ca2b183c40eb5acfdd7a1dc3cc1e546784d9295 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Order.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Order.php @@ -36,7 +36,7 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Reports\Model\Resource\Order\Collection $orderCollection @@ -45,7 +45,7 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Reports\Model\Resource\Order\Collection $orderCollection, diff --git a/app/code/Magento/Backend/Model/Config.php b/app/code/Magento/Backend/Model/Config.php index 4bf70b7a933d523b006ae5f969fe2b20adf3e23c..08a06b81626c6ac79ee3aaf29723ce636f115f62 100644 --- a/app/code/Magento/Backend/Model/Config.php +++ b/app/code/Magento/Backend/Model/Config.php @@ -88,7 +88,7 @@ class Config extends \Magento\Framework\Object protected $_configValueFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -99,7 +99,7 @@ class Config extends \Magento\Framework\Object * @param \Magento\Framework\DB\TransactionFactory $transactionFactory * @param \Magento\Backend\Model\Config\Loader $configLoader * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -109,7 +109,7 @@ class Config extends \Magento\Framework\Object \Magento\Framework\DB\TransactionFactory $transactionFactory, \Magento\Backend\Model\Config\Loader $configLoader, \Magento\Framework\App\Config\ValueFactory $configValueFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { parent::__construct($data); diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php index 9bbd7c296b8d4fc259912ed8fb9a288445ef7621..ec8c974e0094cc212f3f6c09f2d811f3fc05d2b5 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php @@ -50,7 +50,7 @@ class Observer protected $_response; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -66,7 +66,7 @@ class Observer \Magento\Framework\Registry $coreRegistry, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\App\ResponseInterface $response, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_backendData = $backendData; $this->_coreRegistry = $coreRegistry; diff --git a/app/code/Magento/Backend/Model/Config/Source/Website.php b/app/code/Magento/Backend/Model/Config/Source/Website.php index aed17b7c910ff37932f870cff3fd333ff823420b..530a9547486edfe19bd912e36b0ce2ae3fadb68c 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Website.php +++ b/app/code/Magento/Backend/Model/Config/Source/Website.php @@ -31,14 +31,14 @@ class Website implements \Magento\Framework\Option\ArrayInterface protected $_options; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php b/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php index a6598b0ed2b26e1a9a4583455e0b5f5062405ff8..a0c9740b012738cbbaeba92d393f84dad48bd405 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php +++ b/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php @@ -23,7 +23,7 @@ */ namespace Magento\Backend\Model\Config\Structure; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; abstract class AbstractElement implements ElementInterface { @@ -44,12 +44,12 @@ abstract class AbstractElement implements ElementInterface /** * Store manager * - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct(StoreManagerInterface $storeManager) { diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php b/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php index 4db887d81f67c0b7e49a23fdda4c51d91f014793..0c1e5f3ee45dc4dc1f82f7a1ff1c39b38fd467de 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php @@ -33,10 +33,10 @@ abstract class AbstractComposite extends \Magento\Backend\Model\Config\Structure protected $_childrenIterator; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Iterator $childrenIterator */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, Iterator $childrenIterator) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager, Iterator $childrenIterator) { parent::__construct($storeManager); $this->_childrenIterator = $childrenIterator; diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php index cfc5117accadb2c366bebf6b974c11dc7ade9adb..4928299a93456b90b804608b50916d7f7381669c 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php @@ -67,7 +67,7 @@ class Field extends \Magento\Backend\Model\Config\Structure\AbstractElement protected $_blockFactory; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\BackendFactory $backendFactory * @param \Magento\Backend\Model\Config\SourceFactory $sourceFactory * @param \Magento\Backend\Model\Config\CommentFactory $commentFactory @@ -75,7 +75,7 @@ class Field extends \Magento\Backend\Model\Config\Structure\AbstractElement * @param \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\BackendFactory $backendFactory, \Magento\Backend\Model\Config\SourceFactory $sourceFactory, \Magento\Backend\Model\Config\CommentFactory $commentFactory, diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php index c31d0f6aa330430f558a45f8e86935632c551f04..6149666c13214af2da9e01692458a891777e82ec 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php @@ -39,13 +39,13 @@ class Group extends AbstractComposite protected $_dependencyMapper; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\Structure\Element\Iterator\Field $childrenIterator * @param \Magento\Backend\Model\Config\BackendClone\Factory $cloneModelFactory * @param \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\Structure\Element\Iterator\Field $childrenIterator, \Magento\Backend\Model\Config\BackendClone\Factory $cloneModelFactory, \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php index 4cdf82e7c7bdf60b70fec8269a1da041cf1f1fa1..5f91efdb4c81e38993fcf3c3445a9a04ed102bdd 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php @@ -33,12 +33,12 @@ class Section extends AbstractComposite protected $_authorization; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Iterator $childrenIterator * @param \Magento\Framework\AuthorizationInterface $authorization */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, Iterator $childrenIterator, \Magento\Framework\AuthorizationInterface $authorization ) { diff --git a/app/code/Magento/Backend/Model/Session.php b/app/code/Magento/Backend/Model/Session.php index d36bb06c32d6bc380888e1b7789d845b945c6098..966400d471ac4474b33e5df5da1c1e0c71689f3b 100644 --- a/app/code/Magento/Backend/Model/Session.php +++ b/app/code/Magento/Backend/Model/Session.php @@ -57,7 +57,7 @@ class Session extends \Magento\Framework\Session\SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start('adminhtml'); + $this->start(); } /** diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php index 68d49ce4dbd7b6257a91aa411d23ed106069ee18..f6c246b1eec640a25e54bc0868ab0da34f065c43 100644 --- a/app/code/Magento/Backend/Model/Session/Quote.php +++ b/app/code/Magento/Backend/Model/Session/Quote.php @@ -79,7 +79,7 @@ class Quote extends \Magento\Framework\Session\SessionManager protected $_quoteFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -100,7 +100,7 @@ class Quote extends \Magento\Framework\Session\SessionManager * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerService * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( @@ -115,7 +115,7 @@ class Quote extends \Magento\Framework\Session\SessionManager \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerService, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $this->_quoteFactory = $quoteFactory; diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index 7078ff5ffb60eaaf38ec890ddbb5ee72037bd6cc..aab0a3ebd5fb667ad4fc6d3f2923f723a333b70f 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -3,32 +3,31 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/module-sendfriend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-weee": "0.1.0-alpha94", - "magento/module-reports": "0.1.0-alpha94", - "magento/module-catalog-search": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-user": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backup": "0.1.0-alpha94", - "magento/module-email": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-url-rewrite": "0.1.0-alpha94", - "magento/module-translation": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-weee": "0.1.0-alpha95", + "magento/module-reports": "0.1.0-alpha95", + "magento/module-catalog-search": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-user": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backup": "0.1.0-alpha95", + "magento/module-email": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-url-rewrite": "0.1.0-alpha95", + "magento/module-translation": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 09512c7ec5a636b14b9c66e51c2e38c511a96211..20b2078fd446ebc517a9389cc37f407dc95361a1 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -47,11 +47,6 @@ <argument name="backendUrl" xsi:type="object">Magento\Backend\Model\UrlInterface\Proxy</argument> </arguments> </type> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Backend\Model\Config\Structure\Element\Iterator\Tab" shared="false" /> <type name="Magento\Backend\Model\Config\Structure\Element\Iterator\Section" shared="false" /> <type name="Magento\Framework\View\Layout"> @@ -101,6 +96,7 @@ <type name="Magento\Backend\AdminConfig"> <arguments> <argument name="lifetimePath" xsi:type="const">Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME</argument> + <argument name="sessionName" xsi:type="const">Magento\Backend\AdminConfig::SESSION_NAME_ADMIN</argument> </arguments> </type> </config> diff --git a/app/code/Magento/Backend/etc/module.xml b/app/code/Magento/Backend/etc/module.xml index 1b15e3702c4933aa3de51e8ac5dbeea989b3bbd8..a51a0195441ed9e9004344d1a8810f0927158560 100644 --- a/app/code/Magento/Backend/etc/module.xml +++ b/app/code/Magento/Backend/etc/module.xml @@ -34,7 +34,6 @@ <module name="Magento_Core"/> <module name="Magento_Eav"/> <module name="Magento_Cron"/> - <module name="Magento_Sendfriend"/> <module name="Magento_Theme"/> <module name="Magento_Weee"/> <module name="Magento_Reports"/> diff --git a/app/code/Magento/Backup/Controller/Adminhtml/Index.php b/app/code/Magento/Backup/Controller/Adminhtml/Index.php index f0a921c5ac7053ab526973e5b4afd3c51cc93aae..dd0175f9df5aedd1e5212ffafbc7669ae04bae30 100644 --- a/app/code/Magento/Backup/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Backup/Controller/Adminhtml/Index.php @@ -53,7 +53,7 @@ class Index extends \Magento\Backend\App\Action protected $_backupModelFactory; /** - * @var \Magento\Framework\App\State\MaintenanceMode + * @var \Magento\Framework\App\MaintenanceMode */ protected $maintenanceMode; @@ -63,7 +63,7 @@ class Index extends \Magento\Backend\App\Action * @param \Magento\Framework\Backup\Factory $backupFactory * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory * @param \Magento\Backup\Model\BackupFactory $backupModelFactory - * @param \Magento\Framework\App\State\MaintenanceMode $maintenanceMode + * @param \Magento\Framework\App\MaintenanceMode $maintenanceMode */ public function __construct( \Magento\Backend\App\Action\Context $context, @@ -71,7 +71,7 @@ class Index extends \Magento\Backend\App\Action \Magento\Framework\Backup\Factory $backupFactory, \Magento\Framework\App\Response\Http\FileFactory $fileFactory, \Magento\Backup\Model\BackupFactory $backupModelFactory, - \Magento\Framework\App\State\MaintenanceMode $maintenanceMode + \Magento\Framework\App\MaintenanceMode $maintenanceMode ) { $this->_coreRegistry = $coreRegistry; $this->_backupFactory = $backupFactory; diff --git a/app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php b/app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php index 5472af57770aa52187577e89812a7fbcde039ac9..388baac9c82bf61bbf102eaf9ded920ba03c808e 100644 --- a/app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php +++ b/app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php @@ -69,7 +69,7 @@ class Create extends \Magento\Backup\Controller\Adminhtml\Index $this->_coreRegistry->register('backup_manager', $backupManager); if ($this->getRequest()->getParam('maintenance_mode')) { - if (!$this->maintenanceMode->turnOn()) { + if (!$this->maintenanceMode->set(true)) { $response->setError( __( 'You need more permissions to activate maintenance mode right now.' @@ -116,7 +116,7 @@ class Create extends \Magento\Backup\Controller\Adminhtml\Index } if ($this->getRequest()->getParam('maintenance_mode')) { - $this->maintenanceMode->turnOff(); + $this->maintenanceMode->set(false); } $this->getResponse()->representJson($response->toJson()); diff --git a/app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php b/app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php index fb0848da57ac66e3e64d6689202bc1b8f94a3d47..964bb7274b00b30dcfc89a69614800a5747e040c 100644 --- a/app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php +++ b/app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php @@ -91,7 +91,7 @@ class Rollback extends \Magento\Backup\Controller\Adminhtml\Index } if ($this->getRequest()->getParam('maintenance_mode')) { - if (!$this->maintenanceMode->turnOn()) { + if (!$this->maintenanceMode->set(true)) { $response->setError( __( 'You need more permissions to activate maintenance mode right now.' @@ -153,7 +153,7 @@ class Rollback extends \Magento\Backup\Controller\Adminhtml\Index } if ($this->getRequest()->getParam('maintenance_mode')) { - $this->maintenanceMode->turnOff(); + $this->maintenanceMode->set(false); } $this->getResponse()->representJson($response->toJson()); diff --git a/app/code/Magento/Backup/Helper/Data.php b/app/code/Magento/Backup/Helper/Data.php index faa0625d4794ac6d7fe9d2726b0c46d1c40c0fd3..eb046555cd9afe6bd95fbb082cfb85fb8bb18ffc 100644 --- a/app/code/Magento/Backup/Helper/Data.php +++ b/app/code/Magento/Backup/Helper/Data.php @@ -23,7 +23,7 @@ */ namespace Magento\Backup\Helper; -use Magento\Framework\App\State\MaintenanceMode; +use Magento\Framework\App\MaintenanceMode; /** * Backup data helper diff --git a/app/code/Magento/Backup/Model/Observer.php b/app/code/Magento/Backup/Model/Observer.php index afc884990cf8256c90ef4a923998595d3d5b0ac8..df14190b7182d16e1a0b2bd9886587aa2442fa33 100644 --- a/app/code/Magento/Backup/Model/Observer.php +++ b/app/code/Magento/Backup/Model/Observer.php @@ -85,7 +85,7 @@ class Observer protected $_backupFactory; /** - * @var \Magento\Framework\App\State\MaintenanceMode + * @var \Magento\Framework\App\MaintenanceMode */ protected $maintenanceMode; @@ -96,7 +96,7 @@ class Observer * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Framework\Backup\Factory $backupFactory - * @param \Magento\Framework\App\State\MaintenanceMode $maintenanceMode + * @param \Magento\Framework\App\MaintenanceMode $maintenanceMode */ public function __construct( \Magento\Backup\Helper\Data $backupData, @@ -105,7 +105,7 @@ class Observer \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Backup\Factory $backupFactory, - \Magento\Framework\App\State\MaintenanceMode $maintenanceMode + \Magento\Framework\App\MaintenanceMode $maintenanceMode ) { $this->_backupData = $backupData; $this->_coreRegistry = $coreRegistry; @@ -119,7 +119,7 @@ class Observer /** * Create Backup * - * @return \Magento\Log\Model\Cron + * @return $this */ public function scheduledBackup() { @@ -128,7 +128,7 @@ class Observer } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { - $this->maintenanceMode->turnOn(); + $this->maintenanceMode->set(true); } $type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE); @@ -166,7 +166,7 @@ class Observer } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { - $this->maintenanceMode->turnOff(); + $this->maintenanceMode->set(false); } return $this; diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index 59e9c5aa1b63f7d191cd6bdabaae512166634add..fc9af6761dfd6c0559ace8844836fae73ea72f9c 100644 --- a/app/code/Magento/Backup/composer.json +++ b/app/code/Magento/Backup/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Bundle/Model/Product/CatalogPrice.php b/app/code/Magento/Bundle/Model/Product/CatalogPrice.php index f46e4c428c2679b1d07ad6a38c958aae32256fec..ecfe19eea62032a7d67dd410aa1b60cd88b93109 100644 --- a/app/code/Magento/Bundle/Model/Product/CatalogPrice.php +++ b/app/code/Magento/Bundle/Model/Product/CatalogPrice.php @@ -29,7 +29,7 @@ namespace Magento\Bundle\Model\Product; class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -44,12 +44,12 @@ class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterfa protected $coreRegistry; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel * @param \Magento\Framework\Registry $coreRegistry */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel, \Magento\Framework\Registry $coreRegistry ) { diff --git a/app/code/Magento/Bundle/Model/Product/Price.php b/app/code/Magento/Bundle/Model/Product/Price.php index fa90ad6c36da838e9cfb1597ded587f5bbee7f69..d0cb54b895343f298d78a4d499ebf465f30b9a25 100644 --- a/app/code/Magento/Bundle/Model/Product/Price.php +++ b/app/code/Magento/Bundle/Model/Product/Price.php @@ -59,7 +59,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price * Construct * * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -67,7 +67,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price */ public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Event\ManagerInterface $eventManager, diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index a7a700fd32c5c201e20578e366b18d955b9fcb24..09d31b722ccedde183985740a770decdc5df5fbe 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -99,7 +99,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType protected $_catalogProduct = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -154,7 +154,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType * @param \Magento\Catalog\Model\Config $config * @param \Magento\Bundle\Model\Resource\Selection $bundleSelection * @param \Magento\Bundle\Model\OptionFactory $bundleOption - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -178,7 +178,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType \Magento\Catalog\Model\Config $config, \Magento\Bundle\Model\Resource\Selection $bundleSelection, \Magento\Bundle\Model\OptionFactory $bundleOption, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { $this->_catalogProduct = $catalogProduct; diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/Metadata.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Link.php similarity index 85% rename from app/code/Magento/Bundle/Service/V1/Data/Product/Link/Metadata.php rename to app/code/Magento/Bundle/Service/V1/Data/Product/Link.php index 139b1923d0aa09ca99aaaab0ae60ad2e17a3552b..f2742c824555808919ead58f0aab303010115b37 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/Metadata.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Link.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Bundle\Service\V1\Data\Product\Link; +namespace Magento\Bundle\Service\V1\Data\Product; use \Magento\Framework\Service\Data\AbstractExtensibleObject; /** * @codeCoverageIgnore */ -class Metadata extends AbstractExtensibleObject +class Link extends AbstractExtensibleObject { const SKU = 'sku'; @@ -36,6 +36,8 @@ class Metadata extends AbstractExtensibleObject const QTY = 'qty'; + const CAN_CHANGE_QUANTITY = 'can_change_qty'; + const POSITION = 'position'; const DEFINED = 'defined'; @@ -79,7 +81,7 @@ class Metadata extends AbstractExtensibleObject } /** - * @return bool + * @return bool|null */ public function isDefined() { @@ -109,4 +111,14 @@ class Metadata extends AbstractExtensibleObject { return $this->_get(self::PRICE_TYPE); } + + /** + * Get whether quantity could be changed + * + * @return int|null + */ + public function getCanChangeQuantity() + { + return $this->_get(self::CAN_CHANGE_QUANTITY); + } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/LinkBuilder.php similarity index 71% rename from app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataBuilder.php rename to app/code/Magento/Bundle/Service/V1/Data/Product/LinkBuilder.php index 7ee6d251622025ef0a20cf3f048afe7f30202983..1b57e7724e2f63b9d5d25bfbfdcf8b7d3dcd8f59 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataBuilder.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/LinkBuilder.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Bundle\Service\V1\Data\Product\Link; +namespace Magento\Bundle\Service\V1\Data\Product; use Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder; /** * @codeCoverageIgnore */ -class MetadataBuilder extends AbstractExtensibleObjectBuilder +class LinkBuilder extends AbstractExtensibleObjectBuilder { /** * @param string $value @@ -36,7 +36,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setSku($value) { - return $this->_set(Metadata::SKU, $value); + return $this->_set(Link::SKU, $value); } /** @@ -45,7 +45,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setQty($value) { - return $this->_set(Metadata::QTY, $value); + return $this->_set(Link::QTY, $value); } /** @@ -54,7 +54,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setPosition($value) { - return $this->_set(Metadata::POSITION, $value); + return $this->_set(Link::POSITION, $value); } /** @@ -63,7 +63,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setOptionId($value) { - return $this->_set(Metadata::OPTION_ID, $value); + return $this->_set(Link::OPTION_ID, $value); } /** @@ -72,7 +72,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setDefined($value) { - return $this->_set(Metadata::DEFINED, (bool)$value); + return $this->_set(Link::DEFINED, (bool)$value); } /** @@ -81,7 +81,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setDefault($value) { - return $this->_set(Metadata::IS_DEFAULT, (bool)$value); + return $this->_set(Link::IS_DEFAULT, (bool)$value); } /** @@ -90,7 +90,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setPrice($value) { - return $this->_set(Metadata::PRICE, $value); + return $this->_set(Link::PRICE, $value); } /** @@ -99,6 +99,17 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setPriceType($value) { - return $this->_set(Metadata::PRICE_TYPE, $value); + return $this->_set(Link::PRICE_TYPE, $value); + } + + /** + * Set can change quantity + * + * @param int $canChangeQuantity + * @return $this + */ + public function setCanChangeQuantity($canChangeQuantity) + { + return $this->_set(Link::CAN_CHANGE_QUANTITY, $canChangeQuantity); } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/LinkConverter.php similarity index 89% rename from app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataConverter.php rename to app/code/Magento/Bundle/Service/V1/Data/Product/LinkConverter.php index d62167d6aecfeac692ada141d9a28d23f408b3c5..a2a9d5353296a198e51ec41f197d9e816fb18560 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataConverter.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/LinkConverter.php @@ -22,24 +22,24 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Bundle\Service\V1\Data\Product\Link; +namespace Magento\Bundle\Service\V1\Data\Product; use Magento\Catalog\Model\Product; /** * @codeCoverageIgnore */ -class MetadataConverter +class LinkConverter { /** - * @var MetadataBuilder + * @var LinkBuilder */ private $builder; /** - * @param MetadataBuilder $builder + * @param LinkBuilder $builder */ - public function __construct(MetadataBuilder $builder) + public function __construct(LinkBuilder $builder) { $this->builder = $builder; } @@ -47,7 +47,7 @@ class MetadataConverter /** * @param Product $product * @param Product $bundle - * @return Metadata + * @return Link */ public function createDataFromModel(Product $product, Product $bundle) { diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php index ce87c215e49a93d7a1b05d831a943544e71f6b95..6dfe329e47cb818d039415f6d5dc5036d1bec9b0 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php @@ -42,6 +42,8 @@ class Option extends AbstractExtensibleObject const SKU = 'sku'; + const PRODUCT_LINKS = 'product_links'; + /** * Get option id * @@ -101,4 +103,14 @@ class Option extends AbstractExtensibleObject { return $this->_get(self::SKU); } + + /** + * Get product links + * + * @return \Magento\Bundle\Service\V1\Data\Product\Link[]|null + */ + public function getProductLinks() + { + return $this->_get(self::PRODUCT_LINKS); + } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php index 935a15a10a665124d824b9f99a510133827919ca..5247907144e6b163640348377ea94aa386a1b006 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php @@ -95,4 +95,15 @@ class OptionBuilder extends AbstractExtensibleObjectBuilder { return $this->_set(Option::SKU, $value); } + + /** + * Set product links + * + * @param \Magento\Bundle\Service\V1\Data\Product\Link[] $value + * @return $this + */ + public function setProductLinks($value) + { + return $this->_set(Option::PRODUCT_LINKS, $value); + } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php index b5de09c3576a2b308ffb01be052245518652585f..a2331544a8a658d5d9ffc7fa14eb272112972a0c 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php @@ -56,14 +56,16 @@ class OptionConverter /** * @param OptionModel $option * @param Product $product + * @param Link[] $productLinks * @return Option */ - public function createDataFromModel(OptionModel $option, Product $product) + public function createDataFromModel(OptionModel $option, Product $product, $productLinks = null) { $this->builder->populateWithArray($option->getData()) ->setId($option->getId()) ->setTitle(is_null($option->getTitle()) ? $option->getDefaultTitle() : $option->getTitle()) - ->setSku($product->getSku()); + ->setSku($product->getSku()) + ->setProductLinks($productLinks); return $this->builder->create(); } diff --git a/app/code/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessor.php b/app/code/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessor.php new file mode 100644 index 0000000000000000000000000000000000000000..c3ec9a8fe15e319104641a00e53203f9f1e53167 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessor.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Bundle\Service\V1\Product; + +use Magento\Bundle\Model\Option; +use Magento\Bundle\Service\V1\Product\Option\ReadService as OptionReadService; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Type as ProductType; +use Magento\Catalog\Model\ProductRepository; +use Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface; + +/** + * Add bundle product attributes to products during load. + */ +class BundleProductLoadProcessor implements ProductLoadProcessorInterface +{ + /** + * @var OptionReadService + */ + private $optionReadService; + + /** + * @var ProductRepository + */ + private $productRepository; + + /** + * @param OptionReadService $optionReadService + * @param ProductRepository $productRepository + */ + public function __construct( + OptionReadService $optionReadService, + ProductRepository $productRepository + ) { + $this->optionReadService = $optionReadService; + $this->productRepository = $productRepository; + } + + /** + * {@inheritdoc} + */ + public function load($id, \Magento\Catalog\Service\V1\Data\ProductBuilder $productBuilder) + { + /** @var \Magento\Catalog\Model\Product */ + $product = $this->productRepository->get($id); + if ($product->getTypeId() != ProductType::TYPE_BUNDLE) { + return; + } + + $productBuilder->setCustomAttribute( + 'bundle_product_options', + $this->optionReadService->getList($product->getSku()) + ); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessor.php b/app/code/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessor.php new file mode 100644 index 0000000000000000000000000000000000000000..0a5f6032a9b5947cc18c9aa5f323ca2c98c3b670 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessor.php @@ -0,0 +1,233 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Bundle\Service\V1\Product; + +use Magento\Bundle\Service\V1\Data\Product\Option; +use Magento\Bundle\Service\V1\Product\Option\ReadService as OptionReadService; +use Magento\Bundle\Service\V1\Product\Option\WriteService as OptionWriteService; +use Magento\Framework\Service\Data\Eav\AttributeValue; +use Magento\Catalog\Model\Product as ProductModel; +use Magento\Catalog\Model\ProductRepository; +use Magento\Catalog\Model\Product\Type as ProductType; +use Magento\Catalog\Service\V1\Data\Product; +use Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface; + +/** + * Class to save bundle products + */ +class BundleProductSaveProcessor implements ProductSaveProcessorInterface +{ + /** + * @var OptionWriteService + */ + private $optionWriteService; + + /** + * @var OptionReadService + */ + private $optionReadService; + + /** + * @var ProductRepository + */ + private $productRepository; + + /** + * Initialize dependencies. + * + * @param OptionWriteService $optionWriteService + * @param OptionReadService $optionReadService + * @param ProductRepository $productRepository + */ + public function __construct( + OptionWriteService $optionWriteService, + OptionReadService $optionReadService, + ProductRepository $productRepository + ) { + $this->optionWriteService = $optionWriteService; + $this->optionReadService = $optionReadService; + $this->productRepository = $productRepository; + } + + /** + * Process bundle-related attributes of product during its creation. + * + * @param ProductModel $product + * @param Product $productData + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @return string + */ + public function create(ProductModel $product, Product $productData) + { + return $product->getSku(); + } + + /** + * Process bundle-related attributes of product after its creation. + * + * @param ProductModel $product + * @param Product $productData + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @return string + */ + public function afterCreate(ProductModel $product, Product $productData) + { + /** @var string $productSku */ + $productSku = $product->getSku(); + + if ($product->getTypeId() != ProductType::TYPE_BUNDLE) { + return $productSku; + } + + /** @var Option[] $bundleProductOptions */ + + /* @var AttributeValue $bundleProductOptionsAttrValue */ + $bundleProductOptionsAttrValue = $productData->getCustomAttribute('bundle_product_options'); + if (is_null($bundleProductOptionsAttrValue) || !is_array($bundleProductOptionsAttrValue->getValue())) { + $bundleProductOptions = array(); + } else { + $bundleProductOptions = $bundleProductOptionsAttrValue->getValue(); + } + + if (is_array($bundleProductOptions)) { + foreach ($bundleProductOptions as $option) { + $this->optionWriteService->add($productSku, $option); + } + } + + return $productSku; + } + + /** + * Update bundle-related attributes of product. + * + * @param string $sku + * @param Product $updatedProduct + * @return string + */ + public function update($sku, Product $updatedProduct) + { + /** + * @var Product $existingProduct + */ + $existingProduct = $this->productRepository->get($sku, true); + + if ($existingProduct->getTypeId() != ProductType::TYPE_BUNDLE) { + return $sku; + } + + /** + * @var Option[] $existingProductOptions + */ + $existingProductOptions = $this->optionReadService->getList($sku); + /** + * @var Option[] $newProductOptions + */ + /** + * @var AttributeValue $newProductOptionsAttrValue + */ + $newProductOptionsAttrValue = $updatedProduct->getCustomAttribute('bundle_product_options'); + if (is_null($newProductOptionsAttrValue) || !is_array($newProductOptionsAttrValue->getValue())) { + $newProductOptions = array(); + } else { + $newProductOptions = $newProductOptionsAttrValue->getValue(); + } + /** + * @var Option[] $optionsToDelete + */ + $optionsToDelete = array_udiff($existingProductOptions, $newProductOptions, array($this, 'compareOptions')); + foreach ($optionsToDelete as $option) { + $this->optionWriteService->remove($sku, $option->getId()); + } + /** @var Option[] $optionsToUpdate */ + $optionsToUpdate = array_uintersect( + $existingProductOptions, + $newProductOptions, + array($this, 'compareOptions') + ); + foreach ($optionsToUpdate as $option) { + $this->optionWriteService->update($sku, $option->getId(), $option); + } + /** + * @var Option[] $optionsToAdd + */ + $optionsToAdd = array_udiff($newProductOptions, $existingProductOptions, array($this, 'compareOptions')); + foreach ($optionsToAdd as $option) { + $this->optionWriteService->add($sku, $option); + } + + return $sku; + } + + /** + * Delete bundle-related attributes of product. + * + * @param Product $product + * @return void + */ + public function delete(Product $product) + { + if ($product->getTypeId() != ProductType::TYPE_BUNDLE) { + return; + } + + /** + * @var string $productSku + */ + $productSku = $product->getSku(); + + /** + * @var Option[] $bundleProductOptions + */ + /** + * @var AttributeValue $bundleProductOptionsAttrValue + */ + $bundleProductOptionsAttrValue = $product->getCustomAttribute('bundle_product_options'); + if (is_null($bundleProductOptionsAttrValue) || !is_array($bundleProductOptionsAttrValue->getValue())) { + $bundleProductOptions = array(); + } else { + $bundleProductOptions = $bundleProductOptionsAttrValue->getValue(); + } + foreach ($bundleProductOptions as $option) { + $this->optionWriteService->remove($productSku, $option->getId()); + } + } + + /** + * Compare two options and determine if they are equal + * + * @param Option $firstOption + * @param Option $secondOption + * @return int + */ + private function compareOptions(Option $firstOption, Option $secondOption) + { + if ($firstOption->getId() == $secondOption->getId()) { + return 0; + } else { + return 1; + } + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php b/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php deleted file mode 100644 index bc5385b65204ff2f1ec870874faa13acfb9a5538..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Bundle\Service\V1\Product\Link\Data; - -/** - * Bundle ProductLink Service Data Object - * - * @codeCoverageIgnore - */ -class ProductLink extends \Magento\Framework\Service\Data\AbstractExtensibleObject -{ - /** - * Constants for Data Object keys - */ - const SKU = 'product_sku'; - const POSITION = 'position'; - const IS_DEFAULT = 'default'; - const PRICE_TYPE = 'slection_price_type'; - const PRICE_VALUE = 'slection_price_value'; - const QUANTITY = 'selection_qty'; - const CAN_CHANGE_QUANTITY = 'selection_can_change_qty'; - - /** - * Get product sku - * - * @return string - */ - public function getSku() - { - return $this->_get(self::SKU); - } - - /** - * Get product position - * - * @return int - */ - public function getPosition() - { - return $this->_get(self::POSITION); - } - - /** - * @return boolean - */ - public function isDefault() - { - return $this->_get(self::IS_DEFAULT); - } - - /** - * Get price type - * - * @return int - */ - public function getPriceType() - { - return $this->_get(self::PRICE_TYPE); - } - - /** - * Get price value - * - * @return float - */ - public function getPriceValue() - { - return $this->_get(self::PRICE_VALUE); - } - - /** - * Get quantity - * - * @return int - */ - public function getQuantity() - { - return $this->_get(self::QUANTITY); - } - - /** - * Get whether quantity could be changed - * - * @return int - */ - public function getCanChangeQuantity() - { - return $this->_get(self::CAN_CHANGE_QUANTITY); - } -} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php b/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php deleted file mode 100644 index 9081c04761b6f0c16973833b3a799de749267605..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php +++ /dev/null @@ -1,144 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Bundle\Service\V1\Product\Link\Data; - -use Magento\Framework\Service\Data\AttributeValueBuilder; - -/** - * Builder for the ProductLink Service Data Object - * - * @method ProductLink create() - * @codeCoverageIgnore - */ -class ProductLinkBuilder extends \Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder -{ - /** - * @var array - */ - protected $customAttributes = []; - - /** - * @param \Magento\Framework\Service\Data\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder - * @param \Magento\Framework\Service\Config\MetadataConfig $metadataService - * @param array $customAttributesCodes - */ - public function __construct( - \Magento\Framework\Service\Data\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, - \Magento\Framework\Service\Config\MetadataConfig $metadataService, - array $customAttributesCodes = array() - ) { - $this->customAttributes = $customAttributesCodes; - parent::__construct($objectFactory, $valueBuilder, $metadataService); - } - - /** - * Set product sku - * - * @param string $sku - * @return $this - */ - public function setSku($sku) - { - return $this->_set(ProductLink::SKU, $sku); - } - - /** - * Set product position - * - * @param int $position - * @return $this - */ - public function setPosition($position) - { - return $this->_set(ProductLink::POSITION, $position); - } - - /** - * Get custom attributes codes - * - * @return string[] - */ - public function getCustomAttributesCodes() - { - return array_merge(parent::getCustomAttributesCodes(), $this->customAttributes); - } - - /** - * Set is default - * - * @param boolean $default - * @return $this - */ - public function setDefault($default) - { - return $this->_set(ProductLink::IS_DEFAULT, $default); - } - - /** - * Set price type - * - * @param int $priceType - * @return $this - */ - public function setPriceType($priceType) - { - return $this->_set(ProductLink::PRICE_TYPE, $priceType); - } - - /** - * Set price value - * - * @param float $priceValue - * @return $this - */ - public function setPriceValue($priceValue) - { - return $this->_set(ProductLink::PRICE_VALUE, $priceValue); - } - - /** - * Set quantity - * - * @param int $priceValue - * @return $this - */ - public function setQuantity($quantity) - { - return $this->_set(ProductLink::QUANTITY, $quantity); - } - - /** - * Set can change quantity - * - * @param int $canChangeQuantity - * @return $this - */ - public function setCanChangeQuantity($canChangeQuantity) - { - return $this->_set(ProductLink::CAN_CHANGE_QUANTITY, $canChangeQuantity); - } -} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/ReadService.php b/app/code/Magento/Bundle/Service/V1/Product/Link/ReadService.php index 2cb313a5759bdd3d4f50c3e50e64c85a403668ef..ea5ede71fdcd8eacee98961bf347a38f4a51bc22 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/ReadService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/ReadService.php @@ -24,7 +24,7 @@ namespace Magento\Bundle\Service\V1\Product\Link; use Magento\Bundle\Model\Option; -use Magento\Bundle\Service\V1\Data\Product\Link\MetadataConverter; +use Magento\Bundle\Service\V1\Data\Product\LinkConverter; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ProductRepository; use Magento\Webapi\Exception; @@ -37,21 +37,21 @@ class ReadService implements ReadServiceInterface private $productRepository; /** - * @var \Magento\Bundle\Service\V1\Data\Product\Link\MetadataConverter + * @var \Magento\Bundle\Service\V1\Data\Product\LinkConverter */ - private $metadataConverter; + private $linkConverter; /** * @param ProductRepository $productRepository - * @param MetadataConverter $metadataConverter + * @param LinkConverter $linkConverter */ public function __construct( ProductRepository $productRepository, - MetadataConverter $metadataConverter + LinkConverter $linkConverter ) { $this->productRepository = $productRepository; - $this->metadataConverter = $metadataConverter; + $this->linkConverter = $linkConverter; } /** @@ -69,7 +69,7 @@ class ReadService implements ReadServiceInterface foreach ($this->getOptions($product) as $option) { /** @var \Magento\Catalog\Model\Product $selection */ foreach ($option->getSelections() as $selection) { - $childrenList[] = $this->metadataConverter->createDataFromModel($selection, $product); + $childrenList[] = $this->linkConverter->createDataFromModel($selection, $product); } } diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/ReadServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Link/ReadServiceInterface.php index 82d41f220ea88db92cbb483a60549245697089b5..01e2f1b5999b1f8ca92b582b6194174012d8edef 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/ReadServiceInterface.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/ReadServiceInterface.php @@ -29,7 +29,7 @@ interface ReadServiceInterface * Get all children for Bundle product * * @param string $productId - * @return \Magento\Bundle\Service\V1\Data\Product\Link\Metadata[] + * @return \Magento\Bundle\Service\V1\Data\Product\Link[] * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Webapi\Exception */ diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php index 2964310bc693c25faa781cb82469dabb0bd5ad79..80212e3085536bafd62866d68b730181be4b02e4 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php @@ -22,7 +22,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Bundle\Service\V1\Product\Link; use Magento\Catalog\Model\ProductRepository; @@ -46,7 +45,7 @@ class WriteService implements WriteServiceInterface protected $bundleSelection; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -65,14 +64,14 @@ class WriteService implements WriteServiceInterface * @param \Magento\Bundle\Model\SelectionFactory $bundleSelection * @param \Magento\Bundle\Model\Resource\BundleFactory $bundleFactory * @param \Magento\Bundle\Model\Resource\Option\CollectionFactory $optionCollection, - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( ProductRepository $productRepository, \Magento\Bundle\Model\SelectionFactory $bundleSelection, \Magento\Bundle\Model\Resource\BundleFactory $bundleFactory, \Magento\Bundle\Model\Resource\Option\CollectionFactory $optionCollection, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->productRepository = $productRepository; $this->bundleSelection = $bundleSelection; @@ -84,7 +83,7 @@ class WriteService implements WriteServiceInterface /** * {@inheritdoc} */ - public function addChild($productSku, $optionId, Data\ProductLink $linkedProduct) + public function addChild($productSku, $optionId, \Magento\Bundle\Service\V1\Data\Product\Link $linkedProduct) { /** @var \Magento\Catalog\Model\Product $product */ $product = $this->productRepository->get($productSku); @@ -120,7 +119,8 @@ class WriteService implements WriteServiceInterface } if ($selections) { foreach ($selections as $selection) { - if ($selection['option_id'] == $optionId && $selection['product_id'] == $linkProductModel->getId()) { + if ($selection['option_id'] = $optionId && + $selection['product_id'] == $linkProductModel->getId()) { throw new CouldNotSaveException( 'Child with specified sku: "%1" already assigned to product: "%2"', [$linkedProduct->getSku(), $productSku] @@ -132,9 +132,9 @@ class WriteService implements WriteServiceInterface $selectionModel = $this->bundleSelection->create(); $selectionModel->setOptionId($optionId) ->setPosition($linkedProduct->getPosition()) - ->setSelectionQty($linkedProduct->getQuantity()) + ->setSelectionQty($linkedProduct->getQty()) ->setSelectionPriceType($linkedProduct->getPriceType()) - ->setSelectionPriceValue($linkedProduct->getPriceValue()) + ->setSelectionPriceValue($linkedProduct->getPrice()) ->setSelectionCanChangeQty($linkedProduct->getCanChangeQuantity()) ->setProductId($linkProductModel->getId()) ->setParentProductId($product->getId()) diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteServiceInterface.php index 44246c350baedb033acdaa5b51a1f5b01935d855..c8909789eaddf94fe3dc6eb537f14e3ae7e7d2fa 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteServiceInterface.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteServiceInterface.php @@ -31,13 +31,13 @@ interface WriteServiceInterface * * @param string $productSku * @param int $optionId - * @param \Magento\Bundle\Service\V1\Product\Link\Data\ProductLink $linkedProduct + * @param \Magento\Bundle\Service\V1\Data\Product\Link $linkedProduct * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\InputException * @return int */ - public function addChild($productSku, $optionId, Data\ProductLink $linkedProduct); + public function addChild($productSku, $optionId, \Magento\Bundle\Service\V1\Data\Product\Link $linkedProduct); /** * Remove product from Bundle product option diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php index 714401d72e441e215c3630de193a395af5c1eedc..7f566abff9316ba5325782906f270f60f52862ee 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php @@ -24,7 +24,9 @@ namespace Magento\Bundle\Service\V1\Product\Option; use Magento\Bundle\Model\Product\Type; +use Magento\Bundle\Service\V1\Data\Product\LinkConverter; use Magento\Bundle\Service\V1\Data\Product\OptionConverter; +use Magento\Bundle\Service\V1\Product\Link\ReadService as LinkReadService; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ProductRepository; use Magento\Framework\Exception\NoSuchEntityException; @@ -46,19 +48,27 @@ class ReadService implements ReadServiceInterface */ private $type; + /** + * @var LinkConverter + */ + private $linkConverter; + /** * @param OptionConverter $optionConverter * @param ProductRepository $productRepository * @param Type $type + * @param LinkConverter $linkConverter */ public function __construct( OptionConverter $optionConverter, ProductRepository $productRepository, - Type $type + Type $type, + LinkConverter $linkConverter ) { $this->optionConverter = $optionConverter; $this->productRepository = $productRepository; $this->type = $type; + $this->linkConverter = $linkConverter; } /** @@ -75,7 +85,10 @@ class ReadService implements ReadServiceInterface if (!$option->getId()) { throw new NoSuchEntityException('Requested option doesn\'t exist'); } - return $this->optionConverter->createDataFromModel($option, $product); + + $productLinks = $this->getProductLinks($product, $optionId); + + return $this->optionConverter->createDataFromModel($option, $product, $productLinks); } /** @@ -90,11 +103,39 @@ class ReadService implements ReadServiceInterface $optionDtoList = []; /** @var \Magento\Bundle\Model\Option $option */ foreach ($optionCollection as $option) { - $optionDtoList[] = $this->optionConverter->createDataFromModel($option, $product); + $productLinks = $this->getProductLinks($product, $option->getId()); + + $optionDtoList[] = $this->optionConverter->createDataFromModel($option, $product, $productLinks); } return $optionDtoList; } + /** + * @param Product $product + * @param int $optionId + * @return array|null + */ + private function getProductLinks(Product $product, $optionId) + { + /** @var \Magento\Bundle\Model\Product\Type $productTypeInstance */ + $productTypeInstance = $product->getTypeInstance(); + $productTypeInstance->setStoreFilter( + $product->getStoreId(), + $product + ); + $selectionCollection = $productTypeInstance->getSelectionsCollection( + [ $optionId ], + $product + ); + + $productLinks = []; + /** @var \Magento\Catalog\Model\Product $selection */ + foreach ($selectionCollection as $selection) { + $productLinks[] = $this->linkConverter->createDataFromModel($selection, $product); + } + return $productLinks; + } + /** * @param string $productSku * @return Product diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php index d48888f52295d6d8ad98279be65a749c4bb9190e..df486c2a59f428c265d1bdc6954076b8f2bf5097 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php @@ -24,13 +24,15 @@ namespace Magento\Bundle\Service\V1\Product\Option; use Magento\Bundle\Model\Product\Type; +use Magento\Bundle\Service\V1\Data\Product\Link; use Magento\Bundle\Service\V1\Data\Product\Option; +use Magento\Bundle\Service\V1\Product\Link\WriteService as LinkWriteService; use Magento\Bundle\Service\V1\Data\Product\OptionConverter; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ProductRepository; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Webapi\Exception; class WriteService implements WriteServiceInterface @@ -52,22 +54,30 @@ class WriteService implements WriteServiceInterface */ private $storeManager; + /** + * @var LinkWriteService + */ + private $linkWriteService; + /** * @param ProductRepository $productRepository * @param Type $type * @param OptionConverter $optionConverter * @param StoreManagerInterface $storeManager + * @param LinkWriteService $linkWriteService */ public function __construct( ProductRepository $productRepository, Type $type, OptionConverter $optionConverter, - StoreManagerInterface $storeManager + StoreManagerInterface $storeManager, + LinkWriteService $linkWriteService ) { $this->productRepository = $productRepository; $this->type = $type; $this->optionConverter = $optionConverter; $this->storeManager = $storeManager; + $this->linkWriteService = $linkWriteService; } /** @@ -104,7 +114,14 @@ class WriteService implements WriteServiceInterface throw new CouldNotSaveException('Could not save option', [], $e); } - return $optionModel->getId(); + $optionId = $optionModel->getId(); + if (is_array($option->getProductLinks())) { + foreach ($option->getProductLinks() as $link) { + $this->linkWriteService->addChild($productSku, $optionId, $link); + } + } + + return $optionId; } /** @@ -125,6 +142,35 @@ class WriteService implements WriteServiceInterface } $updateOption->setStoreId($this->storeManager->getStore()->getId()); + /** + * @var Link[] $existingProductLinks + */ + $existingProductLinks = $optionModel->getProductLinks(); + if (!is_array($existingProductLinks)) { + $existingProductLinks = array(); + } + /** + * @var Link[] $newProductLinks + */ + $newProductLinks = $option->getProductLinks(); + if (is_null($newProductLinks)) { + $newProductLinks = array(); + } + /** + * @var Link[] $linksToDelete + */ + $linksToDelete = array_udiff($existingProductLinks, $newProductLinks, array($this, 'compareLinks')); + foreach ($linksToDelete as $link) { + $this->linkWriteService->removeChild($productSku, $option->getId(), $link->getSku()); + } + /** + * @var Link[] $linksToAdd + */ + $linksToAdd = array_udiff($newProductLinks, $existingProductLinks, array($this, 'compareLinks')); + foreach ($linksToAdd as $link) { + $this->linkWriteService->addChild($productSku, $option->getId(), $link); + } + try { $updateOption->save(); } catch (\Exception $e) { @@ -156,4 +202,20 @@ class WriteService implements WriteServiceInterface return $product; } + + /** + * Compare two links and determine if they are equal + * + * @param Link $firstLink + * @param Link $secondLink + * @return int + */ + private function compareLinks(Link $firstLink, Link $secondLink) + { + if ($firstLink->getSku() == $secondLink->getSku()) { + return 0; + } else { + return 1; + } + } } diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index 20b090534cd8d59b74fdf620e497a1d6fea62901..c2f9926dbc165837e84ba0b7bd7610f7ea9e1332 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog-rule": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", - "magento/module-webapi": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog-rule": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/module-webapi": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/etc/frontend/di.xml b/app/code/Magento/Bundle/etc/data_object.xml similarity index 76% rename from app/code/Magento/Reports/etc/frontend/di.xml rename to app/code/Magento/Bundle/etc/data_object.xml index a5ab4ba4e5d1b456e5002aa8716fa0fb0e532981..115fb11887372b68907100e13e1ff8572bbee9ed 100644 --- a/app/code/Magento/Reports/etc/frontend/di.xml +++ b/app/code/Magento/Bundle/etc/data_object.xml @@ -23,10 +23,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <virtualType name="Magento\Reports\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </virtualType> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Service/etc/data_object.xsd"> + <custom_attributes for="Magento\Catalog\Service\V1\Data\Product"> + <attribute code="bundle_product_options" type="Magento\Bundle\Service\V1\Data\Product\Option[]" /> + </custom_attributes> </config> diff --git a/app/code/Magento/Bundle/etc/di.xml b/app/code/Magento/Bundle/etc/di.xml index b33dcd27d2b05a88b71b97fa60227c921f0d0df6..6275f1d413cdc2071999e6569c9af52168037a82 100644 --- a/app/code/Magento/Bundle/etc/di.xml +++ b/app/code/Magento/Bundle/etc/di.xml @@ -103,4 +103,24 @@ <argument name="calculator" xsi:type="object">Magento\Bundle\Pricing\Adjustment\BundleCalculatorInterface</argument> </arguments> </type> + <type name="Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite"> + <arguments> + <argument name="loadProcessors" xsi:type="array"> + <item name="bundleProductLoadProcessor" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Bundle\Service\V1\Product\BundleProductLoadProcessor</item> + <item name="sortOrder" xsi:type="string">50</item> + </item> + </argument> + </arguments> + </type> + <type name="Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite"> + <arguments> + <argument name="saveProcessors" xsi:type="array"> + <item name="bundleProductSaveProcessor" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Bundle\Service\V1\Product\BundleProductSaveProcessor</item> + <item name="sortOrder" xsi:type="string">50</item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Captcha/Helper/Data.php b/app/code/Magento/Captcha/Helper/Data.php index 581e52566d343e8b6345be52181ab5015bae6169..f7ed3ae927f470e71d3d99a266aee6d16637c52f 100644 --- a/app/code/Magento/Captcha/Helper/Data.php +++ b/app/code/Magento/Captcha/Helper/Data.php @@ -70,7 +70,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_filesystem; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -81,14 +81,14 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Captcha\Model\CaptchaFactory $factory */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Filesystem $filesystem, \Magento\Captcha\Model\CaptchaFactory $factory diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index ccdc2ddac20747a67f56235dc2e2e9672a98338e..88d0306418ca12a09e8357a56f970a9c631a5a47 100644 --- a/app/code/Magento/Captcha/composer.json +++ b/app/code/Magento/Captcha/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php index 62d8ea5508c42ded2a8ab6ec4e3bf4826296b2d3..e3b6f29b3c2ed811405a7cbeeb0b08d8f8739398 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php @@ -32,7 +32,7 @@ namespace Magento\Catalog\Block\Adminhtml\Category\Helper; class Image extends \Magento\Framework\Data\Form\Element\Image { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -41,7 +41,7 @@ class Image extends \Magento\Framework\Data\Form\Element\Image * @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection * @param \Magento\Framework\Escaper $escaper * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -49,7 +49,7 @@ class Image extends \Magento\Framework\Data\Form\Element\Image \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Framework\Escaper $escaper, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $data = array() ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php index 4978d20a1cec21cc56e4e28a1bc2fde861faf708..ac7c9b178edd98d7bfc82300264d86e1d234e86c 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php @@ -100,7 +100,7 @@ class Wysiwyg extends \Magento\Framework\Data\Form\Element\Textarea 'label' => __('WYSIWYG Editor'), 'type' => 'button', 'disabled' => $disabled, - 'class' => $disabled ? 'disabled action-wysiwyg' : 'action-wysiwyg', + 'class' => 'action-wysiwyg', 'onclick' => 'catalogWysiwygEditor.open(\'' . $this->_backendData->getUrl( 'catalog/product/wysiwyg' ) . '\', \'' . $this->getHtmlId() . '\')' diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php index e347dbe250ee2ad7a9cc518deab5d6c3c6413160..1d5f9eeb0d997efc9afb6774c2761741a221dd12 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php @@ -36,7 +36,7 @@ use Magento\Eav\Model\Entity\Attribute; class Gallery extends AbstractElement { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -50,7 +50,7 @@ class Gallery extends AbstractElement * @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection * @param \Magento\Framework\Escaper $escaper * @param \Magento\Framework\View\LayoutInterface $layout - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -58,7 +58,7 @@ class Gallery extends AbstractElement \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Framework\Escaper $escaper, \Magento\Framework\View\LayoutInterface $layout, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $data = array() ) { $this->_layout = $layout; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php index 115ba7728b223914e58bd6186a04e09510f576c4..8c8845c7688680279332cdaafb911bf3ed7d36bd 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php @@ -50,7 +50,7 @@ class Price extends \Magento\Framework\Data\Form\Element\Text * @param \Magento\Framework\Data\Form\Element\Factory $factoryElement * @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection * @param \Magento\Framework\Escaper $escaper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency * @param \Magento\Tax\Helper\Data $taxData * @param array $data @@ -59,7 +59,7 @@ class Price extends \Magento\Framework\Data\Form\Element\Text \Magento\Framework\Data\Form\Element\Factory $factoryElement, \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Framework\Escaper $escaper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, \Magento\Tax\Helper\Data $taxData, array $data = array() diff --git a/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php index a1bf363c36efb0bfa537500d865a3ef51c7d7e5c..26bd2557ff19b0f99ca0905dd45dd22e22617f92 100644 --- a/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php +++ b/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php @@ -73,11 +73,11 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare protected $httpContext; /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Catalog product visibility @@ -108,7 +108,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory * @param Product\Visibility $catalogProductVisibility - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer * @param array $data @@ -118,7 +118,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare \Magento\Core\Helper\Data $coreData, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Framework\App\Http\Context $httpContext, \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, array $data = array() @@ -126,7 +126,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare $this->_coreData = $coreData; $this->_itemCollectionFactory = $itemCollectionFactory; $this->_catalogProductVisibility = $catalogProductVisibility; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->httpContext = $httpContext; $this->currentCustomer = $currentCustomer; parent::__construct( @@ -184,7 +184,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare } elseif ($this->_customerId) { $this->_items->setCustomerId($this->_customerId); } else { - $this->_items->setVisitorId($this->_logVisitor->getId()); + $this->_items->setVisitorId($this->_customerVisitor->getId()); } $this->_items->addAttributeToSelect( diff --git a/app/code/Magento/Catalog/Block/Product/Context.php b/app/code/Magento/Catalog/Block/Product/Context.php index 2a3708fea28ff39c8bd59dd2d12a552606ae9d59..fe22dcc23b0fe42935547144bf820f2caf3eef37 100644 --- a/app/code/Magento/Catalog/Block/Product/Context.php +++ b/app/code/Magento/Catalog/Block/Product/Context.php @@ -106,7 +106,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context * @param \Magento\Framework\View\FileSystem $viewFileSystem * @param \Magento\Framework\View\TemplateEnginePool $enginePool * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Config $catalogConfig * @param \Magento\Framework\Registry $registry * @param \Magento\Tax\Helper\Data $taxHelper @@ -144,7 +144,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\View\TemplateEnginePool $enginePool, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Config $catalogConfig, \Magento\Framework\Registry $registry, \Magento\Tax\Helper\Data $taxHelper, diff --git a/app/code/Magento/Catalog/Block/Product/Send.php b/app/code/Magento/Catalog/Block/Product/Send.php index 0d5cd90478307b6f69b9548dcd73498415211187..0a9c9cd244c496124c74be57d508ea9fc1f3866d 100644 --- a/app/code/Magento/Catalog/Block/Product/Send.php +++ b/app/code/Magento/Catalog/Block/Product/Send.php @@ -88,13 +88,4 @@ class Send extends \Magento\Catalog\Block\Product\AbstractProduct { return $this->getRequest()->getParam('id'); } - - /** - * @return int - */ - public function getMaxRecipients() - { - $sendToFriendModel = $this->_coreRegistry->registry('send_to_friend_model'); - return $sendToFriendModel->getMaxRecipients(); - } } diff --git a/app/code/Magento/Catalog/Block/Product/View.php b/app/code/Magento/Catalog/Block/Product/View.php index fbfd9c6a21048766f298b727396d529e27a01b62..b23ad04e27892e7cace2db695dbfc3997bc0da47 100644 --- a/app/code/Magento/Catalog/Block/Product/View.php +++ b/app/code/Magento/Catalog/Block/Product/View.php @@ -202,8 +202,7 @@ class View extends AbstractProduct implements \Magento\Framework\View\Block\Iden */ public function canEmailToFriend() { - $sendToFriendModel = $this->_coreRegistry->registry('send_to_friend_model'); - return $sendToFriendModel && $sendToFriendModel->canEmailToFriend(); + return false; } /** diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php index 1d4aa70d7f22d2bfc4ffa23ec63dab9bfb5401af..9c0a81bba6bf5e86e08db8ffb721061199de6e51 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php @@ -48,7 +48,7 @@ class Category extends \Magento\Backend\App\Action $category->load($categoryId); if ($storeId) { $rootId = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $storeId )->getRootCategoryId(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php index 1c6693caa1ba060eb60ab9e6b947b7a136307cb1..366d0e3b8985d2b2aa2a297d01c38f3812e2a95c 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php @@ -38,7 +38,7 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Category $categoryId = (int)$this->getRequest()->getParam('id'); if ($storeId && !$categoryId && !$parentId) { - $store = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore($storeId); + $store = $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore($storeId); $this->getRequest()->setParam('id', (int)$store->getRootCategoryId()); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php index 03178387ebc1559c3d5965844e75f32f296e835c..e6f3378323a4e7fb86fcd35b27eb572fab479cfd 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php @@ -64,7 +64,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category if (!$parentId) { if ($storeId) { $parentId = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $storeId )->getRootCategoryId(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php index 857c6e69af5992dea2b050553a62dee8da6206ac..9d3ead8200f8bc5e53e751a7ff05994b8b51c0f4 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php @@ -39,7 +39,7 @@ class Tree extends \Magento\Catalog\Controller\Adminhtml\Category if ($storeId) { if (!$categoryId) { - $store = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore($storeId); + $store = $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore($storeId); $rootId = $store->getRootCategoryId(); $this->getRequest()->setParam('id', $rootId); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php index a14533d546c0609b22a6bd5cbf5ef9b0738d1b08..fb4fcbb3ef62e5b6d030267eb5c3efecf1703a08 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php @@ -66,7 +66,7 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Product $this->_setActiveMenu('Magento_Catalog::catalog_products'); if (!$this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->isSingleStoreMode() && ($switchBlock = $this->_view->getLayout()->getBlock( 'store_switcher' )) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php index c6ef67d19479044ef5240b63b916a4b51b01141a..9dc472ea17270ab6da743bb4e55140b93ca8db4f 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php @@ -31,7 +31,7 @@ class Helper protected $request; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -52,14 +52,14 @@ class Helper /** * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param StockDataFilter $stockFilter * @param \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks * @param \Magento\Backend\Helper\Js $jsHelper */ public function __construct( \Magento\Framework\App\RequestInterface $request, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, StockDataFilter $stockFilter, \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks, \Magento\Backend\Helper\Js $jsHelper diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php index 82bbbe2b645b4b13df0bb5fbcb3d359b12222101..3351bb8577dca852369abf023ca1f674132aa3ca 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php @@ -36,7 +36,7 @@ class Wysiwyg extends \Magento\Catalog\Controller\Adminhtml\Product $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); $storeId = $this->getRequest()->getParam('store_id', 0); $storeMediaUrl = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $storeId )->getBaseUrl( diff --git a/app/code/Magento/Catalog/Controller/Category/View.php b/app/code/Magento/Catalog/Controller/Category/View.php index e60825d2df87fef4e1326b65a3f6dcd7905f79e5..12a68a4b63088b09e5aa39a14be0f62a081357b1 100644 --- a/app/code/Magento/Catalog/Controller/Category/View.php +++ b/app/code/Magento/Catalog/Controller/Category/View.php @@ -55,7 +55,7 @@ class View extends \Magento\Framework\App\Action\Action protected $_categoryFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -65,7 +65,7 @@ class View extends \Magento\Framework\App\Action\Action * @param \Magento\Catalog\Model\Design $catalogDesign * @param \Magento\Catalog\Model\Session $catalogSession * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Action\Context $context, @@ -73,7 +73,7 @@ class View extends \Magento\Framework\App\Action\Action \Magento\Catalog\Model\Design $catalogDesign, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\Registry $coreRegistry, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; $this->_categoryFactory = $categoryFactory; diff --git a/app/code/Magento/Catalog/Controller/Product/Compare.php b/app/code/Magento/Catalog/Controller/Product/Compare.php index 24c7f8be1f138e5b371e77ed811ecf7e338c2e94..d814773bb34540f4d53895d246545ba4bcf74b61 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare.php @@ -54,11 +54,11 @@ class Compare extends \Magento\Framework\App\Action\Action protected $_catalogProductCompareList; /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Customer session @@ -89,7 +89,7 @@ class Compare extends \Magento\Framework\App\Action\Action protected $_compareItemFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -104,10 +104,10 @@ class Compare extends \Magento\Framework\App\Action\Action * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList * @param \Magento\Catalog\Model\Session $catalogSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param FormKeyValidator $formKeyValidator */ public function __construct( @@ -116,10 +116,10 @@ class Compare extends \Magento\Framework\App\Action\Action \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Customer\Model\Session $customerSession, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList, \Magento\Catalog\Model\Session $catalogSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, FormKeyValidator $formKeyValidator ) { $this->_storeManager = $storeManager; @@ -127,7 +127,7 @@ class Compare extends \Magento\Framework\App\Action\Action $this->_productFactory = $productFactory; $this->_itemCollectionFactory = $itemCollectionFactory; $this->_customerSession = $customerSession; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->_catalogProductCompareList = $catalogProductCompareList; $this->_catalogSession = $catalogSession; $this->_formKeyValidator = $formKeyValidator; diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Add.php b/app/code/Magento/Catalog/Controller/Product/Compare/Add.php index 6cab38dfae2a28b9d7dc3de180c3316bab965299..ba8d8efe36d5bd5f82777c40f34ad82e72bd69d4 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Add.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Add.php @@ -39,7 +39,7 @@ class Add extends \Magento\Catalog\Controller\Product\Compare } $productId = (int)$this->getRequest()->getParam('product'); - if ($productId && ($this->_logVisitor->getId() || $this->_customerSession->isLoggedIn())) { + if ($productId && ($this->_customerVisitor->getId() || $this->_customerSession->isLoggedIn())) { /** @var \Magento\Catalog\Model\Product $product */ $product = $this->_productFactory->create(); $product->setStoreId($this->_storeManager->getStore()->getId())->load($productId); diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php b/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php index f2c1004257519b861391bd54f6efe0d469253ea9..cebf3b5340a57637f82f07d5d5f69ab5d831d9ca 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php @@ -41,7 +41,7 @@ class Clear extends \Magento\Catalog\Controller\Product\Compare } elseif ($this->_customerId) { $items->setCustomerId($this->_customerId); } else { - $items->setVisitorId($this->_logVisitor->getId()); + $items->setVisitorId($this->_customerVisitor->getId()); } try { diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php b/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php index 7380db349bfa0a276434ca751ffba80101e86276..b4c2478c5c94ed2780c3ca2ec38469fd7ccd8595 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php @@ -47,7 +47,7 @@ class Remove extends \Magento\Catalog\Controller\Product\Compare } elseif ($this->_customerId) { $item->setCustomerId($this->_customerId); } else { - $item->addVisitorId($this->_logVisitor->getId()); + $item->addVisitorId($this->_customerVisitor->getId()); } $item->loadByProduct($product); diff --git a/app/code/Magento/Catalog/Helper/Category.php b/app/code/Magento/Catalog/Helper/Category.php index a430b0cc64f804d433639f824f79f56563f1a875..99e5a25df2e3d53bcbf4410d80670b0743913451 100644 --- a/app/code/Magento/Catalog/Helper/Category.php +++ b/app/code/Magento/Catalog/Helper/Category.php @@ -64,7 +64,7 @@ class Category extends AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -85,14 +85,14 @@ class Category extends AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Data\CollectionFactory $dataCollectionFactory */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Catalog\Model\CategoryFactory $categoryFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Data\CollectionFactory $dataCollectionFactory ) { diff --git a/app/code/Magento/Catalog/Helper/Data.php b/app/code/Magento/Catalog/Helper/Data.php index 1a1bf36b4c521300f31a5fca392d19db715bff53..0faa685c3dcf68aa8eb5be8252121fdcb4caec88 100644 --- a/app/code/Magento/Catalog/Helper/Data.php +++ b/app/code/Magento/Catalog/Helper/Data.php @@ -138,7 +138,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -227,7 +227,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Catalog\Model\Resource\Eav\AttributeFactory $eavAttributeFactory * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Session $catalogSession * @param \Magento\Framework\Stdlib\String $string * @param Category $catalogCategory @@ -250,7 +250,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Catalog\Model\Resource\Eav\AttributeFactory $eavAttributeFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\Stdlib\String $string, Category $catalogCategory, diff --git a/app/code/Magento/Catalog/Helper/Product.php b/app/code/Magento/Catalog/Helper/Product.php index 177b2639bbc7fdb76920ccd13df60f7c2981cf7b..4be9078942eaa3c6d1150bc97bcc3469cbefae40 100644 --- a/app/code/Magento/Catalog/Helper/Product.php +++ b/app/code/Magento/Catalog/Helper/Product.php @@ -127,7 +127,7 @@ class Product extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Session $catalogSession @@ -141,7 +141,7 @@ class Product extends \Magento\Core\Helper\Url */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Session $catalogSession, diff --git a/app/code/Magento/Catalog/Helper/Product/Compare.php b/app/code/Magento/Catalog/Helper/Product/Compare.php index 01824c14765ab9540a74d9b9f5f507f5b27934e5..03eb15ffe4f76280138027749e1ac52dfc610fb7 100644 --- a/app/code/Magento/Catalog/Helper/Product/Compare.php +++ b/app/code/Magento/Catalog/Helper/Product/Compare.php @@ -76,11 +76,11 @@ class Compare extends \Magento\Core\Helper\Url protected $_customerSession; /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Catalog product visibility @@ -113,10 +113,10 @@ class Compare extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Catalog\Model\Session $catalogSession * @param \Magento\Framework\Data\Form\FormKey $formKey @@ -125,10 +125,10 @@ class Compare extends \Magento\Core\Helper\Url */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\Data\Form\FormKey $formKey, @@ -137,7 +137,7 @@ class Compare extends \Magento\Core\Helper\Url ) { $this->_itemCollectionFactory = $itemCollectionFactory; $this->_catalogProductVisibility = $catalogProductVisibility; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->_customerSession = $customerSession; $this->_catalogSession = $catalogSession; $this->_formKey = $formKey; @@ -289,7 +289,7 @@ class Compare extends \Magento\Core\Helper\Url } elseif ($this->_customerId) { $this->_itemCollection->setCustomerId($this->_customerId); } else { - $this->_itemCollection->setVisitorId($this->_logVisitor->getId()); + $this->_itemCollection->setVisitorId($this->_customerVisitor->getId()); } $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInSiteIds()); @@ -322,7 +322,7 @@ class Compare extends \Magento\Core\Helper\Url } elseif ($this->_customerId) { $collection->setCustomerId($this->_customerId); } else { - $collection->setVisitorId($this->_logVisitor->getId()); + $collection->setVisitorId($this->_customerVisitor->getId()); } /* Price data is added to consider item stock status using price index */ diff --git a/app/code/Magento/Catalog/Helper/Product/Composite.php b/app/code/Magento/Catalog/Helper/Product/Composite.php index 9369033f17cde65feb314487e1be79b70b3e5e42..ebbf3cb8f03e350c011e9327659ec93542d14fd3 100644 --- a/app/code/Magento/Catalog/Helper/Product/Composite.php +++ b/app/code/Magento/Catalog/Helper/Product/Composite.php @@ -27,7 +27,7 @@ use Magento\Framework\App\Helper\Context; use Magento\Framework\App\ViewInterface; use Magento\Catalog\Helper\Product; use Magento\Catalog\Model\ProductFactory; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Customer\Controller\RegistryConstants; use Magento\Customer\Model\Converter; use Magento\Framework\Registry; @@ -54,7 +54,7 @@ class Composite extends \Magento\Framework\App\Helper\AbstractHelper protected $_catalogProduct = null; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -76,7 +76,7 @@ class Composite extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param ProductFactory $productFactory - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Product $catalogProduct * @param Registry $coreRegistry * @param ViewInterface $view diff --git a/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php b/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php index 1399a446e62befba67dca785a33b2952675f22c7..a63a8c46757024b7c4e118e1d5ded5a51ec9b0c1 100644 --- a/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php +++ b/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php @@ -117,7 +117,7 @@ class Indexer extends \Magento\Framework\App\Helper\AbstractHelper protected $_attributeFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -143,7 +143,7 @@ class Indexer extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Catalog\Model\Attribute\Config $attributeConfig * @param \Magento\Catalog\Model\Resource\ConfigFactory $configFactory * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Mview\View\Changelog $changelog * @param bool $addFilterableAttrs * @param bool $addChildData @@ -156,7 +156,7 @@ class Indexer extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Catalog\Model\Attribute\Config $attributeConfig, \Magento\Catalog\Model\Resource\ConfigFactory $configFactory, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Mview\View\Changelog $changelog, $addFilterableAttrs = false, $addChildData = false, diff --git a/app/code/Magento/Catalog/Helper/Product/Inventory.php b/app/code/Magento/Catalog/Helper/Product/Inventory.php index e3599046fdb227e4bba5c7cd685e33349b9c109a..d51037b1ef227f097915e141647d9f4d03081ca9 100644 --- a/app/code/Magento/Catalog/Helper/Product/Inventory.php +++ b/app/code/Magento/Catalog/Helper/Product/Inventory.php @@ -100,8 +100,8 @@ class Inventory extends \Magento\Framework\App\Helper\AbstractHelper public function getDoFieldData($field, StockItem $dataObject) { $possibleMethods = array( - 'get' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($field), - 'is' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($field) + 'get' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($field), + 'is' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($field) ); foreach ($possibleMethods as $method) { diff --git a/app/code/Magento/Catalog/Model/AbstractModel.php b/app/code/Magento/Catalog/Model/AbstractModel.php index e41ac7c97f6233213845f85a79e780a554ec4e65..3a567565f1d7ead21060e5e71ffe5e50df4a3ca0 100644 --- a/app/code/Magento/Catalog/Model/AbstractModel.php +++ b/app/code/Magento/Catalog/Model/AbstractModel.php @@ -71,14 +71,14 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -86,7 +86,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 77a70a1d91d24e7311f25d0762237f3027ff9044..bc0ec4c791e5fe812c0704ece4603f0525a80536 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -191,7 +191,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Category\Tree $categoryTreeResource * @param \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory @@ -212,7 +212,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Category\Tree $categoryTreeResource, \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php index 804e3f8d6b5d6b1791560cbcb709b2887eb164ff..28ef8cff07af9f116642fa1d80dd2e4147609b71 100644 --- a/app/code/Magento/Catalog/Model/Config.php +++ b/app/code/Magento/Catalog/Model/Config.php @@ -98,7 +98,7 @@ class Config extends \Magento\Eav\Model\Config /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -142,7 +142,7 @@ class Config extends \Magento\Eav\Model\Config * @param \Magento\Catalog\Model\Product\TypeFactory $productTypeFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $groupCollectionFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -157,7 +157,7 @@ class Config extends \Magento\Eav\Model\Config \Magento\Catalog\Model\Product\TypeFactory $productTypeFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $groupCollectionFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig ) { $this->_scopeConfig = $scopeConfig; diff --git a/app/code/Magento/Catalog/Model/Entity/Attribute.php b/app/code/Magento/Catalog/Model/Entity/Attribute.php index 090e68cd60d7b3d9080099670f0674f3c4ff0aa2..1a88eda64605f5aa9ee7ba51e8ad83d0580e37db 100644 --- a/app/code/Magento/Catalog/Model/Entity/Attribute.php +++ b/app/code/Magento/Catalog/Model/Entity/Attribute.php @@ -94,7 +94,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -111,7 +111,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute \Magento\Core\Helper\Data $coreData, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php index 159d3692224de84f82172cdfd4078b60afd9646c..06d98e19372d2a711dd445159113720fef725285 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php @@ -43,7 +43,7 @@ class AbstractAction protected $resource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -63,12 +63,12 @@ class AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Helper $resourceHelper ) { $this->resource = $resource; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php index 72733fa209d7a659630b9c71b839cf3b6700fcd5..3b3dddb053cd7b7b5c4be2d660672853965a4aa0 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php @@ -32,13 +32,13 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Catalog\Model\CategoryFactory $categoryFactory ) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php index 5fb3182e3b11e4c4d699f7745f0b2385d913d7a2..d546d93fb3326767684a59758ba365a114d13b2b 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php @@ -79,7 +79,7 @@ abstract class AbstractAction protected $resource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -97,12 +97,12 @@ abstract class AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Config $config */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Config $config ) { $this->resource = $resource; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilter.php b/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilter.php index fe08d6e044df68c692648588baa225cacf76f011..956a5c0ac338069194a5b6662c1f5324cf6bec36 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilter.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilter.php @@ -50,18 +50,20 @@ class IndexableAttributeFilter { $codes = []; $catalogResource = $this->_attributeFactory->create(); - - foreach ($set->getGroups() as $group) { - /** @var $group \Magento\Eav\Model\Entity\Attribute\Group */ - foreach ($group->getAttributes() as $attribute) { - /** @var $attribute \Magento\Eav\Model\Entity\Attribute */ - $catalogResource->load($attribute->getId()); - if ($catalogResource->isIndexable()) { - // Attribute requires to be cloned for new dataset to maintain attribute set changes - $attributeClone = clone $attribute; - $attributeClone->load($attribute->getAttributeId()); - $codes[] = $attributeClone->getAttributeCode(); - unset($attributeClone); + $groups = $set->getGroups(); + if (is_array($groups)) { + foreach ($groups as $group) { + /** @var $group \Magento\Eav\Model\Entity\Attribute\Group */ + foreach ($group->getAttributes() as $attribute) { + /** @var $attribute \Magento\Eav\Model\Entity\Attribute */ + $catalogResource->load($attribute->getId()); + if ($catalogResource->isIndexable()) { + // Attribute requires to be cloned for new dataset to maintain attribute set changes + $attributeClone = clone $attribute; + $attributeClone->load($attribute->getAttributeId()); + $codes[] = $attributeClone->getAttributeCode(); + unset($attributeClone); + } } } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php index 34d924208652349fe4f5be1358ba5c8c8d3e3025..4e47442491127d4be43e48607c2ae5ed290aa7c1 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php @@ -44,7 +44,7 @@ abstract class AbstractAction protected $_tableDropSuffix = '_drop_indexer'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -89,7 +89,7 @@ abstract class AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper * @param \Magento\Catalog\Model\Product\Type $productType * @param TableBuilder $tableBuilder @@ -97,7 +97,7 @@ abstract class AbstractAction */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, \Magento\Catalog\Model\Product\Type $productType, TableBuilder $tableBuilder, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php index 8829c244647cd88a73db125f93f4146a0ee63489..2caa4477bc6323ddc3bb02a3a00d8520c1451ca1 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php @@ -38,19 +38,19 @@ class Eraser protected $connection; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->productIndexerHelper = $productHelper; $this->connection = $resource->getConnection('default'); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php index ddaf458ae131ce4104f96a1455b3f38cb264efd7..9cb1bc68c4da05dd9ada305c07f1fb87c752926a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php @@ -44,7 +44,7 @@ class Row extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper * @param \Magento\Catalog\Model\Product\Type $productType * @param TableBuilder $tableBuilder @@ -54,7 +54,7 @@ class Row extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, \Magento\Catalog\Model\Product\Type $productType, TableBuilder $tableBuilder, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php index d0d2e38f7e7baa76b653e88ee2ed70e0d5f5081e..8ee5949f63c955410eedc7270eec8407d2bc4b5c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php @@ -39,7 +39,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper * @param \Magento\Catalog\Model\Product\Type $productType * @param TableBuilder $tableBuilder @@ -48,7 +48,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, \Magento\Catalog\Model\Product\Type $productType, TableBuilder $tableBuilder, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php index 787728991b729fa7371c8ebeaba39e0969af6f9f..69bee9ddc1a2ad3c97bfe4943481499b2c828c27 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php @@ -49,7 +49,7 @@ class FlatTableBuilder protected $_config; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -62,14 +62,14 @@ class FlatTableBuilder * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productIndexerHelper * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param TableDataInterface $tableData */ public function __construct( \Magento\Catalog\Helper\Product\Flat\Indexer $productIndexerHelper, \Magento\Framework\App\Resource $resource, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Indexer\Product\Flat\TableDataInterface $tableData ) { $this->_productIndexerHelper = $productIndexerHelper; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 47e19be5f150febf2aee69c5e7c61f395de636dd..c695c64c1af04003e2177624745767db3bc42891 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -56,7 +56,7 @@ abstract class AbstractAction protected $_config; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -104,7 +104,7 @@ abstract class AbstractAction /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -115,7 +115,7 @@ abstract class AbstractAction public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Observer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Observer.php index c3375da301a6e1f196dae831f48e7763f68293a7..49836720f9adf0f478e01e7f8e5264800b0cf35f 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Observer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Observer.php @@ -26,7 +26,7 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; class Observer { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -61,7 +61,7 @@ class Observer protected $_connection; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -69,7 +69,7 @@ class Observer * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $processor */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Catalog/Model/Layer.php b/app/code/Magento/Catalog/Model/Layer.php index 31badd1789bb9d63e9fbc58706de8b7f074f5ee8..fb399b491e8529700235b9d6c51272e98d6cf7dd 100644 --- a/app/code/Magento/Catalog/Model/Layer.php +++ b/app/code/Magento/Catalog/Model/Layer.php @@ -54,7 +54,7 @@ class Layer extends \Magento\Framework\Object /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -107,7 +107,7 @@ class Layer extends \Magento\Framework\Object * @param CategoryFactory $categoryFactory * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -117,7 +117,7 @@ class Layer extends \Magento\Framework\Object \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Catalog\Model\Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer/Category.php b/app/code/Magento/Catalog/Model/Layer/Category.php index ba12e8722a4e3680e74fed7fd226889b35464079..b77a6357be266ebf34b5ecf7d2bbfcfdc25dde8f 100644 --- a/app/code/Magento/Catalog/Model/Layer/Category.php +++ b/app/code/Magento/Catalog/Model/Layer/Category.php @@ -37,7 +37,7 @@ class Category extends \Magento\Catalog\Model\Layer * @param CategoryFactory $categoryFactory * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -47,7 +47,7 @@ class Category extends \Magento\Catalog\Model\Layer CategoryFactory $categoryFactory, Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php b/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php index 8d7afa77589ebe50d4b53d4d6b576003ae392ee2..931dc7a0f48fb9f0f8ac521a76f036361c97a393 100644 --- a/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php +++ b/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php @@ -36,7 +36,7 @@ class FilterableAttributeList implements FilterableAttributeListInterface protected $collectionFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -49,12 +49,12 @@ class FilterableAttributeList implements FilterableAttributeListInterface * FilterableAttributeList constructor * * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer */ public function __construct( \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer ) { $this->collectionFactory = $collectionFactory; diff --git a/app/code/Magento/Catalog/Model/Layer/Category/StateKey.php b/app/code/Magento/Catalog/Model/Layer/Category/StateKey.php index 44a9d1b2b4ef0328be93c9500d24430eaa7255bc..9003a5363b18e1f9d0588cba0ca5c5dddbd2707e 100644 --- a/app/code/Magento/Catalog/Model/Layer/Category/StateKey.php +++ b/app/code/Magento/Catalog/Model/Layer/Category/StateKey.php @@ -30,7 +30,7 @@ use Magento\Catalog\Model\Layer\StateKeyInterface; class StateKey implements StateKeyInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -40,11 +40,11 @@ class StateKey implements StateKeyInterface protected $customerSession; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession ) { $this->storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php b/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php index 88c05c3425e46dd843f320ab41522aa043169271..c760506c2c0eedccadeff02df29572b07eb5f6ff 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php @@ -54,7 +54,7 @@ abstract class AbstractFilter extends \Magento\Framework\Object /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -69,13 +69,13 @@ abstract class AbstractFilter extends \Magento\Framework\Object * Constructor * * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param array $data */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php b/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php index 09917a939d39f912980ba2e416512af56197d832..d365147d7a47c1c3b015f363a99ae55f3dcbb6e4 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php @@ -53,7 +53,7 @@ class Attribute extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter /** * @param ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Resource\Layer\Filter\AttributeFactory $filterAttributeFactory * @param \Magento\Framework\Stdlib\String $string @@ -62,7 +62,7 @@ class Attribute extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\Resource\Layer\Filter\AttributeFactory $filterAttributeFactory, \Magento\Framework\Stdlib\String $string, diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Category.php b/app/code/Magento/Catalog/Model/Layer/Filter/Category.php index 8765e28ce4accaade91abf4f53c3242c1b2028c2..be76e54f90fa1449c8c0321bbae869196225c5ef 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Category.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Category.php @@ -70,7 +70,7 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter * Construct * * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Framework\Escaper $escaper @@ -79,7 +79,7 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Framework\Escaper $escaper, diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php b/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php index bc434112ad16ad7e7a516ae1a4395f5103b424d3..c14a9b5b64c3124c7c315d47b89135d0ce6a358d 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php @@ -45,14 +45,14 @@ class Decimal extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter * Construct * * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Resource\Layer\Filter\DecimalFactory $filterDecimalFactory * @param array $data */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\Resource\Layer\Filter\DecimalFactory $filterDecimalFactory, array $data = array() diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/Layer/Filter/Price.php index 78adcb1eb053c46ab22b6aab4d13fe4eed650d70..f926f6f0b782483325a9822e494c779593c81bd0 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Price.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Price.php @@ -94,7 +94,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter /** * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Resource\Layer\Filter\PriceFactory $filterPriceFactory * @param \Magento\Customer\Model\Session $customerSession @@ -105,7 +105,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\Resource\Layer\Filter\PriceFactory $filterPriceFactory, \Magento\Customer\Model\Session $customerSession, diff --git a/app/code/Magento/Catalog/Model/Layer/Search.php b/app/code/Magento/Catalog/Model/Layer/Search.php index 055a6b21b84e108e0328a6c54148fc04ef6bf080..a5d8f3a1e07c870ac883891ae88909ac12b8855b 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search.php +++ b/app/code/Magento/Catalog/Model/Layer/Search.php @@ -37,7 +37,7 @@ class Search extends \Magento\Catalog\Model\Layer * @param CategoryFactory $categoryFactory * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -47,7 +47,7 @@ class Search extends \Magento\Catalog\Model\Layer CategoryFactory $categoryFactory, Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php b/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php index ff92b26ead5146dd5fb67cdece74dfe85eb88ec0..6781008d8dfd001fb081f7d8ace5861aa18810bd 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php +++ b/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php @@ -39,7 +39,7 @@ class CollectionFilter implements CollectionFilterInterface protected $helper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -51,13 +51,13 @@ class CollectionFilter implements CollectionFilterInterface /** * @param \Magento\Catalog\Model\Config $catalogConfig * @param \Magento\CatalogSearch\Helper\Data $helper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Visibility $productVisibility */ public function __construct( \Magento\Catalog\Model\Config $catalogConfig, \Magento\CatalogSearch\Helper\Data $helper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Visibility $productVisibility ) { $this->catalogConfig = $catalogConfig; diff --git a/app/code/Magento/Catalog/Model/Layer/Search/FilterableAttributeList.php b/app/code/Magento/Catalog/Model/Layer/Search/FilterableAttributeList.php index 2f009577220184cba723a0b1c175a17c12db6229..df8d2dd17090137ee9b89dea4891074324e0e094 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search/FilterableAttributeList.php +++ b/app/code/Magento/Catalog/Model/Layer/Search/FilterableAttributeList.php @@ -29,12 +29,12 @@ class FilterableAttributeList extends \Magento\Catalog\Model\Layer\Category\Filt { /** * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer\Search $layer */ public function __construct( \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer\Search $layer ) { parent::__construct($collectionFactory, $storeManager, $layer); diff --git a/app/code/Magento/Catalog/Model/Layer/Search/StateKey.php b/app/code/Magento/Catalog/Model/Layer/Search/StateKey.php index 955731d9f212268bd1c74fbba4639fdbed771c8a..a6a58adc4e44ba3921a7a15e6a70b4c4264cd746 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search/StateKey.php +++ b/app/code/Magento/Catalog/Model/Layer/Search/StateKey.php @@ -34,12 +34,12 @@ class StateKey extends \Magento\Catalog\Model\Layer\Category\StateKey protected $helper; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\CatalogSearch\Helper\Data $helper */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, \Magento\CatalogSearch\Helper\Data $helper ) { diff --git a/app/code/Magento/Catalog/Model/Observer.php b/app/code/Magento/Catalog/Model/Observer.php index 2907ed2fc4562fe80403637ffa903c5fe01e8df9..9bf515157cda3776d70da838104d77b336548736 100644 --- a/app/code/Magento/Catalog/Model/Observer.php +++ b/app/code/Magento/Catalog/Model/Observer.php @@ -61,7 +61,7 @@ class Observer /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -97,7 +97,7 @@ class Observer * @param \Magento\Catalog\Model\UrlFactory $urlFactory * @param \Magento\Catalog\Model\Resource\Category $categoryResource * @param \Magento\Catalog\Model\Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer\Category $catalogLayer * @param \Magento\Index\Model\Indexer $indexIndexer * @param \Magento\Catalog\Helper\Category $catalogCategory @@ -109,7 +109,7 @@ class Observer \Magento\Catalog\Model\UrlFactory $urlFactory, \Magento\Catalog\Model\Resource\Category $categoryResource, \Magento\Catalog\Model\Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer\Category $catalogLayer, \Magento\Index\Model\Indexer $indexIndexer, \Magento\Catalog\Helper\Category $catalogCategory, diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 7b467099e0ff21bea3bf6f4f80c3757b2931c07b..6bae0cd62700095556ade39d427974f531eb0987 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -272,7 +272,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Product\Url $url * @param Product\Link $productLink * @param Product\Configuration\Item\OptionFactory $itemOptionFactory @@ -302,7 +302,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, Product\Url $url, Product\Link $productLink, \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory $itemOptionFactory, diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php index 4b60745fa470d7d3abc975b7aa91d98b3554e37a..59e690c995cb8df656421286fc51124a8dc9127f 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php @@ -40,7 +40,7 @@ class Groupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Groupp /** * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -49,7 +49,7 @@ class Groupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Groupp public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType, diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php index 8f726dfda1b6db7c6d0f8cf6f8910d20fbab7fb3..c519659e4b9cd5db078555a409da380ff7f04fbf 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php @@ -56,7 +56,7 @@ abstract class AbstractGroupprice extends Price /** * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -64,7 +64,7 @@ abstract class AbstractGroupprice extends Price public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php index fadadfc59281bb2150ddaefed1676347b8daea93..38db295744433ab15aab6ecc9314d4098b839198 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php @@ -40,7 +40,7 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -63,14 +63,14 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend * * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php index d0e0ddb04cdb1e63a8ce48c6446f0fbe753c027f..28fc31e58180f5af5ac56db3711b9712c6f1dcfb 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php @@ -42,7 +42,7 @@ class Tierprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Grouppr /** * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -51,7 +51,7 @@ class Tierprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Grouppr public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType, diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php b/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php index d90a58cebf5ec34820362601dd2667ff443565b8..21652391443d19d64e8c3dba8827998a7331c618 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php @@ -35,16 +35,16 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFronten /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * Construct * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php index c32408dcee690840715f288ee2e1f2cb251fbef1..d54ab15f6d91941bda601c41e776e9635679d750 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php @@ -39,7 +39,7 @@ class Countryofmanufacture extends \Magento\Eav\Model\Entity\Attribute\Source\Ab /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -54,12 +54,12 @@ class Countryofmanufacture extends \Magento\Eav\Model\Entity\Attribute\Source\Ab * Construct * * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Cache\Type\Config $configCacheType */ public function __construct( \Magento\Directory\Model\CountryFactory $countryFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Cache\Type\Config $configCacheType ) { $this->_countryFactory = $countryFactory; diff --git a/app/code/Magento/Catalog/Model/Product/Compare/Item.php b/app/code/Magento/Catalog/Model/Product/Compare/Item.php index 04b3c683c592ed55037f5a6b29e8fb57f881422d..e4db0341e799f6a9115b19385c063fa85ae5bd91 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/Item.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/Item.php @@ -74,24 +74,24 @@ class Item extends \Magento\Framework\Model\AbstractModel implements \Magento\Fr protected $_customerSession; /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Catalog\Helper\Product\Compare $catalogProductCompare * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -101,8 +101,8 @@ class Item extends \Magento\Framework\Model\AbstractModel implements \Magento\Fr public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Framework\StoreManagerInterface $storeManager, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Catalog\Helper\Product\Compare $catalogProductCompare, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -110,7 +110,7 @@ class Item extends \Magento\Framework\Model\AbstractModel implements \Magento\Fr array $data = array() ) { $this->_storeManager = $storeManager; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->_customerSession = $customerSession; $this->_catalogProductCompare = $catalogProductCompare; parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -267,7 +267,7 @@ class Item extends \Magento\Framework\Model\AbstractModel implements \Magento\Fr public function getVisitorId() { if (!$this->hasData('visitor_id')) { - $visitorId = $this->_logVisitor->getId(); + $visitorId = $this->_customerVisitor->getId(); $this->setData('visitor_id', $visitorId); } return $this->getData('visitor_id'); diff --git a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php index 39bac3086d51cb9290802327073298adc057fdd8..788e5b3058102f911584bad11e0ec2ebc26173a9 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php @@ -33,11 +33,11 @@ use Magento\Catalog\Model\Resource\Product\Compare\Item\Collection; class ListCompare extends \Magento\Framework\Object { /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Customer session @@ -74,7 +74,7 @@ class ListCompare extends \Magento\Framework\Object * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory * @param \Magento\Catalog\Model\Resource\Product\Compare\Item $catalogProductCompareItem * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param array $data */ public function __construct( @@ -82,14 +82,14 @@ class ListCompare extends \Magento\Framework\Object \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\Resource\Product\Compare\Item $catalogProductCompareItem, \Magento\Customer\Model\Session $customerSession, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, array $data = array() ) { $this->_compareItemFactory = $compareItemFactory; $this->_itemCollectionFactory = $itemCollectionFactory; $this->_catalogProductCompareItem = $catalogProductCompareItem; $this->_customerSession = $customerSession; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; parent::__construct($data); } @@ -168,7 +168,7 @@ class ListCompare extends \Magento\Framework\Object */ protected function _addVisitorToItem($item) { - $item->addVisitorId($this->_logVisitor->getId()); + $item->addVisitorId($this->_customerVisitor->getId()); if ($this->_customerSession->isLoggedIn()) { $item->setCustomerId($this->_customerSession->getCustomerId()); } diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php index d2372eec3f71d7c78cc4abaa0a34caa2d50559ff..a926fdae7867fcb4a6020840c8d04425b2f2a73d 100644 --- a/app/code/Magento/Catalog/Model/Product/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Image.php @@ -173,14 +173,14 @@ class Image extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Media\Config $catalogProductMediaConfig * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDatabase * @param \Magento\Framework\App\Filesystem $filesystem @@ -195,7 +195,7 @@ class Image extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Media\Config $catalogProductMediaConfig, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDatabase, \Magento\Framework\App\Filesystem $filesystem, diff --git a/app/code/Magento/Catalog/Model/Product/Media/Config.php b/app/code/Magento/Catalog/Model/Product/Media/Config.php index f7a95db8f1daad6f4e43aea5d67dfad01e1610ff..8a99bd6690212261d5fba81bd4cce00fecbc5190 100644 --- a/app/code/Magento/Catalog/Model/Product/Media/Config.php +++ b/app/code/Magento/Catalog/Model/Product/Media/Config.php @@ -33,14 +33,14 @@ class Config implements ConfigInterface /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->storeManager = $storeManager; } diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price.php b/app/code/Magento/Catalog/Model/Product/Type/Price.php index 4d76f7c4f4721fb83b09bd6e20d77c2c20ef821c..59ebb2e3fd7d04a2a26146b78f49bc8e695e74bb 100755 --- a/app/code/Magento/Catalog/Model/Product/Type/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Price.php @@ -64,7 +64,7 @@ class Price /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -79,14 +79,14 @@ class Price * Construct * * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager */ public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Event\ManagerInterface $eventManager diff --git a/app/code/Magento/Catalog/Model/Product/Url.php b/app/code/Magento/Catalog/Model/Product/Url.php index c8ce679c494ae3dff40e82277509ccd59b14f101..45268641301ff0bd1c2fb4c2e93fb8c2108bbdc2 100644 --- a/app/code/Magento/Catalog/Model/Product/Url.php +++ b/app/code/Magento/Catalog/Model/Product/Url.php @@ -63,7 +63,7 @@ class Url extends \Magento\Framework\Object /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -77,7 +77,7 @@ class Url extends \Magento\Framework\Object * * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $urlRewriteFactory * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Category $catalogCategory * @param \Magento\Framework\Filter\FilterManager $filter * @param \Magento\Framework\Session\SidResolverInterface $sidResolver @@ -86,7 +86,7 @@ class Url extends \Magento\Framework\Object public function __construct( \Magento\UrlRewrite\Model\UrlRewriteFactory $urlRewriteFactory, \Magento\Framework\UrlInterface $url, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Category $catalogCategory, \Magento\Framework\Filter\FilterManager $filter, \Magento\Framework\Session\SidResolverInterface $sidResolver, diff --git a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php index 01ce99b70ceda684f4abd2ca120dfb73cdaeb4bc..9238fe9c862c5afde60ec78ca7a4055eb6269f86 100644 --- a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php @@ -40,7 +40,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,7 +60,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Factory $modelFactory * @param array $data */ @@ -71,7 +71,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Factory $modelFactory, $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Resource/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Attribute.php index 3bbd658a48f51118c8bed2bece95a8465ca9f14b..5d7929e93b166650d3087cbc04ad7babad6d756e 100644 --- a/app/code/Magento/Catalog/Model/Resource/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Attribute.php @@ -46,14 +46,14 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Entity\Type $eavEntityType * @param \Magento\Eav\Model\Config $eavConfig * @param LockValidatorInterface $lockValidator */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Entity\Type $eavEntityType, \Magento\Eav\Model\Config $eavConfig, LockValidatorInterface $lockValidator diff --git a/app/code/Magento/Catalog/Model/Resource/Category.php b/app/code/Magento/Catalog/Model/Resource/Category.php index 2fbc171768f6d3b5d0c3765e908fc937461337ee..3d002f93e5534130fae296de1bf4cc340689865c 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category.php +++ b/app/code/Magento/Catalog/Model/Resource/Category.php @@ -90,7 +90,7 @@ class Category extends AbstractResource * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Factory $modelFactory * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory @@ -106,7 +106,7 @@ class Category extends AbstractResource \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Factory $modelFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory, diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php index 072536a0b26df6e486b6e03b65ac0e5d4bee0d99..7b310c768d2668794057e09adcfaee6bd09b4bac 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php @@ -35,16 +35,16 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFronten /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * Construct * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php index 17404be9d87732684c97c42505f24ed00762f6d4..51515557a697f5b040d94bb31429b2611e769ef1 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php @@ -75,7 +75,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -97,7 +97,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource * @param \Magento\Framework\App\Resource $resource * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Config $catalogConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager */ @@ -105,7 +105,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource \Magento\Framework\App\Resource $resource, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Config $catalogConfig, \Magento\Framework\Event\ManagerInterface $eventManager ) { diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php index a25175d8bd0b1f57d48b21a095e765e7348f15a1..e91e35d297d107354045864470a084fd571773f7 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php @@ -28,7 +28,7 @@ use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; use Magento\Framework\Model\Resource\Db\AbstractDb; use Magento\Framework\Logger; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Catalog category flat collection @@ -54,7 +54,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -70,7 +70,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param Logger $logger * @param FetchStrategyInterface $fetchStrategy * @param ManagerInterface $eventManager - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection * @param AbstractDb $resource */ diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Tree.php b/app/code/Magento/Catalog/Model/Resource/Category/Tree.php index b330626f25cde7fe27d8d114d6ecf25954d2ab4e..c87b776ff1277d3905862f5d5346deae60c9a8e7 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Tree.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Tree.php @@ -91,7 +91,7 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -114,7 +114,7 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp * * @param \Magento\Catalog\Model\Resource\Category $catalogCategory * @param \Magento\Framework\App\CacheInterface $cache - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Attribute\Config $attributeConfig @@ -123,7 +123,7 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp public function __construct( \Magento\Catalog\Model\Resource\Category $catalogCategory, \Magento\Framework\App\CacheInterface $cache, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Resource $resource, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Attribute\Config $attributeConfig, diff --git a/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php b/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php index 70eb37b606d5a2ba9c3cd1c27ee9cb3ba57adab1..7694d497346155fb0d54d8ea976d7e295dad34c6 100644 --- a/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php +++ b/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php @@ -41,7 +41,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -55,7 +55,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -70,7 +70,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Resource/Config.php b/app/code/Magento/Catalog/Model/Resource/Config.php index 9027067a5ce520a31733db2f2c511a5d5c035cd7..174fb186153d896e8f018ca04d99055ec308ee1b 100644 --- a/app/code/Magento/Catalog/Model/Resource/Config.php +++ b/app/code/Magento/Catalog/Model/Resource/Config.php @@ -54,18 +54,18 @@ class Config extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php index e447bb073e5a717146b21d6db4094f07e5153095..2058d82898f250a244ae0829fa6b7b53b1ff255e 100644 --- a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php @@ -126,7 +126,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -146,7 +146,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute \Magento\Core\Helper\Data $coreData, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Catalog/Model/Resource/Product.php b/app/code/Magento/Catalog/Model/Resource/Product.php index c7b0aaefd0e4580e0d3ee2084a10fd03644b9d0e..9b7e0d30cc006f07456f1c72ab369d115fd3a251 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product.php +++ b/app/code/Magento/Catalog/Model/Resource/Product.php @@ -67,7 +67,7 @@ class Product extends AbstractResource * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Factory $modelFactory * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory * @param Category $catalogCategory @@ -82,7 +82,7 @@ class Product extends AbstractResource \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Factory $modelFactory, \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory, Category $catalogCategory, diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php index 2e64d42fa00ee597ec5627a144c0e021b9f53293..37d073c47f1f9fd69897065281fc348f3fd07556 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php @@ -268,7 +268,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -291,7 +291,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php index c7e7f2773f6fc2ddae5dfb7cdb3bef30b878bcc3..fc09bc0848d845209138fff668e5698c1fc34112 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php @@ -76,7 +76,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -101,7 +101,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php index 4be82c13741d52ee0fad81dff09c2d905f757887..9370d89bfbc811d9b2b58a726cc5adb1f25b1ceb 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php @@ -49,18 +49,18 @@ class Flat extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Config $catalogConfig */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Config $catalogConfig ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php index e2af327803e4ea452aa3f9001b5147be26165216..f66c51c7ce813c4a5b299146fffd3c4bb4d01325 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php @@ -163,7 +163,7 @@ class Source extends AbstractEav } /**@var $select \Magento\Framework\DB\Select*/ - $select = $adapter->select()->from( + $select = $adapter->select()->distinct(true)->from( array('pid' => new \Zend_Db_Expr(sprintf('(%s)', $subSelect->assemble()))), array() )->joinLeft( @@ -184,6 +184,11 @@ class Source extends AbstractEav $select->where($this->_resourceHelper->getIsNullNotNullCondition('pis.value', 'pid.value')); + /** + * Exclude attribute values that contains NULL + */ + $select->where('NOT(pis.value IS NULL AND pis.value_id IS NOT NULL)'); + /** * Add additional external limitation */ @@ -196,7 +201,6 @@ class Source extends AbstractEav 'store_field' => new \Zend_Db_Expr('pid.store_id') ) ); - $query = $select->insertFromSelect($idxTable); $adapter->query($query); diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option.php b/app/code/Magento/Catalog/Model/Resource/Product/Option.php index a87e5e2bdf8a77e2bef95e8554a17525a9eaae18..be50976351bbeedc4d1fc4fe63147d37b698f9e9 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option.php @@ -33,7 +33,7 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,13 +56,13 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { $this->_currencyFactory = $currencyFactory; diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php index cd11770bef684a2b1636470040de0bda794f29fc..104b47e7746efc18adc778c7dfb82ced9edc45f0 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php @@ -33,7 +33,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -50,7 +50,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $optionValueCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -60,7 +60,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $optionValueCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php index 741aa4c7c3ea1b065e341f5664495b0199efc65c..814ad21e9e23d2bd51ca0b0f1dcd394d39224792 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php @@ -33,7 +33,7 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,13 +56,13 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { $this->_currencyFactory = $currencyFactory; diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Website.php b/app/code/Magento/Catalog/Model/Resource/Product/Website.php index 4d992c66dafafe4af579036a4a9d2dbab6e5283e..8337c236092a9f8d428f4acf614975b18be37c01 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Website.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Website.php @@ -31,17 +31,17 @@ class Website extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; parent::__construct($resource); diff --git a/app/code/Magento/Catalog/Model/Resource/Url.php b/app/code/Magento/Catalog/Model/Resource/Url.php index 010e73a5f9bd10167dc8a312188f1be134ad449a..18e90d9608e1fe3d207397efbb30d61b769508bb 100644 --- a/app/code/Magento/Catalog/Model/Resource/Url.php +++ b/app/code/Magento/Catalog/Model/Resource/Url.php @@ -94,7 +94,7 @@ class Url extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -105,7 +105,7 @@ class Url extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param Product $productResource * @param \Magento\Catalog\Model\Category $catalogCategory @@ -113,7 +113,7 @@ class Url extends \Magento\Framework\Model\Resource\Db\AbstractDb */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, Product $productResource, \Magento\Catalog\Model\Category $catalogCategory, diff --git a/app/code/Magento/Catalog/Model/Template/Filter.php b/app/code/Magento/Catalog/Model/Template/Filter.php index 05ca31624675063a8d497abbd09ae0871f8cd150..912bea2a7bd7ba5d820616c690185582425cda90 100644 --- a/app/code/Magento/Catalog/Model/Template/Filter.php +++ b/app/code/Magento/Catalog/Model/Template/Filter.php @@ -55,19 +55,19 @@ class Filter extends \Magento\Framework\Filter\Template /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Stdlib\String $string - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param array $variables */ public function __construct( \Magento\Framework\Stdlib\String $string, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\Asset\Repository $assetRepo, $variables = array() ) { diff --git a/app/code/Magento/Catalog/Service/V1/Category/Tree/ReadService.php b/app/code/Magento/Catalog/Service/V1/Category/Tree/ReadService.php index 76f6fb52b3241efd848386e1e62d3c8716121240..ecbb191b2d9746b0bb5022d4e8f60f0eafc1211c 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/Tree/ReadService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/Tree/ReadService.php @@ -36,7 +36,7 @@ class ReadService implements ReadServiceInterface protected $categoryFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -48,12 +48,12 @@ class ReadService implements ReadServiceInterface /** * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Service\V1\Data\Category\Tree $categoryTree - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Service\V1\Data\Category\Tree $categoryTree, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->categoryFactory = $categoryFactory; $this->categoryTree = $categoryTree; diff --git a/app/code/Magento/Catalog/Service/V1/Category/WriteService.php b/app/code/Magento/Catalog/Service/V1/Category/WriteService.php index 8e0a607ff18689353e5051ed11393234ca12dcd0..e2725bf82094dc8372cb11457230ae8e2bdfb190 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/WriteService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/WriteService.php @@ -31,7 +31,7 @@ use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\StateException; use Magento\Catalog\Service\V1\Data\Category\Mapper as CategoryMapper; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class WriteService implements WriteServiceInterface { @@ -46,7 +46,7 @@ class WriteService implements WriteServiceInterface private $categoryMapper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -60,7 +60,7 @@ class WriteService implements WriteServiceInterface /** * @param CategoryFactory $categoryFactory * @param CategoryMapper $categoryMapper - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( CategoryFactory $categoryFactory, diff --git a/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php b/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php index e0eb7642466796bea9cd5c4532f79f1add38f0ad..f4d2d7bc6c1fae52d5ffb9cc5a0205c89a7f81bd 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php @@ -36,7 +36,7 @@ class Tree protected $categoryTree; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -52,13 +52,13 @@ class Tree /** * @param \Magento\Catalog\Model\Resource\Category\Tree $categoryTree - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Category\Collection $categoryCollection * @param \Magento\Catalog\Service\V1\Data\Eav\Category\TreeBuilderFactory $treeBuilderFactory */ public function __construct( \Magento\Catalog\Model\Resource\Category\Tree $categoryTree, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Category\Collection $categoryCollection, \Magento\Catalog\Service\V1\Data\Eav\Category\TreeBuilderFactory $treeBuilderFactory ) { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Converter.php b/app/code/Magento/Catalog/Service/V1/Data/Converter.php index 4059993b865b6b822c8fd220cd2a4943b8e69a11..1ecf2cc1c6f638f6b2012d33f843e3b793cc0387 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Converter.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Converter.php @@ -52,9 +52,20 @@ class Converter * @return \Magento\Catalog\Service\V1\Data\Product */ public function createProductDataFromModel(\Magento\Catalog\Model\Product $productModel) + { + return $this->createProductBuilderFromModel($productModel)->create(); + } + + /** + * Initialize product builder with product model data + * + * @param \Magento\Catalog\Model\Product $productModel + * @return \Magento\Catalog\Service\V1\Data\ProductBuilder + */ + public function createProductBuilderFromModel(\Magento\Catalog\Model\Product $productModel) { $this->populateBuilderWithAttributes($productModel); - return $this->productBuilder->create(); + return $this->productBuilder; } /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php b/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php index 6cf6786fb58d0cdf6dafb498ea1c49651b00cd22..77d992841d07cd2b74e6b5e0cb7747e1a2281339 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php +++ b/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php @@ -48,16 +48,18 @@ class ProductMapper /** * @param Product $product * @param \Magento\Catalog\Model\Product $productModel + * @param string[] $customAttributesToSkip * @return \Magento\Catalog\Model\Product * @throws \RuntimeException */ public function toModel( Product $product, - \Magento\Catalog\Model\Product $productModel = null + \Magento\Catalog\Model\Product $productModel = null, + $customAttributesToSkip = array() ) { /** @var \Magento\Catalog\Model\Product $productModel */ $productModel = $productModel ? : $this->productFactory->create(); - $productModel->addData(ExtensibleDataObjectConverter::toFlatArray($product)); + $productModel->addData(ExtensibleDataObjectConverter::toFlatArray($product, $customAttributesToSkip)); if (!is_numeric($productModel->getAttributeSetId())) { $productModel->setAttributeSetId($productModel->getDefaultAttributeSetId()); } diff --git a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadService.php b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadService.php index 22794baae06cc76865a54cb6fd83001c50bc3567..c6621813a6228854b3f759dbc789d018f164b9c2 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadService.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadService.php @@ -76,7 +76,7 @@ class ReadService implements ReadServiceInterface protected $attributeFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -86,7 +86,7 @@ class ReadService implements ReadServiceInterface * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaGallery * @param \Magento\Catalog\Model\Resource\Eav\AttributeFactory $attributeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param MediaImageBuilder $mediaImageBuilder * @param \Magento\Catalog\Model\ProductRepository $productRepository * @param GalleryEntryBuilder $galleryEntryBuilder @@ -97,7 +97,7 @@ class ReadService implements ReadServiceInterface \Magento\Eav\Model\Config $eavConfig, \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaGallery, \Magento\Catalog\Model\Resource\Eav\AttributeFactory $attributeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, MediaImageBuilder $mediaImageBuilder, \Magento\Catalog\Model\ProductRepository $productRepository, GalleryEntryBuilder $galleryEntryBuilder diff --git a/app/code/Magento/Catalog/Service/V1/Product/GroupPriceService.php b/app/code/Magento/Catalog/Service/V1/Product/GroupPriceService.php index 41729855bc5f65cf981a153967c4de250f4ba421..e8bb6563cfa8c9ca6c9526099c41786722b0f3dd 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/GroupPriceService.php +++ b/app/code/Magento/Catalog/Service/V1/Product/GroupPriceService.php @@ -43,7 +43,7 @@ class GroupPriceService implements GroupPriceServiceInterface protected $groupPriceBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -65,7 +65,7 @@ class GroupPriceService implements GroupPriceServiceInterface /** * @param ProductRepository $productRepository * @param Product\GroupPriceBuilder $groupPriceBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService * @param \Magento\Catalog\Model\Product\PriceModifier $priceModifier * @param \Magento\Framework\App\Config\ScopeConfigInterface $config @@ -73,7 +73,7 @@ class GroupPriceService implements GroupPriceServiceInterface public function __construct( ProductRepository $productRepository, Product\GroupPriceBuilder $groupPriceBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService, \Magento\Catalog\Model\Product\PriceModifier $priceModifier, \Magento\Framework\App\Config\ScopeConfigInterface $config diff --git a/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorComposite.php b/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorComposite.php new file mode 100644 index 0000000000000000000000000000000000000000..61718d1dd34fa551eff8bd82b4c176f1c7ccc19e --- /dev/null +++ b/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorComposite.php @@ -0,0 +1,72 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + +/** + * Composite loader of product data. + * + * Allows multiple loaders to be registered and used during product data loading. + */ +class ProductLoadProcessorComposite implements ProductLoadProcessorInterface +{ + /** + * @var ProductLoadProcessorInterface[] + */ + protected $productLoadProcessors = []; + + /** + * Register product load processors. + * + * @param CompositeHelper $compositeHelper + * @param array $loadProcessors Array of the processors which should be registered in the following format: + * <pre> + * [ + * ['type' => $firstProcessorObject, 'sortOrder' => 15], + * ['type' => $secondProcessorObject, 'sortOrder' => 10], + * ... + * ] + * </pre> + */ + public function __construct(CompositeHelper $compositeHelper, $loadProcessors = []) + { + $loadProcessors = $compositeHelper->filterAndSortDeclaredComponents($loadProcessors); + foreach ($loadProcessors as $loadProcessor) { + $this->productLoadProcessors[] = $loadProcessor['type']; + } + } + + /** + * {@inheritdoc} + */ + public function load($id, \Magento\Catalog\Service\V1\Data\ProductBuilder $productBuilder) + { + foreach ($this->productLoadProcessors as $loadProcessor) { + $loadProcessor->load($id, $productBuilder); + } + } +} diff --git a/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorInterface.php b/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..4cb4570f260e1f42c7d521ddc5bd90d7c50951be --- /dev/null +++ b/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorInterface.php @@ -0,0 +1,41 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +/** + * Interface for product data loading. + */ +interface ProductLoadProcessorInterface +{ + /** + * Load product data to the builder, which can be used to instantiate product object. + * + * @param string $id + * @param \Magento\Catalog\Service\V1\Data\ProductBuilder $productBuilder + * @return void + */ + public function load($id, \Magento\Catalog\Service\V1\Data\ProductBuilder $productBuilder); +} diff --git a/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorComposite.php b/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorComposite.php new file mode 100644 index 0000000000000000000000000000000000000000..ae87690b07dd815671a23d2a9365a8bf488fcecd --- /dev/null +++ b/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorComposite.php @@ -0,0 +1,109 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + +/** + * Composite pattern implementation for ProductSaveProcessorInterface. + * + * Allows multiple savers to be registered and used for product data modification. + */ +class ProductSaveProcessorComposite implements ProductSaveProcessorInterface +{ + /** + * @var ProductSaveProcessorInterface[] + */ + protected $productSaveProcessors = []; + + /** + * Register product save processors. + * + * @param CompositeHelper $compositeHelper + * @param array $saveProcessors Array of the processors which should be registered in the following format: + * <pre> + * [ + * ['type' => $firstProcessorObject, 'sortOrder' => 15], + * ['type' => $secondProcessorObject, 'sortOrder' => 10], + * ... + * ] + * </pre> + */ + public function __construct(CompositeHelper $compositeHelper, $saveProcessors = []) + { + $saveProcessors = $compositeHelper->filterAndSortDeclaredComponents($saveProcessors); + foreach ($saveProcessors as $saveProcessor) { + $this->productSaveProcessors[] = $saveProcessor['type']; + } + } + + /** + * {@inheritdoc} + */ + public function create( + \Magento\Catalog\Model\Product $product, + \Magento\Catalog\Service\V1\Data\Product $productData + ) { + foreach ($this->productSaveProcessors as $saveProcessor) { + $saveProcessor->create($product, $productData); + } + return $productData->getSku(); + } + + /** + * {@inheritdoc} + */ + public function afterCreate( + \Magento\Catalog\Model\Product $product, + \Magento\Catalog\Service\V1\Data\Product $productData + ) { + foreach ($this->productSaveProcessors as $saveProcessor) { + $saveProcessor->afterCreate($product, $productData); + } + return $productData->getSku(); + } + + /** + * {@inheritdoc} + */ + public function update($id, \Magento\Catalog\Service\V1\Data\Product $product) + { + foreach ($this->productSaveProcessors as $saveProcessor) { + $saveProcessor->update($id, $product); + } + return $product->getSku(); + } + + /** + * {@inheritdoc} + */ + public function delete(\Magento\Catalog\Service\V1\Data\Product $product) + { + foreach ($this->productSaveProcessors as $saveProcessor) { + $saveProcessor->delete($product); + } + } +} diff --git a/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorInterface.php b/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..48921dfd7ad84c014fc7d697dcd2627d09b156dd --- /dev/null +++ b/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorInterface.php @@ -0,0 +1,73 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +/** + * Interface for product data modification. + */ +interface ProductSaveProcessorInterface +{ + /** + * Create product. + * + * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Catalog\Service\V1\Data\Product $productData + * @return string id + */ + public function create( + \Magento\Catalog\Model\Product $product, + \Magento\Catalog\Service\V1\Data\Product $productData + ); + + /** + * Create product after the initial creation is complete. + * + * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Catalog\Service\V1\Data\Product $productData + * @return string id + */ + public function afterCreate( + \Magento\Catalog\Model\Product $product, + \Magento\Catalog\Service\V1\Data\Product $productData + ); + + /** + * Update product. + * + * @param string $sku + * @param \Magento\Catalog\Service\V1\Data\Product $product + * @return string id + */ + public function update($sku, \Magento\Catalog\Service\V1\Data\Product $product); + + /** + * Delete product. + * + * @param \Magento\Catalog\Service\V1\Data\Product $product + * @return void + */ + public function delete(\Magento\Catalog\Service\V1\Data\Product $product); +} diff --git a/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php b/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php index e50690efc28af8045741d2147f186ec66ff654a2..e00443d1f8aaa6e4cdf3ddc5448001f929f81235 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php +++ b/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php @@ -42,7 +42,7 @@ class TierPriceService implements TierPriceServiceInterface protected $priceBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -64,7 +64,7 @@ class TierPriceService implements TierPriceServiceInterface /** * @param ProductRepository $productRepository * @param Product\TierPriceBuilder $priceBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\PriceModifier $priceModifier * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService @@ -72,7 +72,7 @@ class TierPriceService implements TierPriceServiceInterface public function __construct( ProductRepository $productRepository, Product\TierPriceBuilder $priceBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\PriceModifier $priceModifier, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService diff --git a/app/code/Magento/Catalog/Service/V1/ProductService.php b/app/code/Magento/Catalog/Service/V1/ProductService.php index 9bb1d4d6d29234936ec9eccc488e49009a9fd1b9..839ca2fc5894712cc9b03783290d8dfac2324ff1 100644 --- a/app/code/Magento/Catalog/Service/V1/ProductService.php +++ b/app/code/Magento/Catalog/Service/V1/ProductService.php @@ -79,6 +79,16 @@ class ProductService implements ProductServiceInterface */ private $searchResultsBuilder; + /** + * @var \Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface + */ + private $productLoadProcessor; + + /** + * @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface + */ + private $productSaveProcessor; + /** * @param Product\Initialization\Helper $initializationHelper * @param Data\ProductMapper $productMapper @@ -88,6 +98,10 @@ class ProductService implements ProductServiceInterface * @param ProductMetadataServiceInterface $metadataService * @param \Magento\Catalog\Service\V1\Data\Converter $converter * @param \Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder $searchResultsBuilder + * @param \Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface $productLoadProcessor + * @param \Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface $productSaveProcessor + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( Product\Initialization\Helper $initializationHelper, @@ -97,7 +111,9 @@ class ProductService implements ProductServiceInterface \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollection, ProductMetadataServiceInterface $metadataService, \Magento\Catalog\Service\V1\Data\Converter $converter, - \Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder $searchResultsBuilder + \Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder $searchResultsBuilder, + \Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface $productLoadProcessor, + \Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface $productSaveProcessor ) { $this->initializationHelper = $initializationHelper; $this->productMapper = $productMapper; @@ -107,6 +123,8 @@ class ProductService implements ProductServiceInterface $this->metadataService = $metadataService; $this->converter = $converter; $this->searchResultsBuilder = $searchResultsBuilder; + $this->productLoadProcessor = $productLoadProcessor; + $this->productSaveProcessor = $productSaveProcessor; } /** @@ -115,10 +133,12 @@ class ProductService implements ProductServiceInterface public function create(\Magento\Catalog\Service\V1\Data\Product $product) { try { - $productModel = $this->productMapper->toModel($product); + $productModel = $this->productMapper->toModel($product, null, ['bundle_product_options']); $this->initializationHelper->initialize($productModel); + $this->productSaveProcessor->create($productModel, $product); $productModel->validate(); $productModel->save(); + $this->productSaveProcessor->afterCreate($productModel, $product); } catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) { throw \Magento\Framework\Exception\InputException::invalidFieldValue( $exception->getAttributeCode(), @@ -139,9 +159,10 @@ class ProductService implements ProductServiceInterface { $productModel = $this->productLoader->load($id); try { - $this->productMapper->toModel($product, $productModel); + $this->productMapper->toModel($product, $productModel, ['bundle_product_options']); $this->initializationHelper->initialize($productModel); $this->productTypeManager->processProduct($productModel); + $this->productSaveProcessor->update($id, $product); $productModel->validate(); $productModel->save(); } catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) { @@ -159,8 +180,12 @@ class ProductService implements ProductServiceInterface */ public function delete($id) { - $product = $this->productLoader->load($id); - $product->delete(); + $productModel = $this->productLoader->load($id); + + $productDataObject = $this->converter->createProductDataFromModel($productModel); + $this->productSaveProcessor->delete($productDataObject); + + $productModel->delete(); return true; } @@ -169,7 +194,9 @@ class ProductService implements ProductServiceInterface */ public function get($id) { - return $this->converter->createProductDataFromModel($this->productLoader->load($id)); + $productBuilder = $this->converter->createProductBuilderFromModel($this->productLoader->load($id)); + $this->productLoadProcessor->load($id, $productBuilder); + return $productBuilder->create(); } /** @@ -221,7 +248,9 @@ class ProductService implements ProductServiceInterface $products = array(); /** @var \Magento\Catalog\Model\Product $productModel */ foreach ($collection as $productModel) { - $products[] = $this->converter->createProductDataFromModel($productModel); + $productBuilder = $this->converter->createProductBuilderFromModel($productModel); + $this->productLoadProcessor->load($productModel->getSku(), $productBuilder); + $products[] = $productBuilder->create(); } $this->searchResultsBuilder->setItems($products); diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index f3ce62d8d406be2b73e280a603569e78557cbd0c..f655a3900de92fbe4c114a3d811501d06a4083d8 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -3,33 +3,33 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-log": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-bundle": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-catalog-rule": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog-search": "0.1.0-alpha94", - "magento/module-product-alert": "0.1.0-alpha94", - "magento/module-url-rewrite": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-log": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-bundle": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-catalog-rule": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog-search": "0.1.0-alpha95", + "magento/module-product-alert": "0.1.0-alpha95", + "magento/module-url-rewrite": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml index e0ffc5299d76f166f33d282829afef0001657810..b838bdd88f29576c23394ebd3d39f6a1f79172cc 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/di.xml +++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml @@ -30,11 +30,6 @@ <argument name="attributeLabelCache" xsi:type="object">Magento\Framework\App\Cache\Type\Translate</argument> </arguments> </type> - <type name="Magento\Catalog\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Catalog\Block\Adminhtml\Product\Frontend\Product\Watermark"> <arguments> <argument name="imageTypes" xsi:type="array"> diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 6cea44bd685884b6e3a8a0801ef1f0ea2ff9cc85..a0f16e2eef3febc6880fde00936bbb2a5fb42fba 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -66,6 +66,8 @@ <preference for="Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\ReaderInterface" type="Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\Reader" /> <preference for="Magento\Catalog\Service\V1\Product\CustomOptions\WriteServiceInterface" type="Magento\Catalog\Service\V1\Product\CustomOptions\WriteService" /> <preference for="Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\ConverterInterface" type="Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\Converter\Composite" /> + <preference for="Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface" type="Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite" /> + <preference for="Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface" type="Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite" /> <type name="Magento\Log\Model\Resource\Log"> <plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" /> </type> diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml index 51914835414d67ce56bd5947fb21232e1616503f..9665dcee2ad3fb143ca63d73eef0f873778799c8 100644 --- a/app/code/Magento/Catalog/etc/frontend/di.xml +++ b/app/code/Magento/Catalog/etc/frontend/di.xml @@ -24,11 +24,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Catalog\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Catalog\Model\Resource\Category\Collection"> <arguments> <argument name="fetchStrategy" xsi:type="object">Magento\Framework\Data\Collection\Db\FetchStrategy\Cache</argument> diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php index 10f60a27f71ccd1f839a822ac592b2b5eab846be..6c9bf078c50d4215895e0aac5184284945193289 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php @@ -218,7 +218,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $config * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Logger $logger * @param \Magento\Catalog\Model\Resource\Product\Collection $collection * @param \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig @@ -236,7 +236,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $config, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Logger $logger, \Magento\Catalog\Model\Resource\Product\Collection $collection, \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig, diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 2bc539809f5cd3623b90054ff099c18939b859fc..7bef8186538c2fd3dade77da6984b3fcb4d6397e 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -430,7 +430,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity protected $_productFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -507,7 +507,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryColFactory * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\CatalogImportExport\Model\Import\Product\Type\Factory $productTypeFactory * @param \Magento\Catalog\Model\Resource\Product\LinkFactory $linkFactory * @param \Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory $proxyProdFactory @@ -538,7 +538,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryColFactory, \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogImportExport\Model\Import\Product\Type\Factory $productTypeFactory, \Magento\Catalog\Model\Resource\Product\LinkFactory $linkFactory, \Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory $proxyProdFactory, diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php index 168dbb9978aeb8ddfa030d6774da0bd3c4440cc7..9c9a1c154a9e797b320b3ec12517913f4d5bf696 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php @@ -292,7 +292,7 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity protected $_resource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -320,7 +320,7 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * @param \Magento\ImportExport\Model\Resource\Import\Data $importData * @param \Magento\Framework\App\Resource $resource * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper - * @param \Magento\Store\Model\StoreManagerInterface $_storeManager + * @param \Magento\Framework\StoreManagerInterface $_storeManager * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Product\Option\CollectionFactory $optionColFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $colIteratorFactory @@ -335,7 +335,7 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity \Magento\ImportExport\Model\Resource\Import\Data $importData, \Magento\Framework\App\Resource $resource, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, - \Magento\Store\Model\StoreManagerInterface $_storeManager, + \Magento\Framework\StoreManagerInterface $_storeManager, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Resource\Product\Option\CollectionFactory $optionColFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $colIteratorFactory, diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index 6a9713aa174b0265881e75e2f6d4fe99cd8d9c07..9715aa6300f3a13a10ce902857293197406777b0 100644 --- a/app/code/Magento/CatalogImportExport/composer.json +++ b/app/code/Magento/CatalogImportExport/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-import-export": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-import-export": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php index 28607fe7f04442ce7b5c2f00cd7e951a8f53419f..78aabdd765e513df0fc41e8bd6a9115ebc66fbf6 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php @@ -32,7 +32,7 @@ use Magento\CatalogInventory\Model\Stock; class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -41,7 +41,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -50,7 +50,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php index e6db107f1ef7c015c25b6aeccb18fa933bfc3b57..dad09e3d5e96fe67994d7b749d31c0e17528eb7e 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php @@ -33,7 +33,7 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store model manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -51,13 +51,13 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Store\Model\WebsiteFactory $websiteFactory * @param \Magento\Eav\Model\Config $eavConfig */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Eav\Model\Config $eavConfig ) { diff --git a/app/code/Magento/CatalogInventory/Model/Stock.php b/app/code/Magento/CatalogInventory/Model/Stock.php index dc0245c89452fd8dce81379db6ced604ce553e9e..436680533d2619e2723d19ec46a22281dc176c9d 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Stock.php @@ -61,7 +61,7 @@ class Stock extends \Magento\Framework\Model\AbstractModel /** * Store model manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -88,7 +88,7 @@ class Stock extends \Magento\Framework\Model\AbstractModel * @param Resource\Stock\Item\CollectionFactory $collectionFactory * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService * @param Stock\Status $stockStatus - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Stock\ItemFactory $stockItemFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -101,7 +101,7 @@ class Stock extends \Magento\Framework\Model\AbstractModel \Magento\CatalogInventory\Model\Resource\Stock\Item\CollectionFactory $collectionFactory, \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, \Magento\CatalogInventory\Model\Stock\Status $stockStatus, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index 14b744233ac1ef33cefbf742e8817dd166d025e4..9653a6e97cb6c1ae8e8eeb4382b8b96eb5e939d0 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -203,7 +203,7 @@ class Item extends \Magento\Framework\Model\AbstractModel /** * Store model manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -252,7 +252,7 @@ class Item extends \Magento\Framework\Model\AbstractModel * @param ItemRegistry $stockItemRegistry * @param \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Framework\Math\Division $mathDivision * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -271,7 +271,7 @@ class Item extends \Magento\Framework\Model\AbstractModel \Magento\CatalogInventory\Model\Stock\ItemRegistry $stockItemRegistry, \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Framework\Math\Division $mathDivision, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Stock/Status.php index 69b4fd7e0bc4eae32e080fa25714c55e46b770c7..91ea17cbb782e773d220da4aa045ce654f77458b 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Status.php @@ -81,7 +81,7 @@ class Status extends \Magento\Framework\Model\AbstractModel /** * Store model manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -97,7 +97,7 @@ class Status extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param Type $productType * @param \Magento\Catalog\Model\Product\Website $productWebsite - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param ItemFactory $stockItemFactory * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -109,7 +109,7 @@ class Status extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Registry $registry, Type $productType, \Magento\Catalog\Model\Product\Website $productWebsite, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, ItemFactory $stockItemFactory, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index e621d13a2c8c24e5e87ad0b30c12d8ad5a61b4aa..ad583e88628a2bee5c7d7edf5c2bdf2a9f13891e 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogInventory/etc/adminhtml/system.xml b/app/code/Magento/CatalogInventory/etc/adminhtml/system.xml index 3fd2fa2ab2f2c6c97c83d2cfa05b544811d055be..a4cee45cfb0814d6dbd31293dccc73fe97685a82 100644 --- a/app/code/Magento/CatalogInventory/etc/adminhtml/system.xml +++ b/app/code/Magento/CatalogInventory/etc/adminhtml/system.xml @@ -35,7 +35,7 @@ <label>Decrease Stock When Order is Placed</label> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> </field> - <field id="can_back_in_stock" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <field id="can_back_in_stock" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="0" showInStore="0"> <label>Set Items' Status to be In Stock When Order is Cancelled</label> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> </field> diff --git a/app/code/Magento/CatalogRule/Model/Observer.php b/app/code/Magento/CatalogRule/Model/Observer.php index cf3ae5768117b843fa2fc7ba4ed323ab3cf03854..57eb2b22bc20115be566b2d1db09f60caf54d52e 100644 --- a/app/code/Magento/CatalogRule/Model/Observer.php +++ b/app/code/Magento/CatalogRule/Model/Observer.php @@ -35,7 +35,7 @@ use Magento\CatalogRule\Model\Rule; use Magento\CatalogRule\Model\Resource\Rule\Collection; use Magento\CatalogRule\Model\Rule\Product\Price; use Magento\Framework\Registry; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Customer\Service\V1\CustomerGroupServiceInterface as Group; use Magento\Customer\Model\Session as CustomerModelSession; diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule.php b/app/code/Magento/CatalogRule/Model/Resource/Rule.php index 182beb86d105aa562250f301be65d7afd2d0a06a..1b4315961fe35feb647e122b74558be5a18d46fb 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule.php @@ -95,7 +95,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource protected $_conditionFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -106,7 +106,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\ConditionFactory $conditionFactory * @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Eav\Model\Config $eavConfig @@ -117,7 +117,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\ConditionFactory $conditionFactory, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, \Magento\Eav\Model\Config $eavConfig, diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index 952c709389a72d0746c1b43bbe89cb36ba612028..212900131444917d890603e392a4a4fe3da51864 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -150,7 +150,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel protected $_productFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -170,7 +170,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\Framework\Data\FormFactory $formFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory * @param \Magento\CatalogRule\Model\Rule\Action\CollectionFactory $actionCollectionFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -191,7 +191,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory, \Magento\CatalogRule\Model\Rule\Action\CollectionFactory $actionCollectionFactory, \Magento\Catalog\Model\ProductFactory $productFactory, diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index 991455bb723c96d17ca4e0b64cc8a8fb70d9b31b..0d81e595a2642fbaa385951dcf7e374b0f450c23 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-rule": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-rule": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogSearch/Controller/Result/Index.php b/app/code/Magento/CatalogSearch/Controller/Result/Index.php index dcbe1c4d53d2bab52041256a6a2032868fffd3e8..dcfcd4c9374b92d390001aa88b87dfbca69e59c5 100644 --- a/app/code/Magento/CatalogSearch/Controller/Result/Index.php +++ b/app/code/Magento/CatalogSearch/Controller/Result/Index.php @@ -26,7 +26,7 @@ namespace Magento\CatalogSearch\Controller\Result; use Magento\Framework\App\Action\Context; use Magento\Catalog\Model\Session; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class Index extends \Magento\Framework\App\Action\Action { diff --git a/app/code/Magento/CatalogSearch/Helper/Data.php b/app/code/Magento/CatalogSearch/Helper/Data.php index 6e6d5317aaf1e644dccbc6deee65a183a57efce5..fda9eb9af5bf628b19457f712c0b5909dedc688a 100644 --- a/app/code/Magento/CatalogSearch/Helper/Data.php +++ b/app/code/Magento/CatalogSearch/Helper/Data.php @@ -34,7 +34,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Escaper; use Magento\Framework\Filter\FilterManager; use Magento\Framework\Stdlib\String; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Catalog search helper @@ -123,7 +123,7 @@ class Data extends AbstractHelper protected $filter; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; diff --git a/app/code/Magento/CatalogSearch/Model/Advanced.php b/app/code/Magento/CatalogSearch/Model/Advanced.php index 138588428880dab1ba0a2ec534b0dfed67074d47..98f994a5ba2e3d711505bdd4a0f479434a7f8b1e 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced.php @@ -34,7 +34,7 @@ use Magento\CatalogSearch\Model\Resource\EngineProvider; use Magento\Framework\Model\Exception; use Magento\Framework\Model\Context; use Magento\Framework\Registry; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Directory\Model\Currency; use Magento\Directory\Model\CurrencyFactory; use Magento\Eav\Model\Entity\Attribute as EntityAttribute; @@ -109,7 +109,7 @@ class Advanced extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -138,7 +138,7 @@ class Advanced extends \Magento\Framework\Model\AbstractModel * @param EngineProvider $engineProvider * @param CurrencyFactory $currencyFactory * @param ProductFactory $productFactory - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php index f3e0932fd33388b05a4a3edae4ea23437fa51767..7ae849cf2a8b61047239495fb67548977bb0e0b8 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php @@ -110,7 +110,7 @@ class Full /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -154,7 +154,7 @@ class Full * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -170,7 +170,7 @@ class Full \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\CatalogSearch\Helper\Data $catalogSearchData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Advanced.php b/app/code/Magento/CatalogSearch/Model/Layer/Advanced.php index 831dbe38d7e171c44b2668a69b6e49fc97991563..4914e56049d86bc93f63e30aebb61f1f26fcab4e 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Advanced.php @@ -37,7 +37,7 @@ class Advanced extends \Magento\Catalog\Model\Layer * @param CategoryFactory $categoryFactory * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -47,7 +47,7 @@ class Advanced extends \Magento\Catalog\Model\Layer CategoryFactory $categoryFactory, Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Advanced/CollectionFilter.php b/app/code/Magento/CatalogSearch/Model/Layer/Advanced/CollectionFilter.php index b0d7f3173ae30229be5fa2ff5121d67762c7fdbe..c5c486b14f42f8292d4d5825845d539a49a4b9a1 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Advanced/CollectionFilter.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Advanced/CollectionFilter.php @@ -39,7 +39,7 @@ class CollectionFilter implements CollectionFilterInterface protected $helper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -51,14 +51,14 @@ class CollectionFilter implements CollectionFilterInterface /** * @param \Magento\Catalog\Model\Config $catalogConfig * @param \Magento\CatalogSearch\Helper\Data $helper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Framework\Registry $registry */ public function __construct( \Magento\Catalog\Model\Config $catalogConfig, \Magento\CatalogSearch\Helper\Data $helper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Framework\Registry $registry ) { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Advanced/FilterableAttributeList.php b/app/code/Magento/CatalogSearch/Model/Layer/Advanced/FilterableAttributeList.php index d851bc4ba1ed59e7184a2e876b5952060d89e404..15f42e129d614f2d2c5b319e9c1f62d440769393 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Advanced/FilterableAttributeList.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Advanced/FilterableAttributeList.php @@ -29,12 +29,12 @@ class FilterableAttributeList extends \Magento\Catalog\Model\Layer\Category\Filt { /** * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\CatalogSearch\Model\Layer\Advanced $layer */ public function __construct( \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogSearch\Model\Layer\Advanced $layer ) { parent::__construct($collectionFactory, $storeManager, $layer); diff --git a/app/code/Magento/CatalogSearch/Model/Query.php b/app/code/Magento/CatalogSearch/Model/Query.php index 59057d2f9bd98a72c8ea34cadb15505a55f22db3..cdd362fcf72c255fd5b295d96c4b3121928eae52 100644 --- a/app/code/Magento/CatalogSearch/Model/Query.php +++ b/app/code/Magento/CatalogSearch/Model/Query.php @@ -32,7 +32,7 @@ use Magento\Framework\Model\Context; use Magento\Framework\Registry; use Magento\Framework\Model\Resource\AbstractResource; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Data\Collection\Db; use Magento\Eav\Model\Entity\Collection\AbstractCollection; diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php index 65efb780d6227683b761766b6026dd31b536a52d..007cebc8321f3920f61e646e49c2e64ffdbf91a0 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php @@ -40,7 +40,7 @@ class Advanced extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -48,12 +48,12 @@ class Advanced extends \Magento\Framework\Model\Resource\Db\AbstractDb * Construct * * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Event\ManagerInterface $eventManager */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Event\ManagerInterface $eventManager ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php index 4763a0154ce79a9264b849b5b157a862f9269e4f..e587c54cb600c2dde934fcf3bac7fe4c8b85022b 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php @@ -49,7 +49,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -73,7 +73,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php index c7302a4e4068df811acdb2f90ebcca3cdad2202b..d1d13e6386878f1fafc9e72df369bc68f7380345 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php @@ -54,7 +54,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -79,7 +79,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php index 7703c22e41f9dea10441d326a14d1208faa07aff..0922a799c3568f774c867bbaaff70e6966d6beba 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php @@ -42,7 +42,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -58,7 +58,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource @@ -68,7 +68,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php index d27a819b8db11811e3326dd01b3559ad1b8d4912..3644db6635e673500862d41d49339b0545597b33 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php @@ -61,7 +61,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -85,7 +85,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index fae48f2b90e61246336608e91e21b238d1132024..78c0be37f47fce993497e559c7c10106e01acdae 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml b/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml index cd88f320eefedf1140e99eb9c431d4add88a242b..3e337de8a9b924afe593a245c684240c5a0982de 100644 --- a/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml +++ b/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\CatalogSearch\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\CatalogSearch\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> </config> diff --git a/app/code/Magento/CatalogSearch/etc/di.xml b/app/code/Magento/CatalogSearch/etc/di.xml index 6b995a09fc79c0367850f1cf28852bb1f2d13d80..8f314df6174471c88af133f9485b2a12b736bc4f 100644 --- a/app/code/Magento/CatalogSearch/etc/di.xml +++ b/app/code/Magento/CatalogSearch/etc/di.xml @@ -61,4 +61,15 @@ <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> </arguments> </type> + <type name="Magento\Framework\Search\EntityMetadata" /> + <virtualType name="Magento\Framework\Search\ProductEntityMetadata" type="Magento\Framework\Search\EntityMetadata"> + <arguments> + <argument name="entityId" xsi:type="string">product_id</argument> + </arguments> + </virtualType> + <type name="Magento\Framework\Search\Adapter\Mysql\DocumentFactory"> + <arguments> + <argument name="entityId" xsi:type="object">Magento\Framework\Search\ProductEntityMetadata</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/CatalogSearch/etc/frontend/di.xml b/app/code/Magento/CatalogSearch/etc/frontend/di.xml index f69a0086554aa26c67147894c6872491b937c517..408654dcd259c19a7ccf4897c934cf0a26a9db71 100644 --- a/app/code/Magento/CatalogSearch/etc/frontend/di.xml +++ b/app/code/Magento/CatalogSearch/etc/frontend/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\CatalogSearch\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\CatalogSearch\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> <virtualType name="Magento\CatalogSearch\Block\SearchResult\ListProduct" type="Magento\Catalog\Block\Product\ListProduct"> diff --git a/app/code/Magento/CatalogSearch/etc/search_request.xml b/app/code/Magento/CatalogSearch/etc/search_request.xml new file mode 100644 index 0000000000000000000000000000000000000000..f1c6ef3c362b9bddd3bd017e30af05012896c7d6 --- /dev/null +++ b/app/code/Magento/CatalogSearch/etc/search_request.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd"> + <request query="quick_search_container" index="product"> + <dimensions> + <dimension name="scope" value="%scope_placeholder%" /> + </dimensions> + <queries> + <query xsi:type="matchQuery" name="quick_search_container"> + <match field="name" value="$search_term" boost="1" /> + <match field="sku" value="$search_term" boost="1" /> + <match field="description" value="$search_term" boost="1" /> + <match field="short_description" value="$search_term" boost="1" /> + <match field="price" value="$search_term" boost="1" /> + <match field="tax_class" value="$search_term" boost="1" /> + </query> + </queries> + <from>10</from> + <size>10</size> + </request> + <request query="advanced_search_container" index="product"> + <dimensions> + <dimension name="scope" value="%scope_placeholder%" /> + </dimensions> + <queries> + <query xsi:type="boolQuery" name="advanced_search_container" boost="1"> + <queryReference clause="should" ref="name_query" /> + <queryReference clause="should" ref="sku_query" /> + <queryReference clause="should" ref="description_query" /> + <queryReference clause="should" ref="short_description_query" /> + <queryReference clause="should" ref="price_query" /> + <queryReference clause="should" ref="tax_class_query" /> + </query> + <query xsi:type="matchQuery" name="name_query"> + <match field="name" value="$name" boost="1" /> + </query> + <query xsi:type="filteredQuery" name="sku_query"> + <filterReference ref="sku_query_filter" /> + </query> + <query xsi:type="matchQuery" name="description_query"> + <match field="description" value="$description" boost="1" /> + </query> + <query xsi:type="matchQuery" name="short_description_query"> + <match field="short_description" value="$short_description" boost="1" /> + </query> + <query xsi:type="filteredQuery" name="price_query"> + <filterReference ref="price_query_filter" /> + </query> + <query xsi:type="filteredQuery" name="tax_class_query"> + <filterReference ref="tax_class_query_filter" /> + </query> + </queries> + <filters> + <filter xsi:type="termFilter" name="sku_query_filter" field="sku" value="$sku" /> + <filter xsi:type="rangeFilter" name="price_query_filter" field="price" from="$price_from" to="$price_to" /> + <filter xsi:type="termFilter" name="tax_class_query_filter" field="tax_class" value="$tax_class" /> + </filters> + <from>10</from> + <size>10</size> + </request> +</requests> diff --git a/app/code/Magento/CatalogUrlRewrite/Helper/Data.php b/app/code/Magento/CatalogUrlRewrite/Helper/Data.php index 74ab3e84de1f8603a57e39b5e72e300ea00ae7c2..098a731a8aa379b3df1e9c3d3c03eddd334493da 100644 --- a/app/code/Magento/CatalogUrlRewrite/Helper/Data.php +++ b/app/code/Magento/CatalogUrlRewrite/Helper/Data.php @@ -30,7 +30,7 @@ use Magento\Catalog\Model\Product; use Magento\Eav\Model\Config; use Magento\Framework\App\Resource; use Magento\Store\Model\Store; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Service\V1\Data\Converter; use Magento\UrlRedirect\Service\V1\Data\UrlRewrite; @@ -62,7 +62,7 @@ class Data /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/CatalogUrlRewrite/Service/V1/AbstractUrlGenerator.php b/app/code/Magento/CatalogUrlRewrite/Service/V1/AbstractUrlGenerator.php index 3a6925dee2eab674d280e83ce30d3a43b3bd706f..73abbe199ddafdf81714c74e95d7f7e0d6cb69b3 100644 --- a/app/code/Magento/CatalogUrlRewrite/Service/V1/AbstractUrlGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Service/V1/AbstractUrlGenerator.php @@ -25,7 +25,7 @@ namespace Magento\CatalogUrlRewrite\Service\V1; use Magento\Catalog\Model\ProductFactory; use Magento\CatalogUrlRewrite\Helper\Data as CatalogUrlRewriteHelper; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Model\OptionProvider; use Magento\UrlRedirect\Service\V1\Data\Converter; use Magento\UrlRedirect\Service\V1\Data\FilterFactory; diff --git a/app/code/Magento/CatalogUrlRewrite/Service/V1/CategoryUrlGenerator.php b/app/code/Magento/CatalogUrlRewrite/Service/V1/CategoryUrlGenerator.php index cbb770f46f0af4abd836579aa61c265b0209ff13..31d86734e4673399e7c01726f3690fa912473341 100644 --- a/app/code/Magento/CatalogUrlRewrite/Service/V1/CategoryUrlGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Service/V1/CategoryUrlGenerator.php @@ -24,7 +24,7 @@ namespace Magento\CatalogUrlRewrite\Service\V1; use Magento\CatalogUrlRewrite\Helper\Data as CatalogUrlRewriteHelper; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Model\OptionProvider; use Magento\UrlRedirect\Service\V1\Data\FilterFactory; use Magento\UrlRedirect\Service\V1\UrlMatcherInterface; @@ -48,7 +48,7 @@ class CategoryUrlGenerator implements CategoryUrlGeneratorInterface /** * Store manager * - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -74,7 +74,7 @@ class CategoryUrlGenerator implements CategoryUrlGeneratorInterface /** * @param FilterFactory $filterFactory - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param UrlMatcherInterface $urlMatcher * @param CatalogUrlRewriteHelper $catalogUrlRewriteHelper */ diff --git a/app/code/Magento/CatalogUrlRewrite/Service/V1/ProductUrlGenerator.php b/app/code/Magento/CatalogUrlRewrite/Service/V1/ProductUrlGenerator.php index a6991bc1c0f24b2d1504526b05f49f0c7bc3b072..a41fd154e90ff9780b4b7009a9a4ec876dd0f9d7 100644 --- a/app/code/Magento/CatalogUrlRewrite/Service/V1/ProductUrlGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Service/V1/ProductUrlGenerator.php @@ -24,7 +24,7 @@ namespace Magento\CatalogUrlRewrite\Service\V1; use Magento\CatalogUrlRewrite\Helper\Data as CatalogUrlRewriteHelper; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Model\OptionProvider; use Magento\UrlRedirect\Service\V1\Data\FilterFactory; use Magento\UrlRedirect\Service\V1\UrlMatcherInterface; diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index 77746445869ab90229669115318a5ac0f728932c..ddac15070653c4c57bac7b736156829113fb5aa0 100644 --- a/app/code/Magento/CatalogUrlRewrite/composer.json +++ b/app/code/Magento/CatalogUrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-url-redirect": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/module-url-redirect": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/composer.json b/app/code/Magento/Centinel/composer.json index a4f821efb8665182b3dd4e29a1249522f0a849cd..36619e8fb2c0eb10c3170e524cfad819a12445c7 100644 --- a/app/code/Magento/Centinel/composer.json +++ b/app/code/Magento/Centinel/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/etc/adminhtml/di.xml b/app/code/Magento/Centinel/etc/adminhtml/di.xml index 49b1b49842184093e2f4923c797b4876ab198b50..9afea19d7047610325645a94224752f4d1a0a21e 100644 --- a/app/code/Magento/Centinel/etc/adminhtml/di.xml +++ b/app/code/Magento/Centinel/etc/adminhtml/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Centinel\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Centinel\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> <type name="Magento\Centinel\Model\Service"> diff --git a/app/code/Magento/Centinel/etc/frontend/di.xml b/app/code/Magento/Centinel/etc/frontend/di.xml index d7a868b509baa1c639787264151534b069cb9499..85c5c74c54d7ff175144260298b7959cdaafc1f4 100644 --- a/app/code/Magento/Centinel/etc/frontend/di.xml +++ b/app/code/Magento/Centinel/etc/frontend/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Centinel\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Centinel\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> <type name="Magento\Core\Model\Url\SecurityInfo"> diff --git a/app/code/Magento/Checkout/Controller/Cart.php b/app/code/Magento/Checkout/Controller/Cart.php index 865c4478acc87c5eb8d35e449f946fb3b11c5f73..b825d6d2687466048a329230f46f34c247feda46 100644 --- a/app/code/Magento/Checkout/Controller/Cart.php +++ b/app/code/Magento/Checkout/Controller/Cart.php @@ -42,7 +42,7 @@ class Cart extends \Magento\Framework\App\Action\Action implements ViewInterface protected $_checkoutSession; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,7 +60,7 @@ class Cart extends \Magento\Framework\App\Action\Action implements ViewInterface * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator * @param CustomerCart $cart */ @@ -68,7 +68,7 @@ class Cart extends \Magento\Framework\App\Action\Action implements ViewInterface \Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, CustomerCart $cart ) { diff --git a/app/code/Magento/Checkout/Controller/Cart/Add.php b/app/code/Magento/Checkout/Controller/Cart/Add.php index b6cc05214d12b621cb38d9ba50dd0c2e051ec2aa..3a5faa119eb64210a875a12547fc407746f6563c 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Add.php +++ b/app/code/Magento/Checkout/Controller/Cart/Add.php @@ -35,7 +35,7 @@ class Add extends \Magento\Checkout\Controller\Cart { $productId = (int)$this->getRequest()->getParam('product'); if ($productId) { - $storeId = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId(); + $storeId = $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getId(); $product = $this->_objectManager->create( 'Magento\Catalog\Model\Product' )->setStoreId( diff --git a/app/code/Magento/Checkout/Controller/Cart/Index.php b/app/code/Magento/Checkout/Controller/Cart/Index.php index 10e0e0d11ce1ccdd0105cfa2a50211b7a89c3e19..4f7b5e439c0add9a6c716f051ba3742662ec6ac8 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Index.php +++ b/app/code/Magento/Checkout/Controller/Cart/Index.php @@ -39,7 +39,7 @@ class Index extends \Magento\Checkout\Controller\Cart if (!$this->cart->getQuote()->validateMinimumAmount()) { $currencyCode = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getCurrentCurrencyCode(); $minimumAmount = $this->_objectManager->get( 'Magento\Framework\Locale\CurrencyInterface' diff --git a/app/code/Magento/Checkout/Controller/Onepage/Index.php b/app/code/Magento/Checkout/Controller/Onepage/Index.php index a9e34d5ef0b98eade7f279681ebd646d4d53dd6e..d83225b5114a18cf98f5b56d6f941a985cdab88e 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/Index.php +++ b/app/code/Magento/Checkout/Controller/Onepage/Index.php @@ -44,6 +44,7 @@ class Index extends \Magento\Checkout\Controller\Onepage return; } + $this->_customerSession->regenerateId(); $this->_objectManager->get('Magento\Checkout\Model\Session')->setCartWasUpdated(false); $currentUrl = $this->_objectManager->create('Magento\Framework\UrlInterface') ->getUrl( diff --git a/app/code/Magento/Checkout/Helper/Cart.php b/app/code/Magento/Checkout/Helper/Cart.php index e1137ecb82690100e34d141f10608450be9cb73c..98295d3060a12e5dc3fb81f63d1fd929562982ef 100644 --- a/app/code/Magento/Checkout/Helper/Cart.php +++ b/app/code/Magento/Checkout/Helper/Cart.php @@ -71,7 +71,7 @@ class Cart extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Cart $checkoutCart @@ -79,7 +79,7 @@ class Cart extends \Magento\Core\Helper\Url */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Cart $checkoutCart, diff --git a/app/code/Magento/Checkout/Helper/Data.php b/app/code/Magento/Checkout/Helper/Data.php index e1733995be2cc9f6e32f02d920ceba46f02c8a89..ed2b7264a87da19dd486a26ccf6c46deab9c2465 100644 --- a/app/code/Magento/Checkout/Helper/Data.php +++ b/app/code/Magento/Checkout/Helper/Data.php @@ -45,7 +45,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -72,7 +72,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder @@ -81,7 +81,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, diff --git a/app/code/Magento/Checkout/Model/Cart.php b/app/code/Magento/Checkout/Model/Cart.php index 5b9813aa09c9661c1749eadd4a615d6dca31d509..a3760e04cedc7cda82114385da40719bbcb11f63 100644 --- a/app/code/Magento/Checkout/Model/Cart.php +++ b/app/code/Magento/Checkout/Model/Cart.php @@ -59,7 +59,7 @@ class Cart extends \Magento\Framework\Object implements \Magento\Checkout\Model\ protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -97,7 +97,7 @@ class Cart extends \Magento\Framework\Object implements \Magento\Checkout\Model\ * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Checkout\Model\Resource\Cart $resourceCart * @param Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession @@ -109,7 +109,7 @@ class Cart extends \Magento\Framework\Object implements \Magento\Checkout\Model\ \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Checkout\Model\Resource\Cart $resourceCart, Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php index e217ec2ef69aa7fcf3ee46301a8d063da765a40b..07ed03d5505e5ec988de9dba9efb4eb95728f541 100644 --- a/app/code/Magento/Checkout/Model/Session.php +++ b/app/code/Magento/Checkout/Model/Session.php @@ -88,7 +88,7 @@ class Session extends \Magento\Framework\Session\SessionManager protected $_eventManager; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -106,7 +106,7 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param null $sessionName */ public function __construct( @@ -123,8 +123,7 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, - $sessionName = null + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_orderFactory = $orderFactory; $this->_customerSession = $customerSession; @@ -142,7 +141,7 @@ class Session extends \Magento\Framework\Session\SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start($sessionName); + $this->start(); } /** diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index 327dfe6f02f365302a09d8e02d576e67e8b99028..6c353ca06c6faa6986dd73b778cf138a1e2c4b58 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -87,7 +87,7 @@ class Onepage protected $_eventManager = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -161,7 +161,7 @@ class Onepage * @param \Magento\Framework\Logger $logger * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Customer\Model\AddressFactory $customrAddrFactory * @param \Magento\Customer\Model\FormFactory $customerFormFactory @@ -186,7 +186,7 @@ class Onepage \Magento\Framework\Logger $logger, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Customer\Model\AddressFactory $customrAddrFactory, \Magento\Customer\Model\FormFactory $customerFormFactory, diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php index 8c2fa58e98b01c93ee46f934da0d92794eeeb8e6..503da90a8b179db7fa6e2ebd3b83d477869e0eff 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php @@ -39,19 +39,19 @@ class ReadService implements ReadServiceInterface protected $addressConverter; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader * @param AddressConverter $addressConverter - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, AddressConverter $addressConverter, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteLoader = $quoteLoader; $this->addressConverter = $addressConverter; diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php index c94d3dc4b18e05f8c58606f7a973f4b0350b0a0d..a965c7067ea1eb25939266ac89b32993cf515c06 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php @@ -28,7 +28,7 @@ use Magento\Framework\Exception\InputException; use Magento\Framework\Logger; use \Magento\Checkout\Service\V1\QuoteLoader; use \Magento\Sales\Model\Quote\AddressFactory; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Checkout\Service\V1\Address\Converter; use \Magento\Checkout\Service\V1\Address\Validator; diff --git a/app/code/Magento/Checkout/Service/V1/Address/Converter.php b/app/code/Magento/Checkout/Service/V1/Address/Converter.php index 17b70ef827d531d364636ec73752d81eb64df1f2..b282663988b532e9a2b33b95d3cc7771eb88d3da 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Converter.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Converter.php @@ -85,7 +85,7 @@ class Converter foreach ($this->metadataService->getCustomAttributesMetadata() as $attributeMetadata) { $attributeCode = $attributeMetadata->getAttributeCode(); - $method = 'get' . SimpleDataObjectConverter::snakeCaseToCamelCase($attributeCode); + $method = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode); $data[Address::CUSTOM_ATTRIBUTES_KEY][] = [AttributeValue::ATTRIBUTE_CODE => $attributeCode, AttributeValue::VALUE => $address->$method()]; } diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php index 4c3e9289a4806301fb04e3f17e5012545e667d18..ee81610db5641a0119a4b9c61cb42ad9e9cb95fc 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php @@ -40,19 +40,19 @@ class ReadService implements ReadServiceInterface protected $addressConverter; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader * @param AddressConverter $addressConverter - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, AddressConverter $addressConverter, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteLoader = $quoteLoader; $this->addressConverter = $addressConverter; diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php index 96276b6fd7badfb149a9ffae65701c8dc1ee0446..abf6cae32c9bd8bc243e4e5d3275817987a903e6 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php @@ -36,7 +36,7 @@ class WriteService implements WriteServiceInterface protected $quoteLoader; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -62,7 +62,7 @@ class WriteService implements WriteServiceInterface /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Checkout\Service\V1\Address\Converter $addressConverter * @param \Magento\Checkout\Service\V1\Address\Validator $addressValidator * @param \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory @@ -70,7 +70,7 @@ class WriteService implements WriteServiceInterface */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Checkout\Service\V1\Address\Converter $addressConverter, \Magento\Checkout\Service\V1\Address\Validator $addressValidator, \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory, diff --git a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php index 9ea16bab045b9e687a585717515c1abcd1f0a23e..fed2d2b7b45eaff5d85364daf5728224ae6488f6 100644 --- a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php @@ -36,7 +36,7 @@ class WriteService implements WriteServiceInterface protected $quoteFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -47,12 +47,12 @@ class WriteService implements WriteServiceInterface /** * @param \Magento\Sales\Model\QuoteFactory $quoteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\CustomerRegistry $customerRegistry */ public function __construct( \Magento\Sales\Model\QuoteFactory $quoteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\CustomerRegistry $customerRegistry ) { $this->quoteFactory = $quoteFactory; diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php b/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php index de967a49e0b379a92fd1b0b60c9e4a59c6446b90..948871502fc3cf1e43d80f8c3df07d62c43d0d77 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php @@ -42,19 +42,19 @@ class ReadService implements ReadServiceInterface protected $couponBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader * @param CouponBuilder $couponBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, CouponBuilder $couponBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteLoader = $quoteLoader; $this->couponBuilder = $couponBuilder; diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php b/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php index 5fef831aadbe61f29f6042ce9d8d09357092eb6e..33dbe23e25047226148961c9bb802a46a9d3f4a2 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php @@ -44,19 +44,19 @@ class WriteService implements WriteServiceInterface protected $couponBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader * @param CouponBuilder $couponBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, CouponBuilder $couponBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteLoader = $quoteLoader; $this->couponBuilder = $couponBuilder; diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php index 584ba7c8eab1d73debf3a592efcba1bb51e47d99..adeadd88a3f81e5db7fc0aaf522140d78d3a7665 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php @@ -37,11 +37,11 @@ class ShippingMethodConverter /** * @param ShippingMethodBuilder $builder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $builder, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->builder = $builder; $this->storeManager = $storeManager; diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php index 9a7939c873391f6f6eca249da5dd2fdea7ec62d8..dfc0d2c008618c2a36d4c06f968f60ddf3abf240 100644 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php @@ -25,7 +25,7 @@ namespace Magento\Checkout\Service\V1\PaymentMethod; use \Magento\Checkout\Service\V1\QuoteLoader; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter as QuoteMethodConverter; use Magento\Checkout\Service\V1\Data\PaymentMethod\Converter as PaymentMethodConverter; use \Magento\Payment\Model\MethodList; diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php index bdc62911779f00d26d504d23afd7ba5eb0b2a4e4..b162bce65ef16fa49b2b3cc03c9a15dafbf385a9 100644 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php @@ -25,7 +25,7 @@ namespace Magento\Checkout\Service\V1\PaymentMethod; use \Magento\Checkout\Service\V1\QuoteLoader; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder; use \Magento\Framework\Exception\State\InvalidTransitionException; use \Magento\Payment\Model\MethodList; @@ -33,7 +33,7 @@ use \Magento\Payment\Model\MethodList; class WriteService implements WriteServiceInterface { /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -54,7 +54,7 @@ class WriteService implements WriteServiceInterface /** * @param QuoteLoader $quoteLoader - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Builder $paymentMethodBuilder * @param \Magento\Payment\Model\Checks\ZeroTotal $zeroTotalValidator */ diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php index 267aab7debd26b7a3b923770e971dc549dcd70d2..370d45b8462155c5b74ce4daa18c0ea23173eb20 100644 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php @@ -37,7 +37,7 @@ class ReadService implements ReadServiceInterface protected $quoteLoader; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -53,13 +53,13 @@ class ReadService implements ReadServiceInterface /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter $converter * @param ShippingMethodBuilder $methodBuilder */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter $converter, \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $methodBuilder ) { diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php index 1d648df3b0742d77187dfec645e0c06cfaf54c5f..91069b36753d5b19b22b28a130e120f7c340a671 100644 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php @@ -41,17 +41,17 @@ class WriteService implements WriteServiceInterface protected $quoteLoader; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Quote\AddressFactory $addressFactory * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Quote\AddressFactory $addressFactory, \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader ) { diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index eaf6d3af7233bede0737e4af26294fc8c699defc..36015c01be5a21356f520baf46de309b85aab970 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Checkout/etc/frontend/di.xml b/app/code/Magento/Checkout/etc/frontend/di.xml index d59e3e04eeb41d55542eab0817136315ce395878..300d93907ef1ec9663d139d4116199d6e559cb6d 100644 --- a/app/code/Magento/Checkout/etc/frontend/di.xml +++ b/app/code/Magento/Checkout/etc/frontend/di.xml @@ -24,11 +24,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Checkout\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/code/Magento/CheckoutAgreements/Model/AgreementsProvider.php b/app/code/Magento/CheckoutAgreements/Model/AgreementsProvider.php index 5df05f6675f109c4383eeeb87bf59cca4cca859e..2d24fe98aa5f0094fb2d66afd55578d14fd4a28b 100644 --- a/app/code/Magento/CheckoutAgreements/Model/AgreementsProvider.php +++ b/app/code/Magento/CheckoutAgreements/Model/AgreementsProvider.php @@ -40,17 +40,17 @@ class AgreementsProvider implements AgreementsProviderInterface /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $scopeConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param Resource\Agreement\CollectionFactory $agreementCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\CheckoutAgreements\Model\Resource\Agreement\CollectionFactory $agreementCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $this->agreementCollectionFactory = $agreementCollectionFactory; diff --git a/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php b/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php index 8671e62df157a0782935e1c6511f2b1d760779dd..25bb597d6a2a5b3edeed29196ff5b42584973d21 100644 --- a/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php +++ b/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php @@ -27,7 +27,7 @@ use \Magento\CheckoutAgreements\Model\Resource\Agreement\CollectionFactory as Ag use \Magento\CheckoutAgreements\Model\Resource\Agreement\Collection as AgreementCollection; use \Magento\CheckoutAgreements\Model\Agreement; use \Magento\Framework\App\Config\ScopeConfigInterface; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Store\Model\ScopeInterface; use \Magento\CheckoutAgreements\Service\V1\Data\AgreementBuilder; use \Magento\CheckoutAgreements\Service\V1\Data\Agreement as AgreementDataObject; @@ -45,7 +45,7 @@ class ReadService implements ReadServiceInterface private $agreementBuilder; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $storeManager; @@ -57,7 +57,7 @@ class ReadService implements ReadServiceInterface /** * @param AgreementCollectionFactory $collectionFactory * @param AgreementBuilder $agreementBuilder - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param ScopeConfigInterface $scopeConfig */ public function __construct( diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index 4c1983ff11dad7483534beadded02c80c7f165ec..050712e044196811972a0b196f613d6603b24c92 100644 --- a/app/code/Magento/CheckoutAgreements/composer.json +++ b/app/code/Magento/CheckoutAgreements/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/Block/Block.php b/app/code/Magento/Cms/Block/Block.php index 2ad0a7535835f5706bab55c6c9b034d5b6a302c8..6a25831bb79a7318fc336a894e1f7d42500ecfaa 100644 --- a/app/code/Magento/Cms/Block/Block.php +++ b/app/code/Magento/Cms/Block/Block.php @@ -36,7 +36,7 @@ class Block extends \Magento\Framework\View\Element\AbstractBlock implements \Ma /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -52,14 +52,14 @@ class Block extends \Magento\Framework\View\Element\AbstractBlock implements \Ma * * @param \Magento\Framework\View\Element\Context $context * @param \Magento\Cms\Model\Template\FilterProvider $filterProvider - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Cms\Model\BlockFactory $blockFactory * @param array $data */ public function __construct( \Magento\Framework\View\Element\Context $context, \Magento\Cms\Model\Template\FilterProvider $filterProvider, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Cms\Model\BlockFactory $blockFactory, array $data = array() ) { diff --git a/app/code/Magento/Cms/Block/Page.php b/app/code/Magento/Cms/Block/Page.php index b43fbe302312a9dcce9ee5eeabacb8e35fc3db86..8d5c12fb7a6dca90d84df8a72fde340a2d85d43f 100644 --- a/app/code/Magento/Cms/Block/Page.php +++ b/app/code/Magento/Cms/Block/Page.php @@ -41,7 +41,7 @@ class Page extends \Magento\Framework\View\Element\AbstractBlock implements \Mag /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -63,7 +63,7 @@ class Page extends \Magento\Framework\View\Element\AbstractBlock implements \Mag * @param \Magento\Framework\View\Element\Context $context * @param \Magento\Cms\Model\Page $page * @param \Magento\Cms\Model\Template\FilterProvider $filterProvider - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Cms\Model\PageFactory $pageFactory * @param \Magento\Framework\View\Page\Config $pageConfig * @param array $data @@ -72,7 +72,7 @@ class Page extends \Magento\Framework\View\Element\AbstractBlock implements \Mag \Magento\Framework\View\Element\Context $context, \Magento\Cms\Model\Page $page, \Magento\Cms\Model\Template\FilterProvider $filterProvider, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Cms\Model\PageFactory $pageFactory, \Magento\Framework\View\Page\Config $pageConfig, array $data = array() diff --git a/app/code/Magento/Cms/Controller/Router.php b/app/code/Magento/Cms/Controller/Router.php index a2f2f53527b03f9abcaad85bc51789ed5ee7efa3..528481c8ba3f7defe273dd4149ae8c7cd8ca258c 100644 --- a/app/code/Magento/Cms/Controller/Router.php +++ b/app/code/Magento/Cms/Controller/Router.php @@ -45,7 +45,7 @@ class Router implements \Magento\Framework\App\RouterInterface /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -81,24 +81,21 @@ class Router implements \Magento\Framework\App\RouterInterface * @param \Magento\Framework\App\ActionFactory $actionFactory * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Framework\App\State $appState * @param \Magento\Cms\Model\PageFactory $pageFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\ResponseInterface $response */ public function __construct( \Magento\Framework\App\ActionFactory $actionFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\UrlInterface $url, - \Magento\Framework\App\State $appState, \Magento\Cms\Model\PageFactory $pageFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\ResponseInterface $response ) { $this->actionFactory = $actionFactory; $this->_eventManager = $eventManager; $this->_url = $url; - $this->_appState = $appState; $this->_pageFactory = $pageFactory; $this->_storeManager = $storeManager; $this->_response = $response; @@ -109,16 +106,9 @@ class Router implements \Magento\Framework\App\RouterInterface * * @param \Magento\Framework\App\RequestInterface $request * @return bool - * - * @SuppressWarnings(PHPMD.ExitExpression) */ public function match(\Magento\Framework\App\RequestInterface $request) { - if (!$this->_appState->isInstalled()) { - $this->_response->setRedirect($this->_url->getUrl('install'))->sendResponse(); - exit; - } - $identifier = trim($request->getPathInfo(), '/'); $condition = new \Magento\Framework\Object(array('identifier' => $identifier, 'continue' => true)); diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php index cfea022b04e6851de955316044bd717095391af0..525f8e92305f4e6b006c257624868e1b45bd61ef 100644 --- a/app/code/Magento/Cms/Helper/Page.php +++ b/app/code/Magento/Cms/Helper/Page.php @@ -70,7 +70,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -102,7 +102,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Cms\Model\Page $page * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Cms\Model\PageFactory $pageFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Escaper $escaper * @param \Magento\Framework\App\ViewInterface $view @@ -114,7 +114,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Cms\Model\Page $page, \Magento\Framework\View\DesignInterface $design, \Magento\Cms\Model\PageFactory $pageFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Escaper $escaper, \Magento\Framework\App\ViewInterface $view, diff --git a/app/code/Magento/Cms/Helper/Wysiwyg/Images.php b/app/code/Magento/Cms/Helper/Wysiwyg/Images.php index fa787e420dc4c3d5edcf8f8a5cf44ae33f07eb73..c8b0aa35b4e16494876484dc79556eb7ba68f250 100644 --- a/app/code/Magento/Cms/Helper/Wysiwyg/Images.php +++ b/app/code/Magento/Cms/Helper/Wysiwyg/Images.php @@ -69,7 +69,7 @@ class Images extends \Magento\Framework\App\Helper\AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -80,14 +80,14 @@ class Images extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Backend\Helper\Data $backendData * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\App\Filesystem $filesystem - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Backend\Helper\Data $backendData, \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Filesystem $filesystem, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($context); $this->_backendData = $backendData; diff --git a/app/code/Magento/Cms/Model/Resource/Block.php b/app/code/Magento/Cms/Model/Resource/Block.php index a7a51f5f4d3a6a2e48ab96090d587bff39f44de3..571576375866d49aff3ca22c93503692edf340fd 100644 --- a/app/code/Magento/Cms/Model/Resource/Block.php +++ b/app/code/Magento/Cms/Model/Resource/Block.php @@ -36,7 +36,7 @@ class Block extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -45,12 +45,12 @@ class Block extends \Magento\Framework\Model\Resource\Db\AbstractDb * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime\DateTime $date - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($resource); $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Cms/Model/Resource/Page.php b/app/code/Magento/Cms/Model/Resource/Page.php index d34e800e7fb713c6e7218e72273663f7324a8edf..90796013df2296eaa044ce5b22b91b506d1fd1ac 100644 --- a/app/code/Magento/Cms/Model/Resource/Page.php +++ b/app/code/Magento/Cms/Model/Resource/Page.php @@ -43,7 +43,7 @@ class Page extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -62,14 +62,14 @@ class Page extends \Magento\Framework\Model\Resource\Db\AbstractDb * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime\DateTime $date - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Filter\FilterManager $filter */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Filter\FilterManager $filter ) { diff --git a/app/code/Magento/Cms/Model/Resource/Page/Collection.php b/app/code/Magento/Cms/Model/Resource/Page/Collection.php index e2728697243a14273087235f3102415340731c36..030486139be9a1a8d8103d7e63c1d2b7efa97b48 100644 --- a/app/code/Magento/Cms/Model/Resource/Page/Collection.php +++ b/app/code/Magento/Cms/Model/Resource/Page/Collection.php @@ -38,7 +38,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -47,7 +47,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -56,7 +56,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index c640be2d979df5e98adb9b10177fa3e0f1b8a29e..0a450210906c9943ec3a6c825f0ad2f5df58ae95 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -3,19 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-email": "0.1.0-alpha94", - "magento/module-install": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-email": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0-1.6.0.1.php b/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0-1.6.0.1.php index b201c72f7e3855ff401dc122ea78550fa21f318c..ce4239a009455cc87495bf588800f98c627c89aa 100644 --- a/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0-1.6.0.1.php +++ b/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0-1.6.0.1.php @@ -150,10 +150,6 @@ $pageContent = <<<EOD <th>COMPARE</th> <td>The items that you have in the Compare Products list.</td> </tr> - <tr> - <th>CURRENCY</th> - <td>Your preferred currency</td> - </tr> <tr> <th>CUSTOMER</th> <td>An encrypted version of your customer id with the store.</td> diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index 0258aa60d6e0cb8e7299aa138df9c4edb622fcbb..24d9c5e083a8550fa4a48ce8ff4142549783121c 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -39,7 +39,6 @@ <module name="Magento_Backend"/> <module name="Magento_Catalog"/> <module name="Magento_Email"/> - <module name="Magento_Install"/> </depends> </module> </config> diff --git a/app/code/Magento/CmsUrlRewrite/Service/V1/CmsPageUrlGenerator.php b/app/code/Magento/CmsUrlRewrite/Service/V1/CmsPageUrlGenerator.php index eda0815e280a78a810040769996f8119177ddea8..076448145b63b1cae709c6e9797596596c3a7773 100644 --- a/app/code/Magento/CmsUrlRewrite/Service/V1/CmsPageUrlGenerator.php +++ b/app/code/Magento/CmsUrlRewrite/Service/V1/CmsPageUrlGenerator.php @@ -23,7 +23,7 @@ */ namespace Magento\CmsUrlRewrite\Service\V1; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Service\V1\Data\Converter; use Magento\UrlRedirect\Service\V1\Data\UrlRewrite; diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index 340a21129095a1d6bd65e052fae731ca6df35ef0..c4e60a26ee1435b2e5435f035fe4bd541fa990db 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -3,12 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-url-redirect": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-url-redirect": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CmsUrlRewrite/etc/module.xml b/app/code/Magento/CmsUrlRewrite/etc/module.xml index 8df04efdd0440c97e3c5324681c1ef535259fa43..7d40a61c1068d167bfe6483a99abed44ead8052e 100644 --- a/app/code/Magento/CmsUrlRewrite/etc/module.xml +++ b/app/code/Magento/CmsUrlRewrite/etc/module.xml @@ -26,7 +26,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_CmsUrlRewrite" schema_version="1.0.0.0" active="false"> <depends> - <module name="Magento_Store"/> <module name="Magento_UrlRedirect"/> </depends> </module> diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json index a225386a7488ddc02cefc797841e1f771d3ae1a6..b84ae5a7bcf9f92e126b7681fbe48c2085095880 100644 --- a/app/code/Magento/ConfigurableImportExport/composer.json +++ b/app/code/Magento/ConfigurableImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-import-export": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-import-export": "0.1.0-alpha94", - "magento/module-configurable-product": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-import-export": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-import-export": "0.1.0-alpha95", + "magento/module-configurable-product": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php index a03b2afd35ce4721ef137696c6e3cd17238be588..55b388d494f340843a00cf42aca2490df4db4d5f 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php @@ -39,18 +39,28 @@ class SuggestConfigurableAttributes extends Action */ protected $coreHelper; + /** + * Store manager + * + * @var \Magento\Framework\StoreManagerInterface + */ + protected $storeManager; + /** * @param Action\Context $context * @param SuggestedAttributeList $attributeList * @param \Magento\Core\Helper\Data $coreHelper + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( Action\Context $context, SuggestedAttributeList $attributeList, - \Magento\Core\Helper\Data $coreHelper + \Magento\Core\Helper\Data $coreHelper, + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->attributeList = $attributeList; $this->coreHelper = $coreHelper; + $this->storeManager = $storeManager; parent::__construct($context); } @@ -71,6 +81,8 @@ class SuggestConfigurableAttributes extends Action */ public function execute() { + $this->storeManager->setCurrentStore(\Magento\Store\Model\Store::ADMIN_CODE); + $this->getResponse()->representJson( $this->coreHelper->jsonEncode( $this->attributeList->getSuggestedAttributes($this->getRequest()->getParam('label_part')) diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 9326f2db453f8bb29d8c86a848a6f63f62105744..ca9ca611ed03fab9b385cf2afed09a42332b7369 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -386,6 +386,11 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType $res = array(); foreach ($this->getConfigurableAttributes($product) as $attribute) { $eavAttribute = $attribute->getProductAttribute(); + $storeId = 0; + if ($product->getStoreId() !== null) { + $storeId = $product->getStoreId(); + } + $eavAttribute->setStoreId($storeId); /* @var $attribute \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute */ $res[$eavAttribute->getId()] = array( 'id' => $attribute->getId(), diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php index e7aea06a2c3f94f5043c9410c0c3d0fa901d4699..1ce75115d4368ee6349cc8e491620d6dddfa789b 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php @@ -36,7 +36,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price /** * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -44,7 +44,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price */ public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Event\ManagerInterface $eventManager, diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php index 18f93795bf5f281be11d7ea03e9f3d53887d7a11..28b1fa104ff87dd61bc9adda39ed2bc79054e925 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php @@ -62,6 +62,7 @@ class VariationMatrix } while (true); return $variations; + } /** @@ -77,7 +78,7 @@ class VariationMatrix $options = array(); foreach ($attribute['options'] as $valueInfo) { foreach ($attribute['values'] as $priceData) { - if ($priceData['value_index'] == $valueInfo['value'] + if (isset($priceData['value_index']) && $priceData['value_index'] == $valueInfo['value'] && (!isset($priceData['include']) || $priceData['include']) ) { $valueInfo['price'] = $priceData; diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php index b5014625915044bc3e2e061c9f62ae05858fc1a3..ce7a85a10e33c659fa2403446be6258662a9fae8 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php @@ -65,7 +65,7 @@ class AssociatedProduct extends \Magento\Catalog\Model\Resource\Product\Collecti * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -91,7 +91,7 @@ class AssociatedProduct extends \Magento\Catalog\Model\Resource\Product\Collecti \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php index b832a6c8c4e08ec151c93db0694bd63a225a7e0e..7d2753b43190aadc8dfa4c49d9ebd5a5abfc4ccc 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php @@ -53,18 +53,18 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php index 9b4cc92aaca4a74ed49c27c3e7b77f0bcb25b24d..e7aa08e135a47108f38a95098673cff3ff786fb3 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php @@ -68,7 +68,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -77,7 +77,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $catalogProductTypeConfigurable * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute $resource @@ -88,7 +88,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ConfigurableProduct\Model\Product\Type\Configurable $catalogProductTypeConfigurable, \Magento\Catalog\Helper\Data $catalogData, \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute $resource, diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php index fd87bf057ad9c077f0b082d3cbce2c338bea0e97..95dd75fbdbcfd4b3aaba5548fdda27a131fa56fb 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php @@ -46,7 +46,7 @@ class AttributePrice extends AbstractPrice implements AttributePriceInterface /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -55,14 +55,14 @@ class AttributePrice extends AbstractPrice implements AttributePriceInterface * @param float $quantity * @param CalculatorInterface $calculator * @param PriceModifierInterface $modifier - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( Product $saleableItem, $quantity, CalculatorInterface $calculator, PriceModifierInterface $modifier, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->priceModifier = $modifier; $this->storeManager = $storeManager; diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php index 9a5dcbf2446b7367cdeb11104f7c751b1f35e212..28fe23b5e1d489c10b8c52bc1e79572215dd4bfc 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php @@ -33,7 +33,7 @@ use Magento\Eav\Model\Config as EavConfig; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Type as ProductType; use Magento\Store\Model\Store; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\CouldNotSaveException; @@ -81,7 +81,7 @@ class WriteService implements WriteServiceInterface * @param ConfigurableAttributeFactory $configurableAttributeFactory * @param EavConfig $eavConfig * @param OptionConverter $optionConverter - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param ConfigurableType $productType */ public function __construct( diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index 6b34c23b7d9d38474eaeef2c66823b0bdeb7800f..722d22f5713ed130ee39f6d0b7db7fc00ac48810 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog-rule": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-weee": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", - "magento/module-webapi": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog-rule": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-weee": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/module-webapi": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/etc/module.xml b/app/code/Magento/ConfigurableProduct/etc/module.xml index c4e5719f372eef062d4d12f3f99a9307bb205f32..0b9cba1389f59167fd782f16e6262a926e9962d1 100644 --- a/app/code/Magento/ConfigurableProduct/etc/module.xml +++ b/app/code/Magento/ConfigurableProduct/etc/module.xml @@ -30,7 +30,6 @@ <module name="Magento_CatalogInventory"/> <module name="Magento_Sales"/> <module name="Magento_Checkout"/> - <module name="Magento_ImportExport"/> </sequence> <depends> <module name="Magento_Store"/> diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml index e045fd29517af2e4e014b24d962bcc7d93ae9368..20c3a7d9d6c5cb38ac0b5a6c818b7b802af2ee8f 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml @@ -63,7 +63,7 @@ $productByUsedAttributes = $this->getAssociatedProducts(); <?php foreach ($usedProductAttributes as $attribute) { /** @var $attribute \Magento\Catalog\Model\Resource\Eav\Attribute */ - echo '<th class="col-' . preg_replace('#[^a-z0-9]+#', '-', strtolower($attribute->getStoreLabel())) . '">', $attribute->getStoreLabel(), '</th>', PHP_EOL; + echo '<th class="col-' . preg_replace('#[^a-z0-9]+#', '-', strtolower($attribute->getStoreLabel(0))) . '">', $attribute->getStoreLabel(0), '</th>', PHP_EOL; } ?> <th class="col-actions hidden"></th> diff --git a/app/code/Magento/Contact/Controller/Index.php b/app/code/Magento/Contact/Controller/Index.php index e52e7cb3c484050489c5b5dcdd49d78bad128fe0..47bcc7c91a52374adbba35486205f63b39a11cb3 100644 --- a/app/code/Magento/Contact/Controller/Index.php +++ b/app/code/Magento/Contact/Controller/Index.php @@ -67,7 +67,7 @@ class Index extends \Magento\Framework\App\Action\Action protected $scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -76,14 +76,14 @@ class Index extends \Magento\Framework\App\Action\Action * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($context); $this->_transportBuilder = $transportBuilder; diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index f16c6e423d6f4d6339b7a63275bda5bb30d2cb60..5ba1d3b07bf7569235d55857b5cd43df9880c72e 100644 --- a/app/code/Magento/Contact/composer.json +++ b/app/code/Magento/Contact/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/App/Media.php b/app/code/Magento/Core/App/Media.php index 71ec833e5e2d1f212de1503358e6dbd7ffc888e3..0a8868324d5e6381ee36aad78fdd7a92e92ca68a 100644 --- a/app/code/Magento/Core/App/Media.php +++ b/app/code/Magento/Core/App/Media.php @@ -26,6 +26,7 @@ namespace Magento\Core\App; use Magento\Framework\App\State; +use Magento\Framework\App; use Magento\Framework\AppInterface; use Magento\Framework\ObjectManager; use Magento\Core\Model\File\Storage\Request; @@ -33,11 +34,6 @@ use Magento\Core\Model\File\Storage\Response; class Media implements AppInterface { - /** - * @var \Magento\Framework\App\State - */ - protected $_applicationState; - /** * @var \Magento\Framework\ObjectManager */ @@ -99,7 +95,6 @@ class Media implements AppInterface protected $directory; /** - * @param State $applicationState * @param ObjectManager $objectManager * @param Request $request * @param Response $response @@ -111,7 +106,6 @@ class Media implements AppInterface * @param \Magento\Framework\App\Filesystem $filesystem */ public function __construct( - State $applicationState, ObjectManager $objectManager, Request $request, Response $response, @@ -122,7 +116,6 @@ class Media implements AppInterface $relativeFileName, \Magento\Framework\App\Filesystem $filesystem ) { - $this->_applicationState = $applicationState; $this->_objectManager = $objectManager; $this->_request = $request; $this->_response = $response; @@ -139,51 +132,51 @@ class Media implements AppInterface * Run application * * @return \Magento\Framework\App\ResponseInterface + * @throws \LogicException */ public function launch() { - try { - if (!$this->_applicationState->isInstalled()) { - $this->_response->setHttpResponseCode(404); - return $this->_response; - } - if (!$this->_mediaDirectory) { - $config = $this->_objectManager->create( - 'Magento\Core\Model\File\Storage\Config', - array('cacheFile' => $this->_configCacheFile) - ); - $config->save(); - $this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory()); - $allowedResources = $config->getAllowedResources(); - $this->_relativeFileName = str_replace( - $this->_mediaDirectory . '/', - '', - $this->_request->getPathInfo() - ); - $isAllowed = $this->_isAllowed; - if (!$isAllowed($this->_relativeFileName, $allowedResources)) { - $this->_response->setHttpResponseCode(404); - return $this->_response; - } + if (!$this->_mediaDirectory) { + $config = $this->_objectManager->create( + 'Magento\Core\Model\File\Storage\Config', + array('cacheFile' => $this->_configCacheFile) + ); + $config->save(); + $this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory()); + $allowedResources = $config->getAllowedResources(); + $this->_relativeFileName = str_replace( + $this->_mediaDirectory . '/', + '', + $this->_request->getPathInfo() + ); + $isAllowed = $this->_isAllowed; + if (!$isAllowed($this->_relativeFileName, $allowedResources)) { + throw new \LogicException('The specified path is not allowed.'); } + } - if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) { - $this->_response->setHttpResponseCode(404); - return $this->_response; - } + if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) { + throw new \LogicException('The specified path is not within media directory.'); + } - $sync = $this->_objectManager->get('Magento\Core\Model\File\Storage\Synchronization'); - $sync->synchronize($this->_relativeFileName, $this->_request->getFilePath()); + $sync = $this->_objectManager->get('Magento\Core\Model\File\Storage\Synchronization'); + $sync->synchronize($this->_relativeFileName, $this->_request->getFilePath()); - if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) { - $this->_response->setFilePath($this->_request->getFilePath()); - } else { - $this->_response->setHttpResponseCode(404); - } - return $this->_response; - } catch (\Exception $e) { + if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) { + $this->_response->setFilePath($this->_request->getFilePath()); + } else { $this->_response->setHttpResponseCode(404); - return $this->_response; } + return $this->_response; + } + + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + $this->_response->setHttpResponseCode(404); + $this->_response->sendHeaders(); + return true; } } diff --git a/app/code/Magento/Core/App/Router/Base.php b/app/code/Magento/Core/App/Router/Base.php index 42c8b2603ca9082d43857a649825abd4e0d60e31..957ed87e38b88ed94dfa7c0d335c56ddac9c9305 100644 --- a/app/code/Magento/Core/App/Router/Base.php +++ b/app/code/Magento/Core/App/Router/Base.php @@ -81,15 +81,10 @@ class Base implements \Magento\Framework\App\RouterInterface protected $_url; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @var \Magento\Framework\App\ResponseFactory */ @@ -133,9 +128,8 @@ class Base implements \Magento\Framework\App\RouterInterface * @param \Magento\Framework\App\DefaultPathInterface $defaultPath * @param \Magento\Framework\App\ResponseFactory $responseFactory * @param \Magento\Framework\App\Route\ConfigInterface $routeConfig - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Store\Model\StoreManagerInterface|\Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface|\Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo * @param string $routerId @@ -148,9 +142,8 @@ class Base implements \Magento\Framework\App\RouterInterface \Magento\Framework\App\DefaultPathInterface $defaultPath, \Magento\Framework\App\ResponseFactory $responseFactory, \Magento\Framework\App\Route\ConfigInterface $routeConfig, - \Magento\Framework\App\State $appState, \Magento\Framework\UrlInterface $url, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo, $routerId, @@ -165,7 +158,6 @@ class Base implements \Magento\Framework\App\RouterInterface $this->_scopeConfig = $scopeConfig; $this->_url = $url; $this->_storeManager = $storeManager; - $this->_appState = $appState; $this->nameBuilder = $nameBuilder; } @@ -374,7 +366,7 @@ class Base implements \Magento\Framework\App\RouterInterface */ protected function _checkShouldBeSecure(\Magento\Framework\App\RequestInterface $request, $path = '') { - if (!$this->_appState->isInstalled() || $request->getPost()) { + if ($request->getPost()) { return; } diff --git a/app/code/Magento/Core/Helper/Data.php b/app/code/Magento/Core/Helper/Data.php index c772f4a460c75bc46b0b5afe6db0f24dc74371cc..bcc1e4036620b7be1fc6802493dd342437697a63 100644 --- a/app/code/Magento/Core/Helper/Data.php +++ b/app/code/Magento/Core/Helper/Data.php @@ -69,7 +69,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -91,7 +91,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param PriceCurrencyInterface $priceCurrency * @param bool $dbCompatibleMode @@ -99,7 +99,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, PriceCurrencyInterface $priceCurrency, $dbCompatibleMode = true diff --git a/app/code/Magento/Core/Helper/Url.php b/app/code/Magento/Core/Helper/Url.php index 70dde1dec409fa1deb81f322295ee73a4c91f6b8..eee8a61f032cc08758047fc4561248086784ccc5 100644 --- a/app/code/Magento/Core/Helper/Url.php +++ b/app/code/Magento/Core/Helper/Url.php @@ -32,17 +32,17 @@ namespace Magento\Core\Helper; class Url extends \Magento\Framework\App\Helper\AbstractHelper { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($context); $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Core/Model/App/Emulation.php b/app/code/Magento/Core/Model/App/Emulation.php index ffb50176c28506f5dc930d56691af2e5e80f3950..b0ff91b2808c19e2b77239747160817cb7a8cbf4 100644 --- a/app/code/Magento/Core/Model/App/Emulation.php +++ b/app/code/Magento/Core/Model/App/Emulation.php @@ -34,7 +34,7 @@ use Magento\Framework\Translate\Inline\ConfigInterface; class Emulation extends \Magento\Framework\Object { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -71,7 +71,7 @@ class Emulation extends \Magento\Framework\Object protected $inlineTranslation; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\DesignInterface $viewDesign * @param \Magento\Framework\App\DesignInterface $design * @param \Magento\Framework\TranslateInterface $translate @@ -82,7 +82,7 @@ class Emulation extends \Magento\Framework\Object * @param array $data */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\DesignInterface $viewDesign, \Magento\Framework\App\DesignInterface $design, \Magento\Framework\TranslateInterface $translate, diff --git a/app/code/Magento/Core/Model/Layout/Merge.php b/app/code/Magento/Core/Model/Layout/Merge.php index 9761749cf00b70b7d867898013803c02f99c772b..94e82c47d0e17c7ccfc566e8152c60b2fd99d3b4 100644 --- a/app/code/Magento/Core/Model/Layout/Merge.php +++ b/app/code/Magento/Core/Model/Layout/Merge.php @@ -149,7 +149,7 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface * Init merge model * * @param \Magento\Framework\View\DesignInterface $design - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\File\CollectorInterface $fileSource * @param \Magento\Core\Model\Resource\Layout\Update $resource * @param \Magento\Framework\App\State $appState @@ -162,7 +162,7 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface */ public function __construct( \Magento\Framework\View\DesignInterface $design, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\File\CollectorInterface $fileSource, \Magento\Core\Model\Resource\Layout\Update $resource, \Magento\Framework\App\State $appState, @@ -512,9 +512,7 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface protected function _merge($handle) { $this->_fetchPackageLayoutUpdates($handle); - if ($this->_appState->isInstalled()) { - $this->_fetchDbLayoutUpdates($handle); - } + $this->_fetchDbLayoutUpdates($handle); return $this; } diff --git a/app/code/Magento/Core/Model/Resource/Setup.php b/app/code/Magento/Core/Model/Resource/Setup.php index 284480e10c00e33d99330ea7a86827ef030b4914..5dde54656c234fe37c17e05be7c6f1145ee8dc8d 100644 --- a/app/code/Magento/Core/Model/Resource/Setup.php +++ b/app/code/Magento/Core/Model/Resource/Setup.php @@ -60,7 +60,7 @@ class Setup extends \Magento\Framework\Module\Setup } /** - * @return \Magento\Core\Model\Resource\Theme\CollectionFactory + * @return \Magento\Core\Model\Resource\Theme\Collection */ public function createThemeResourceFactory() { @@ -68,7 +68,7 @@ class Setup extends \Magento\Framework\Module\Setup } /** - * @return \Magento\Core\Model\Theme\CollectionFactory + * @return \Magento\Core\Model\Theme\Collection */ public function createThemeFactory() { diff --git a/app/code/Magento/Core/Model/Theme/Collection.php b/app/code/Magento/Core/Model/Theme/Collection.php index 99cb2daccea517bbc43fb7153aca43d75da69a49..e490c611df35fbc421fbaaff6b10e11a2efb9f06 100644 --- a/app/code/Magento/Core/Model/Theme/Collection.php +++ b/app/code/Magento/Core/Model/Theme/Collection.php @@ -70,7 +70,7 @@ class Collection extends \Magento\Framework\Data\Collection implements ListInter */ public function addDefaultPattern($area = \Magento\Framework\App\Area::AREA_FRONTEND) { - $this->addTargetPattern(implode('/', array($area, '*/*', 'theme.xml'))); + $this->addTargetPattern(implode('/', array($area, '{*/*,*/}', 'theme.xml'))); return $this; } diff --git a/app/code/Magento/Core/Model/Theme/Image/Path.php b/app/code/Magento/Core/Model/Theme/Image/Path.php index 2f2c183c4d56ae0a7cf598a5762de488931193c7..1651d4aca47197f544d2e594c9f5c264d3844525 100644 --- a/app/code/Magento/Core/Model/Theme/Image/Path.php +++ b/app/code/Magento/Core/Model/Theme/Image/Path.php @@ -49,7 +49,7 @@ class Path implements \Magento\Framework\View\Design\Theme\Image\PathInterface protected $assetRepo; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -58,12 +58,12 @@ class Path implements \Magento\Framework\View\Design\Theme\Image\PathInterface * * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\View\Asset\Repository $assetRepo, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->mediaDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MEDIA_DIR); $this->assetRepo = $assetRepo; diff --git a/app/code/Magento/Core/Model/Url/RouteParamsResolver.php b/app/code/Magento/Core/Model/Url/RouteParamsResolver.php index 708356a6a8061164e39870a1a7e6418a42ea421e..cdbee8fc799ed4cae0c97be1e7eca74aa95f6a8c 100644 --- a/app/code/Magento/Core/Model/Url/RouteParamsResolver.php +++ b/app/code/Magento/Core/Model/Url/RouteParamsResolver.php @@ -36,7 +36,7 @@ class RouteParamsResolver extends \Magento\Framework\Object implements \Magento\ protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -48,14 +48,14 @@ class RouteParamsResolver extends \Magento\Framework\Object implements \Magento\ /** * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver * @param array $data */ public function __construct( \Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver, array $data = array() ) { diff --git a/app/code/Magento/Core/Model/Url/ScopeResolver.php b/app/code/Magento/Core/Model/Url/ScopeResolver.php index 5937b282382a455c9ed2e8b987594326229e59fd..760944753e9dd4fa9032dce0eda445e1e03e93ce 100644 --- a/app/code/Magento/Core/Model/Url/ScopeResolver.php +++ b/app/code/Magento/Core/Model/Url/ScopeResolver.php @@ -26,7 +26,7 @@ namespace Magento\Core\Model\Url; class ScopeResolver implements \Magento\Framework\Url\ScopeResolverInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -36,10 +36,10 @@ class ScopeResolver implements \Magento\Framework\Url\ScopeResolverInterface protected $_areaCode; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param string|null $areaCode */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, $areaCode = null) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager, $areaCode = null) { $this->_storeManager = $storeManager; $this->_areaCode = $areaCode; diff --git a/app/code/Magento/Core/Model/View/Design.php b/app/code/Magento/Core/Model/View/Design.php index 7d7d7bf61ca6210d5917fe82c4379169999bea3e..3b21a1a216e334029ed592edd0f940648c792163 100644 --- a/app/code/Magento/Core/Model/View/Design.php +++ b/app/code/Magento/Core/Model/View/Design.php @@ -54,7 +54,7 @@ class Design implements \Magento\Framework\View\DesignInterface /** * Store list manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -84,7 +84,7 @@ class Design implements \Magento\Framework\View\DesignInterface protected $_appState; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\Design\Theme\FlyweightFactory $flyweightFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Core\Model\ThemeFactory $themeFactory @@ -93,7 +93,7 @@ class Design implements \Magento\Framework\View\DesignInterface * @param array $themes */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\Design\Theme\FlyweightFactory $flyweightFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Core\Model\ThemeFactory $themeFactory, diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json index 5e9a33f37d7a43a058cd8a9c6b79f41a9c36df6d..67fbd0494bde24a1139f382ae0ccb35b985e62d9 100644 --- a/app/code/Magento/Core/composer.json +++ b/app/code/Magento/Core/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.10-1.6.0.11.php b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.10-1.6.0.11.php index 2f09b686e5431e7ec879f4dfde3740a8422106de..1a1572b6ac1aa53851bef5672706c528f12c077d 100644 --- a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.10-1.6.0.11.php +++ b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.10-1.6.0.11.php @@ -22,13 +22,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $filesystemCollection \Magento\Core\Model\Theme\Collection */ -$filesystemCollection = $this->createThemeFactory(); -$filesystemCollection->addDefaultPattern('*'); +/** @var $this \Magento\Core\Model\Resource\Setup */ +$fileCollection = $this->createThemeFactory(); +$fileCollection->addDefaultPattern('*'); +$fileCollection->setItemObjectClass('Magento\Core\Model\Theme\Data'); + +$resourceCollection = $this->createThemeResourceFactory(); +$resourceCollection->setItemObjectClass('Magento\Core\Model\Theme\Data'); /** @var $theme \Magento\Framework\View\Design\ThemeInterface */ -foreach ($this->createThemeResourceFactory() as $theme) { - $themeType = $filesystemCollection->hasTheme($theme) +foreach ($resourceCollection as $theme) { + $themeType = $fileCollection->hasTheme($theme) ? \Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL : \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL; $theme->setType($themeType)->save(); diff --git a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.12-1.6.0.13.php b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.12-1.6.0.13.php index 9f27d2da50368993d1a604262956bcb6df4924db..1655e11fc2a52320afc2defc03c4a87b60f6404f 100644 --- a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.12-1.6.0.13.php +++ b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.12-1.6.0.13.php @@ -22,11 +22,16 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +$fileCollection = $this->createThemeFactory(); +$fileCollection->addDefaultPattern('*'); +$fileCollection->setItemObjectClass('Magento\Core\Model\Theme\Data'); + /** @var $themeDbCollection \Magento\Core\Model\Resource\Theme\Collection */ $themeDbCollection = $this->createThemeResourceFactory(); +$themeDbCollection->setItemObjectClass('Magento\Core\Model\Theme\Data'); /** @var $theme \Magento\Framework\View\Design\ThemeInterface */ -foreach ($this->createThemeFactory()->addDefaultPattern('*') as $theme) { +foreach ($fileCollection as $theme) { $dbTheme = $themeDbCollection->getThemeByFullPath($theme->getFullPath()); $dbTheme->setCode($theme->getCode()); $dbTheme->save(); diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index 9004dd991a1460b9d00083bb468c47d25135aa99..4d8994e83cc78d9885eddb381fa89507d39926a1 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -417,7 +417,7 @@ </arguments> </type> <type name="Magento\Framework\App\FrontController"> - <plugin name="install" type="Magento\Framework\Module\FrontController\Plugin\Install" sortOrder="40"/> + <plugin name="install" type="Magento\Framework\Module\Plugin\DbStatusValidator" sortOrder="40"/> </type> <type name="Magento\Framework\App\Action\Action"> <plugin name="storeCheck" type="Magento\Store\App\Action\Plugin\StoreCheck" sortOrder="10"/> diff --git a/app/code/Magento/Core/etc/frontend/di.xml b/app/code/Magento/Core/etc/frontend/di.xml index 845639a371110c0ebc7affba3b4866791af6949c..6f6749c94da9bb4b4651405ca8862dd87f9dfd70 100644 --- a/app/code/Magento/Core/etc/frontend/di.xml +++ b/app/code/Magento/Core/etc/frontend/di.xml @@ -24,11 +24,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Framework\View\Layout"> <plugin name="core-session-depersonalize" type="Magento\Core\Model\Layout\DepersonalizePlugin" sortOrder="1"/> diff --git a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php b/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php deleted file mode 100644 index a1187eccc635ad408add26f7374a8ae12aee55ce..0000000000000000000000000000000000000000 --- a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Cron application plugin - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Cron\App\Cron\Plugin; - -use \Magento\Framework\App\State; - -class ApplicationInitializer -{ - /** - * @var State - */ - protected $_appState; - - /** - * @var \Magento\Framework\Session\SidResolverInterface - */ - protected $_sidResolver; - - /** - * @param State $appState - * @param \Magento\Framework\Session\SidResolverInterface $sidResolver - */ - public function __construct(State $appState, \Magento\Framework\Session\SidResolverInterface $sidResolver) - { - $this->_appState = $appState; - $this->_sidResolver = $sidResolver; - } - - /** - * Perform required checks before cron run - * - * @param \Magento\Framework\App\Cron $subject - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @throws \Magento\Framework\Exception - */ - public function beforeLaunch(\Magento\Framework\App\Cron $subject) - { - $this->_sidResolver->setUseSessionInUrl(false); - if (false == $this->_appState->isInstalled()) { - throw new \Magento\Framework\Exception('Application is not installed yet, please complete the installation first.'); - } - } -} diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index f0455dcf52b8015b0dff9f2637966bf54d1949d9..f7f0c5fbf5160d576f7fc69b3e3e237976e2dfdf 100644 --- a/app/code/Magento/Cron/composer.json +++ b/app/code/Magento/Cron/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index e2af396831911c43997b2747b88eb3ef94427a95..7af22e923b23cebeefc2828c8831533ef8399966 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -31,9 +31,6 @@ <argument name="defaultReader" xsi:type="object">Magento\Store\Model\Config\Reader\DefaultReader</argument> </arguments> </type> - <type name="Magento\Framework\App\Cron"> - <plugin name="application_initializer" type="Magento\Cron\App\Cron\Plugin\ApplicationInitializer" sortOrder="10"/> - </type> <type name="Magento\Backend\Model\Config\Structure\Converter"> <plugin name="cron_backend_config_structure_converter_plugin" type="Magento\Cron\Model\Backend\Config\Structure\Converter" /> </type> diff --git a/app/code/Magento/CurrencySymbol/Helper/Data.php b/app/code/Magento/CurrencySymbol/Helper/Data.php index 2a4e92fccb821bf58144f889d19c752110f2d4e5..6446899ac037a55fbadb6ede85151eedb43d759a 100644 --- a/app/code/Magento/CurrencySymbol/Helper/Data.php +++ b/app/code/Magento/CurrencySymbol/Helper/Data.php @@ -39,7 +39,7 @@ class Data extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory @@ -48,7 +48,7 @@ class Data extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory, diff --git a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php index 2c9a48ce5cdb459b34f4209642f484608e862a28..4180dc7adc9fb2ffe52a3d8e2a0e0f16496c9534 100644 --- a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php +++ b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php @@ -104,7 +104,7 @@ class Currencysymbol protected $_systemStore; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -130,7 +130,7 @@ class Currencysymbol * @param \Magento\Framework\App\Config\ReinitableConfigInterface $coreConfig * @param \Magento\Backend\Model\Config\Factory $configFactory * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Store\Model\System\Store $systemStore * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -140,7 +140,7 @@ class Currencysymbol \Magento\Framework\App\Config\ReinitableConfigInterface $coreConfig, \Magento\Backend\Model\Config\Factory $configFactory, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Store\Model\System\Store $systemStore, \Magento\Framework\Event\ManagerInterface $eventManager diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index 951da4982059c51f76b0463891f08f5c8192b1f9..1167b1a964591fcc3b84fd25a3b9abc31810a4e8 100644 --- a/app/code/Magento/CurrencySymbol/composer.json +++ b/app/code/Magento/CurrencySymbol/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Sendemail.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Sendemail.php index 6ea74406b8f8a32971e5235295a1991cc08d10c6..b8b3d3f4dc64ab9e043e6a969221a144e010efdc 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Sendemail.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Sendemail.php @@ -36,7 +36,7 @@ class Sendemail extends Element protected $_template = 'edit/tab/account/form/renderer/sendemail.phtml'; /** - * @var \Magento\Store\Model\StoreManagerInterface|null + * @var \Magento\Framework\StoreManagerInterface|null */ protected $_storeManager = null; diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php index 8a632a02aafe6f8e532871018cd9d052f7ac888f..0cd008fdec7607dc841bfd95a9f2f379abd9f50d 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php @@ -24,28 +24,12 @@ namespace Magento\Customer\Block\Adminhtml\Edit\Tab; use Magento\Customer\Controller\RegistryConstants; -use Magento\Customer\Service\V1\CustomerAccountServiceInterface; -use Magento\Customer\Service\V1\Data\AddressConverter; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; /** * Customer account form block - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class View extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\Tab\TabInterface { - /** - * @var \Magento\Customer\Service\V1\Data\Customer - */ - protected $_customer; - - /** - * @var \Magento\Log\Model\Customer - */ - protected $_customerLog; - /** * Core registry * @@ -53,99 +37,20 @@ class View extends \Magento\Backend\Block\Template implements \Magento\Backend\B */ protected $_coreRegistry; - /** - * @var \Magento\Log\Model\Visitor - */ - protected $_modelVisitor; - - /** - * @var CustomerAccountServiceInterface - */ - protected $_accountService; - - /** - * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface - */ - protected $_addressService; - - /** - * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface - */ - protected $_groupService; - - /** - * @var \Magento\Customer\Service\V1\Data\CustomerBuilder - */ - protected $_customerBuilder; - - /** - * @var \Magento\Customer\Helper\Address - */ - protected $_addressHelper; - - /** - * @var \Magento\Log\Model\CustomerFactory - */ - protected $_logFactory; - - /** - * @var \Magento\Framework\Stdlib\DateTime - */ - protected $dateTime; - /** * @param \Magento\Backend\Block\Template\Context $context - * @param CustomerAccountServiceInterface $accountService - * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService - * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService - * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder - * @param \Magento\Customer\Helper\Address $addressHelper - * @param \Magento\Log\Model\CustomerFactory $logFactory * @param \Magento\Framework\Registry $registry - * @param \Magento\Log\Model\Visitor $modelVisitor - * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\Block\Template\Context $context, - CustomerAccountServiceInterface $accountService, - \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, - \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService, - \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, - \Magento\Customer\Helper\Address $addressHelper, - \Magento\Log\Model\CustomerFactory $logFactory, \Magento\Framework\Registry $registry, - \Magento\Log\Model\Visitor $modelVisitor, - \Magento\Framework\Stdlib\DateTime $dateTime, array $data = array() ) { $this->_coreRegistry = $registry; - $this->_modelVisitor = $modelVisitor; - $this->_accountService = $accountService; - $this->_addressService = $addressService; - $this->_groupService = $groupService; - $this->_customerBuilder = $customerBuilder; - $this->_addressHelper = $addressHelper; - $this->_logFactory = $logFactory; - $this->dateTime = $dateTime; parent::__construct($context, $data); } - /** - * @return \Magento\Customer\Service\V1\Data\Customer - */ - public function getCustomer() - { - if (!$this->_customer) { - $this->_customer = $this->_customerBuilder->populateWithArray( - $this->_backendSession->getCustomerData()['account'] - )->create(); - } - return $this->_customer; - } - /** * @return string|null */ @@ -154,212 +59,6 @@ class View extends \Magento\Backend\Block\Template implements \Magento\Backend\B return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); } - /** - * @param int $groupId - * @return \Magento\Customer\Service\V1\Data\CustomerGroup|null - */ - private function getGroup($groupId) - { - try { - $group = $this->_groupService->getGroup($groupId); - } catch (NoSuchEntityException $e) { - $group = null; - } - return $group; - } - - /** - * @return string|null - */ - public function getGroupName() - { - $customer = $this->getCustomer(); - - if ($groupId = $customer->getId() ? $customer->getGroupId() : null) { - if ($group = $this->getGroup($groupId)) { - return $group->getCode(); - } - } - - return null; - } - - /** - * Load Customer Log model - * - * @return \Magento\Log\Model\Customer - */ - public function getCustomerLog() - { - if (!$this->_customerLog) { - $this->_customerLog = $this->_logFactory->create()->loadByCustomer($this->getCustomerId()); - } - return $this->_customerLog; - } - - /** - * Get customer creation date - * - * @return string - */ - public function getCreateDate() - { - return $this->formatDate( - $this->getCustomer()->getCreatedAt(), - TimezoneInterface::FORMAT_TYPE_MEDIUM, - true - ); - } - - /** - * @return string - */ - public function getStoreCreateDate() - { - $date = $this->_localeDate->scopeDate( - $this->getCustomer()->getStoreId(), - $this->dateTime->toTimestamp($this->getCustomer()->getCreatedAt()), - true - ); - return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); - } - - /** - * @return string - */ - public function getStoreCreateDateTimezone() - { - return $this->_scopeConfig->getValue( - $this->_localeDate->getDefaultTimezonePath(), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getCustomer()->getStoreId() - ); - } - - /** - * Get customer last login date - * - * @return string - */ - public function getLastLoginDate() - { - $date = $this->getCustomerLog()->getLoginAtTimestamp(); - if ($date) { - return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); - } - return __('Never'); - } - - /** - * @return string - */ - public function getStoreLastLoginDate() - { - $date = $this->getCustomerLog()->getLoginAtTimestamp(); - if ($date) { - $date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true); - return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); - } - return __('Never'); - } - - /** - * @return string - */ - public function getStoreLastLoginDateTimezone() - { - return $this->_scopeConfig->getValue( - $this->_localeDate->getDefaultTimezonePath(), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getCustomer()->getStoreId() - ); - } - - /** - * @return string - */ - public function getCurrentStatus() - { - $log = $this->getCustomerLog(); - $interval = $this->_modelVisitor->getOnlineMinutesInterval(); - if ($log->getLogoutAt() - || strtotime( - $this->dateTime->now() - ) - strtotime( - $log->getLastVisitAt() - ) > $interval * 60 - ) { - return __('Offline'); - } - return __('Online'); - } - - /** - * @return string - */ - public function getIsConfirmedStatus() - { - $id = $this->getCustomerId(); - switch ($this->_accountService->getConfirmationStatus($id)) { - case CustomerAccountServiceInterface::ACCOUNT_CONFIRMED: - return __('Confirmed'); - case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED: - return __('Confirmation Required'); - case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED: - return __('Confirmation Not Required'); - } - return __('Indeterminate'); - } - - /** - * @return null|string - */ - public function getCreatedInStore() - { - return $this->_storeManager->getStore($this->getStoreId())->getName(); - } - - /** - * @return int - */ - public function getStoreId() - { - return $this->getCustomer()->getStoreId(); - } - - /** - * @return string|null - */ - public function getBillingAddressHtml() - { - try { - $address = $this->_addressService->getAddress($this->getCustomer()->getDefaultBilling()); - } catch (NoSuchEntityException $e) { - return __('The customer does not have default billing address.'); - } - return $this->_addressHelper->getFormatTypeRenderer( - 'html' - )->renderArray( - AddressConverter::toFlatArray($address) - ); - } - - /** - * @return string - */ - public function getAccordionHtml() - { - return $this->getChildHtml('accordion'); - } - - /** - * @return string - */ - public function getSalesHtml() - { - return $this->getChildHtml('sales'); - } - /** * @return string */ diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php new file mode 100644 index 0000000000000000000000000000000000000000..7444dc99b298f7e155b7d6b7477178a2b035c02c --- /dev/null +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php @@ -0,0 +1,244 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Customer\Service\V1\Data\AddressConverter; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; + +/** + * Adminhtml customer view personal information sales block + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class PersonalInfo extends \Magento\Backend\Block\Template +{ + /** + * @var \Magento\Customer\Service\V1\Data\Customer + */ + protected $customer; + + /** + * @var CustomerAccountServiceInterface + */ + protected $accountService; + + /** + * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface + */ + protected $addressService; + + /** + * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface + */ + protected $groupService; + + /** + * @var \Magento\Customer\Service\V1\Data\CustomerBuilder + */ + protected $customerBuilder; + + /** + * @var \Magento\Customer\Helper\Address + */ + protected $addressHelper; + + /** + * @var \Magento\Framework\Stdlib\DateTime + */ + protected $dateTime; + + /** + * Core registry + * + * @var \Magento\Framework\Registry + */ + protected $coreRegistry; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param CustomerAccountServiceInterface $accountService + * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService + * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService + * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder + * @param \Magento\Customer\Helper\Address $addressHelper + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Framework\Registry $registry + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + CustomerAccountServiceInterface $accountService, + \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, + \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService, + \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, + \Magento\Customer\Helper\Address $addressHelper, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Framework\Registry $registry, + array $data = array() + ) { + $this->coreRegistry = $registry; + $this->accountService = $accountService; + $this->addressService = $addressService; + $this->groupService = $groupService; + $this->customerBuilder = $customerBuilder; + $this->addressHelper = $addressHelper; + $this->dateTime = $dateTime; + parent::__construct($context, $data); + } + + /** + * @return \Magento\Customer\Service\V1\Data\Customer + */ + public function getCustomer() + { + if (!$this->customer) { + $this->customer = $this->customerBuilder->populateWithArray( + $this->_backendSession->getCustomerData()['account'] + )->create(); + } + return $this->customer; + } + + /** + * @return string|null + */ + public function getCustomerId() + { + return $this->coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * @return string + */ + public function getStoreCreateDate() + { + $date = $this->_localeDate->scopeDate( + $this->getCustomer()->getStoreId(), + $this->dateTime->toTimestamp($this->getCustomer()->getCreatedAt()), + true + ); + return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); + } + + /** + * @return string + */ + public function getStoreCreateDateTimezone() + { + return $this->_scopeConfig->getValue( + $this->_localeDate->getDefaultTimezonePath(), + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getCustomer()->getStoreId() + ); + } + + /** + * Get customer creation date + * + * @return string + */ + public function getCreateDate() + { + return $this->formatDate( + $this->getCustomer()->getCreatedAt(), + TimezoneInterface::FORMAT_TYPE_MEDIUM, + true + ); + } + + /** + * @return string + */ + public function getIsConfirmedStatus() + { + $id = $this->getCustomerId(); + switch ($this->accountService->getConfirmationStatus($id)) { + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMED: + return __('Confirmed'); + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED: + return __('Confirmation Required'); + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED: + return __('Confirmation Not Required'); + } + return __('Indeterminate'); + } + + /** + * @return null|string + */ + public function getCreatedInStore() + { + return $this->_storeManager->getStore( + $this->getCustomer()->getStoreId() + )->getName(); + } + + /** + * @return string|null + */ + public function getBillingAddressHtml() + { + try { + $address = $this->addressService->getAddress($this->getCustomer()->getDefaultBilling()); + } catch (NoSuchEntityException $e) { + return __('The customer does not have default billing address.'); + } + return $this->addressHelper->getFormatTypeRenderer( + 'html' + )->renderArray( + AddressConverter::toFlatArray($address) + ); + } + + /** + * @return string|null + */ + public function getGroupName() + { + $customer = $this->getCustomer(); + if ($groupId = $customer->getId() ? $customer->getGroupId() : null) { + if ($group = $this->getGroup($groupId)) { + return $group->getCode(); + } + } + + return null; + } + + /** + * @param int $groupId + * @return \Magento\Customer\Service\V1\Data\CustomerGroup|null + */ + private function getGroup($groupId) + { + try { + $group = $this->groupService->getGroup($groupId); + } catch (NoSuchEntityException $e) { + $group = null; + } + return $group; + } +} diff --git a/app/code/Magento/Customer/Block/Widget/Dob.php b/app/code/Magento/Customer/Block/Widget/Dob.php index 0acdb7b001618d99ad010837d09671d16ca9fe26..c8734afd9a0e7464e3a1d4a648d5f6084705e396 100644 --- a/app/code/Magento/Customer/Block/Widget/Dob.php +++ b/app/code/Magento/Customer/Block/Widget/Dob.php @@ -24,6 +24,7 @@ namespace Magento\Customer\Block\Widget; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; +use Magento\Framework\Service\ArrayObjectSearch; class Dob extends AbstractWidget { @@ -158,8 +159,12 @@ class Dob extends AbstractWidget $dob = $this->_getAttribute('dob'); if (!is_null($dob)) { $rules = $this->_getAttribute('dob')->getValidationRules(); - if (isset($rules[self::MIN_DATE_RANGE_KEY])) { - return date("Y/m/d", $rules[self::MIN_DATE_RANGE_KEY]); + $minDateValue = ArrayObjectSearch::getArrayElementByName( + $rules, + self::MIN_DATE_RANGE_KEY + ); + if (!is_null($minDateValue)) { + return date("Y/m/d", $minDateValue); } } return null; @@ -175,8 +180,12 @@ class Dob extends AbstractWidget $dob = $this->_getAttribute('dob'); if (!is_null($dob)) { $rules = $this->_getAttribute('dob')->getValidationRules(); - if (isset($rules[self::MAX_DATE_RANGE_KEY])) { - return date("Y/m/d", $rules[self::MAX_DATE_RANGE_KEY]); + $maxDateValue = ArrayObjectSearch::getArrayElementByName( + $rules, + self::MAX_DATE_RANGE_KEY + ); + if (!is_null($maxDateValue)) { + return date("Y/m/d", $maxDateValue); } } return null; diff --git a/app/code/Magento/Customer/Controller/Account.php b/app/code/Magento/Customer/Controller/Account.php index 235a62a4da5a218566ec77d2294a495575d9c6d6..fdfbeceb97d7dd4e943ba95af8385275c4f2c55c 100644 --- a/app/code/Magento/Customer/Controller/Account.php +++ b/app/code/Magento/Customer/Controller/Account.php @@ -65,15 +65,12 @@ class Account extends \Magento\Framework\App\Action\Action /** @var \Magento\Framework\UrlFactory */ protected $_urlFactory; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $_scopeConfig; - /** @var \Magento\Framework\App\State */ - protected $appState; - /** @var CustomerAccountServiceInterface */ protected $_customerAccountService; @@ -82,9 +79,8 @@ class Account extends \Magento\Framework\App\Action\Action * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService */ public function __construct( @@ -92,9 +88,8 @@ class Account extends \Magento\Framework\App\Action\Action \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService ) { $this->_session = $customerSession; @@ -102,7 +97,6 @@ class Account extends \Magento\Framework\App\Action\Action $this->_urlFactory = $urlFactory; $this->_storeManager = $storeManager; $this->_scopeConfig = $scopeConfig; - $this->appState = $appState; $this->_customerAccountService = $customerAccountService; parent::__construct($context); } @@ -135,10 +129,6 @@ class Account extends \Magento\Framework\App\Action\Action */ public function dispatch(RequestInterface $request) { - if (!$this->appState->isInstalled()) { - parent::dispatch($request); - } - if (!$this->getRequest()->isDispatched()) { parent::dispatch($request); } diff --git a/app/code/Magento/Customer/Controller/Account/Create.php b/app/code/Magento/Customer/Controller/Account/Create.php index fcc57656561325acacf06dd1275014e49d04953c..b3d11180172675ae2ddd8a059b388018934010ca 100644 --- a/app/code/Magento/Customer/Controller/Account/Create.php +++ b/app/code/Magento/Customer/Controller/Account/Create.php @@ -37,9 +37,8 @@ class Create extends \Magento\Customer\Controller\Account * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Helper\Data $customerHelper */ @@ -48,9 +47,8 @@ class Create extends \Magento\Customer\Controller\Account \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Helper\Data $customerHelper ) { @@ -62,7 +60,6 @@ class Create extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Account/CreatePost.php b/app/code/Magento/Customer/Controller/Account/CreatePost.php index df94a3471fa52cf20d3e2064427cc5213ba936b8..cb34708150371a805c7c1ec2f2743382a60d31d5 100644 --- a/app/code/Magento/Customer/Controller/Account/CreatePost.php +++ b/app/code/Magento/Customer/Controller/Account/CreatePost.php @@ -62,9 +62,8 @@ class CreatePost extends \Magento\Customer\Controller\Account * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Model\Metadata\FormFactory $formFactory * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory @@ -82,9 +81,8 @@ class CreatePost extends \Magento\Customer\Controller\Account \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Model\Metadata\FormFactory $formFactory, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, @@ -110,7 +108,6 @@ class CreatePost extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } @@ -188,6 +185,8 @@ class CreatePost extends \Magento\Customer\Controller\Account return; } + $this->_session->regenerateId(); + try { $customer = $this->customerExtractor->extract('customer_account_create', $this->_request); $address = $this->_extractAddress(); diff --git a/app/code/Magento/Customer/Controller/Account/Edit.php b/app/code/Magento/Customer/Controller/Account/Edit.php index 022389054c8e4bcf51f192c9b68da9795d817fac..a07456177f214542cb9e9a57bc96281ce5814508 100644 --- a/app/code/Magento/Customer/Controller/Account/Edit.php +++ b/app/code/Magento/Customer/Controller/Account/Edit.php @@ -40,9 +40,8 @@ class Edit extends \Magento\Customer\Controller\Account * @param Session $customerSession * @param CustomerHelper $addressHelper * @param UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder */ @@ -51,9 +50,8 @@ class Edit extends \Magento\Customer\Controller\Account Session $customerSession, CustomerHelper $addressHelper, UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder ) { @@ -65,7 +63,6 @@ class Edit extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Account/EditPost.php b/app/code/Magento/Customer/Controller/Account/EditPost.php index 2e59c352698740d1802c3910308f12bf3cd46e41..742bcd3d1518141038a8c3bb11408985a24d05e5 100644 --- a/app/code/Magento/Customer/Controller/Account/EditPost.php +++ b/app/code/Magento/Customer/Controller/Account/EditPost.php @@ -50,9 +50,8 @@ class EditPost extends \Magento\Customer\Controller\Account * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator @@ -66,9 +65,8 @@ class EditPost extends \Magento\Customer\Controller\Account \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, @@ -86,7 +84,6 @@ class EditPost extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php b/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php index 50a0e8622a019f173e307cc76f4265590048638f..0fa38e97bff673f12df22265b4343451e5fed45c 100644 --- a/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php +++ b/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php @@ -30,7 +30,7 @@ use Magento\Framework\App\Action\Context; use Magento\Customer\Model\Session; use Magento\Customer\Helper\Address; use Magento\Framework\UrlFactory; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class ForgotPasswordPost extends \Magento\Customer\Controller\Account { @@ -44,7 +44,6 @@ class ForgotPasswordPost extends \Magento\Customer\Controller\Account * @param UrlFactory $urlFactory * @param StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Framework\Escaper $escaper */ @@ -55,7 +54,6 @@ class ForgotPasswordPost extends \Magento\Customer\Controller\Account UrlFactory $urlFactory, StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Framework\Escaper $escaper ) { @@ -67,7 +65,6 @@ class ForgotPasswordPost extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Account/LoginPost.php b/app/code/Magento/Customer/Controller/Account/LoginPost.php index 33fc21bfa58fd297985d61beae9c7d63999226f9..751a4258fa5797d142ec6b3844722f489bb4a7af 100644 --- a/app/code/Magento/Customer/Controller/Account/LoginPost.php +++ b/app/code/Magento/Customer/Controller/Account/LoginPost.php @@ -47,9 +47,8 @@ class LoginPost extends \Magento\Customer\Controller\Account * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Core\Helper\Data $coreHelperData * @param \Magento\Customer\Helper\Data $customerHelperData @@ -62,9 +61,8 @@ class LoginPost extends \Magento\Customer\Controller\Account \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Core\Helper\Data $coreHelperData, \Magento\Customer\Helper\Data $customerHelperData, @@ -80,7 +78,6 @@ class LoginPost extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php index 611cd4975cbd59c5f8d710e0a9bf4dc4bcfc5aa4..9f9e40ff164048878f2735d330c935229805533f 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php @@ -72,7 +72,7 @@ class Cart extends \Magento\Backend\App\Action $this->_quote = $this->_objectManager->create( 'Magento\Sales\Model\Quote' )->setWebsite( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getWebsite($websiteId) + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getWebsite($websiteId) )->loadByCustomer( $this->_customerId ); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Customer/InvalidateToken.php b/app/code/Magento/Customer/Controller/Adminhtml/Customer/InvalidateToken.php index 63e0718d44097927a095f219594a863398bee631..7b5e2fd7060de2e7fd5207c1c946fcf77cdd76bb 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Customer/InvalidateToken.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Customer/InvalidateToken.php @@ -45,8 +45,8 @@ class InvalidateToken extends \Magento\Customer\Controller\Adminhtml\Index { if ($customerId = $this->getRequest()->getParam('customer_id')) { try { - /** @var \Magento\Integration\Service\V1\TokenService $tokenService */ - $tokenService = $this->_objectManager->get('Magento\Integration\Service\V1\TokenService'); + /** @var \Magento\Integration\Service\V1\CustomerTokenService $tokenService */ + $tokenService = $this->_objectManager->get('Magento\Integration\Service\V1\CustomerTokenService'); $tokenService->revokeCustomerAccessToken($customerId); $this->messageManager->addSuccess(__('You have revoked the customer\'s tokens.')); $this->_redirect('customer/index/edit', array('id' => $customerId, '_current' => true)); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php index ff43ec8f6acafa812245fcb08cb2be1607d0ce88..5bc7e3e4466d40b2db9c524a614bc85c5c940e24 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php @@ -44,7 +44,7 @@ class Cart extends \Magento\Customer\Controller\Adminhtml\Index $quote = $this->_objectManager->create( 'Magento\Sales\Model\Quote' )->setWebsite( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getWebsite($websiteId) + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getWebsite($websiteId) )->loadByCustomer( $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID) ); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php index 97deddec59629e4582ae5635340be3675f20d60a..543a827bbd50fd0e13281e78a1a1f042a8ee0761 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php @@ -53,5 +53,6 @@ class Index extends \Magento\Customer\Controller\Adminhtml\Index $this->_addBreadcrumb(__('Manage Customers'), __('Manage Customers')); $this->_view->renderLayout(); + $this->_getSession()->unsCustomerData(); } } diff --git a/app/code/Magento/Customer/Helper/Address.php b/app/code/Magento/Customer/Helper/Address.php index ea5d48d4f2f9d965dbc6cd8ddccdc954f214f5c8..e8615a90e93653d6e0d57fd3409d5edb626ecfef 100755 --- a/app/code/Magento/Customer/Helper/Address.php +++ b/app/code/Magento/Customer/Helper/Address.php @@ -82,7 +82,7 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper /** @var \Magento\Framework\View\Element\BlockFactory */ protected $_blockFactory; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ @@ -100,7 +100,7 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\View\Element\BlockFactory $blockFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService * @param \Magento\Customer\Service\V1\AddressMetadataServiceInterface $addressMetadataService @@ -109,7 +109,7 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\View\Element\BlockFactory $blockFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService, \Magento\Customer\Service\V1\AddressMetadataServiceInterface $addressMetadataService, diff --git a/app/code/Magento/Customer/Model/Address/Config.php b/app/code/Magento/Customer/Model/Address/Config.php index f1aab65203cc23992d44f44c7c16e5346b9a03ce..0469c8176fbecd41f7ba8989ee7d4ee786307844 100644 --- a/app/code/Magento/Customer/Model/Address/Config.php +++ b/app/code/Magento/Customer/Model/Address/Config.php @@ -59,7 +59,7 @@ class Config extends \Magento\Framework\Config\Data protected $_defaultTypes = array(); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -76,7 +76,7 @@ class Config extends \Magento\Framework\Config\Data /** * @param \Magento\Customer\Model\Address\Config\Reader $reader * @param \Magento\Framework\Config\CacheInterface $cache - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param string $cacheId @@ -84,7 +84,7 @@ class Config extends \Magento\Framework\Config\Data public function __construct( \Magento\Customer\Model\Address\Config\Reader $reader, \Magento\Framework\Config\CacheInterface $cache, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, $cacheId = 'address_format' diff --git a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php index 5ff0b776f02aa7b898a0940443ccfafc8d782392..d9525c50d0ca17de7e3734f6c01513a4cd930977 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php @@ -35,14 +35,14 @@ class Street extends \Magento\Framework\App\Config\Value */ protected $_eavConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -52,7 +52,7 @@ class Street extends \Magento\Framework\App\Config\Value \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php index 5a20036fa9b5803b9a3e1cf9948094957a02b36d..409ab4f8e72e6ec596be986e5b0087ca7321a6ef 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php @@ -37,14 +37,14 @@ class Customer extends \Magento\Framework\App\Config\Value */ protected $_eavConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -54,7 +54,7 @@ class Customer extends \Magento\Framework\App\Config\Value \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Customer/Model/Config/Share.php b/app/code/Magento/Customer/Model/Config/Share.php index 1b1bfff634b7bedff9cc2377776a85dd76f54ca8..2f9f1a588caea818a704d29aff3a841281003cfd 100644 --- a/app/code/Magento/Customer/Model/Config/Share.php +++ b/app/code/Magento/Customer/Model/Config/Share.php @@ -49,7 +49,7 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram */ protected $_customerResource; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** @@ -58,7 +58,7 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -68,7 +68,7 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Resource\Customer $customerResource, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Customer/Model/Converter.php b/app/code/Magento/Customer/Model/Converter.php index c3fec82385cd581b9c03bd1a1347fcc78e7dccbf..b9ba7ae280386222955331d82333a7206a7819c6 100644 --- a/app/code/Magento/Customer/Model/Converter.php +++ b/app/code/Magento/Customer/Model/Converter.php @@ -28,7 +28,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Customer\Service\V1\Data\Customer as CustomerDataObject; use Magento\Customer\Service\V1\Data\CustomerBuilder as CustomerDataObjectBuilder; use Magento\Framework\Service\ExtensibleDataObjectConverter; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Customer Model converter. @@ -48,7 +48,7 @@ class Converter protected $_customerFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 06071b38d080295d3619d531bf318ecdee9b158f..99cf6d6bdb8e6ad88488324fd32e0b5d905e8dd8 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -138,7 +138,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel protected $_isReadonly = false; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -213,7 +213,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Customer\Helper\Data $customerData - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $config * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Resource\Customer $resource @@ -233,7 +233,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Customer\Helper\Data $customerData, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $config, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Model\Resource\Customer $resource, diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php index 0025b504c9368e9bbee43ef6053352d30b1c23a0..da9753ef73e4a4c6c2136a9aa117d9a06426b4ba 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php @@ -31,15 +31,15 @@ namespace Magento\Customer\Model\Customer\Attribute\Backend; class Store extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Logger $logger - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; parent::__construct($logger); diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php index 81cc1e379b467d859658f9f66d2ed8568b0298ef..c8c99a5f9582bd5d65c37339e8d503a0005e2e27 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php @@ -31,15 +31,15 @@ namespace Magento\Customer\Model\Customer\Attribute\Backend; class Website extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Logger $logger - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; parent::__construct($logger); diff --git a/app/code/Magento/Customer/Model/CustomerExtractor.php b/app/code/Magento/Customer/Model/CustomerExtractor.php index e82ec9b6215e5f7f4a883a194f2740e8da68d1aa..f4f700e188bc195fb0e7abdc1bdbec595fdc01ed 100644 --- a/app/code/Magento/Customer/Model/CustomerExtractor.php +++ b/app/code/Magento/Customer/Model/CustomerExtractor.php @@ -40,7 +40,7 @@ class CustomerExtractor protected $customerBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -52,13 +52,13 @@ class CustomerExtractor /** * @param Metadata\FormFactory $formFactory * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param CustomerGroupServiceInterface $groupService */ public function __construct( \Magento\Customer\Model\Metadata\FormFactory $formFactory, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, CustomerGroupServiceInterface $groupService ) { $this->formFactory = $formFactory; diff --git a/app/code/Magento/Customer/Model/CustomerRegistry.php b/app/code/Magento/Customer/Model/CustomerRegistry.php index 2cab8784bda8975d07abf7537dd23880c173aeea..9b16df2d09bdaa227379ce585cecfe449ca14195 100644 --- a/app/code/Magento/Customer/Model/CustomerRegistry.php +++ b/app/code/Magento/Customer/Model/CustomerRegistry.php @@ -26,7 +26,7 @@ namespace Magento\Customer\Model; use Magento\Customer\Model\CustomerFactory; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Registry for \Magento\Customer\Model\Customer @@ -51,7 +51,7 @@ class CustomerRegistry const REGISTRY_SEPARATOR = ':'; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $storeManager; diff --git a/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php b/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php index 530edc374c875b32c295121e2e988676957af74c..799eb75a951ef77c64792982b10437e61b0d18d1 100644 --- a/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php +++ b/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php @@ -56,7 +56,7 @@ class DepersonalizePlugin protected $moduleManager; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ protected $visitor; @@ -81,7 +81,7 @@ class DepersonalizePlugin * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\Module\Manager $moduleManager - * @param \Magento\Log\Model\Visitor $visitor + * @param \Magento\Customer\Model\Visitor $visitor * @param \Magento\PageCache\Model\Config $cacheConfig */ public function __construct( @@ -90,7 +90,7 @@ class DepersonalizePlugin \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\Module\Manager $moduleManager, - \Magento\Log\Model\Visitor $visitor, + \Magento\Customer\Model\Visitor $visitor, \Magento\PageCache\Model\Config $cacheConfig ) { $this->session = $session; diff --git a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php index 1dfefab91b2c79b0b424d9525bc297509eed1221..15f5fababbbb20b15bfba2a826b98bda94c6fed7 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + abstract class AbstractData { /** @@ -284,8 +286,13 @@ abstract class AbstractData $label = $this->getAttribute()->getStoreLabel(); $validateRules = $this->getAttribute()->getValidationRules(); - if (!empty($validateRules['input_validation'])) { - switch ($validateRules['input_validation']) { + $inputValidation = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'input_validation' + ); + + if (!is_null($inputValidation)) { + switch ($inputValidation) { case 'alphanumeric': $validator = new \Zend_Validate_Alnum(true); $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alnum::INVALID); diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Date.php b/app/code/Magento/Customer/Model/Metadata/Form/Date.php index d0ee99a639e4b302efb36ec34deae8428ca04b00..1a6580ccafd15b307d2d27a9b40b0b8df831bed4 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Date.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Date.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + class Date extends AbstractData { /** @@ -65,29 +67,37 @@ class Date extends AbstractData //range validation $validateRules = $attribute->getValidationRules(); - if (!empty($validateRules['date_range_min']) && strtotime( - $value - ) < $validateRules['date_range_min'] || !empty($validateRules['date_range_max']) && strtotime( - $value - ) > $validateRules['date_range_max'] + + $minDateValue = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'date_range_min' + ); + + $maxDateValue = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'date_range_max' + ); + + if (!is_null($minDateValue) && strtotime($value) < $minDateValue + || !is_null($maxDateValue) && strtotime($value) > $maxDateValue ) { - if (!empty($validateRules['date_range_min']) && !empty($validateRules['date_range_max'])) { + if (!is_null($minDateValue) && !is_null($maxDateValue)) { $errors[] = __( 'Please enter a valid date between %1 and %2 at %3.', - date('d/m/Y', $validateRules['date_range_min']), - date('d/m/Y', $validateRules['date_range_max']), + date('d/m/Y', $minDateValue), + date('d/m/Y', $maxDateValue), $label ); - } elseif (!empty($validateRules['date_range_min'])) { + } elseif (!is_null($minDateValue)) { $errors[] = __( 'Please enter a valid date equal to or greater than %1 at %2.', - date('d/m/Y', $validateRules['date_range_min']), + date('d/m/Y', $minDateValue), $label ); - } elseif (!empty($validateRules['date_range_max'])) { + } elseif (!is_null($maxDateValue)) { $errors[] = __( 'Please enter a valid date less than or equal to %1 at %2.', - date('d/m/Y', $validateRules['date_range_max']), + date('d/m/Y', $maxDateValue), $label ); } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/File.php b/app/code/Magento/Customer/Model/Metadata/Form/File.php index abda9a3e1edaec1db7102754b79db5a4134f6497..0a7c45533c2b396f20abdd4376d0f0727cab790b 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/File.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/File.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + class File extends AbstractData { /** @@ -147,9 +149,12 @@ class File extends AbstractData $label = $value['name']; $rules = $this->getAttribute()->getValidationRules(); $extension = pathinfo($value['name'], PATHINFO_EXTENSION); - - if (!empty($rules['file_extensions'])) { - $extensions = explode(',', $rules['file_extensions']); + $fileExtensions = ArrayObjectSearch::getArrayElementByName( + $rules, + 'file_extensions' + ); + if (!is_null($fileExtensions)) { + $extensions = explode(',', $fileExtensions); $extensions = array_map('trim', $extensions); if (!in_array($extension, $extensions)) { return array(__('"%1" is not a valid file extension.', $extension)); @@ -167,9 +172,13 @@ class File extends AbstractData return array(__('"%1" is not a valid file.', $label)); } - if (!empty($rules['max_file_size'])) { + $maxFileSize = ArrayObjectSearch::getArrayElementByName( + $rules, + 'max_file_size' + ); + if (!is_null($maxFileSize)) { $size = $value['size']; - if ($rules['max_file_size'] < $size) { + if ($maxFileSize < $size) { return array(__('"%1" exceeds the allowed file size.', $label)); } } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Image.php b/app/code/Magento/Customer/Model/Metadata/Form/Image.php index fadd7f41f7210780920a073f37baedb3d75874c2..9f3b97397c1c2fbcd293bcb2c4bebb085e965d49 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Image.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Image.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + class Image extends File { /** @@ -57,23 +59,36 @@ class Image extends File $value['name'] = pathinfo($value['name'], PATHINFO_FILENAME) . '.' . $allowImageTypes[$imageProp[2]]; } + $maxFileSize = ArrayObjectSearch::getArrayElementByName( + $rules, + 'max_file_size' + ); $errors = array(); - if (!empty($rules['max_file_size'])) { + if (!is_null($maxFileSize)) { $size = $value['size']; - if ($rules['max_file_size'] < $size) { + if ($maxFileSize < $size) { $errors[] = __('"%1" exceeds the allowed file size.', $label); } } - if (!empty($rules['max_image_width'])) { - if ($rules['max_image_width'] < $imageProp[0]) { - $r = $rules['max_image_width']; + $maxImageWidth = ArrayObjectSearch::getArrayElementByName( + $rules, + 'max_image_width' + ); + if (!is_null($maxImageWidth)) { + if ($maxImageWidth < $imageProp[0]) { + $r = $maxImageWidth; $errors[] = __('"%1" width exceeds allowed value of %2 px.', $label, $r); } } - if (!empty($rules['max_image_heght'])) { - if ($rules['max_image_heght'] < $imageProp[1]) { - $r = $rules['max_image_heght']; + + $maxImageHeight = ArrayObjectSearch::getArrayElementByName( + $rules, + 'max_image_height' + ); + if (!is_null($maxImageHeight)) { + if ($maxImageHeight < $imageProp[1]) { + $r = $maxImageHeight; $errors[] = __('"%1" height exceeds allowed value of %2 px.', $label, $r); } } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Text.php b/app/code/Magento/Customer/Model/Metadata/Form/Text.php index 00b472c807776fd512a9e8dcc07ca7b4b50d6221..d6accf1e5bf07db35b2f891299cfa7528073f94b 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Text.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Text.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + class Text extends AbstractData { /** @@ -90,13 +92,21 @@ class Text extends AbstractData $length = $this->_string->strlen(trim($value)); $validateRules = $attribute->getValidationRules(); - if (!empty($validateRules['min_text_length']) && $length < $validateRules['min_text_length']->getValue()) { - $v = $validateRules['min_text_length']->getValue(); - $errors[] = __('"%1" length must be equal or greater than %2 characters.', $label, $v); + + $minTextLength = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'min_text_length' + ); + if (!is_null($minTextLength) && $length < $minTextLength) { + $errors[] = __('"%1" length must be equal or greater than %2 characters.', $label, $minTextLength); } - if (!empty($validateRules['max_text_length']) && $length > $validateRules['max_text_length']->getValue()) { - $v = $validateRules['max_text_length']->getValue(); - $errors[] = __('"%1" length must be equal or less than %2 characters.', $label, $v); + + $maxTextLength = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'max_text_length' + ); + if (!is_null($maxTextLength) && $length > $maxTextLength) { + $errors[] = __('"%1" length must be equal or less than %2 characters.', $label, $maxTextLength); } $result = $this->_validateInputRule($value); diff --git a/app/code/Magento/Customer/Model/Resource/Customer/CustomersTypeOptions.php b/app/code/Magento/Customer/Model/Resource/Customer/CustomersTypeOptions.php index 23edc6cb58ac62c37667ceb2a96b97e0d22deba2..c16a8eca49aef6960ffe3d47ea869823ae00964a 100644 --- a/app/code/Magento/Customer/Model/Resource/Customer/CustomersTypeOptions.php +++ b/app/code/Magento/Customer/Model/Resource/Customer/CustomersTypeOptions.php @@ -35,8 +35,8 @@ class CustomersTypeOptions implements \Magento\Framework\Option\ArrayInterface public function toOptionArray() { return array( - \Magento\Log\Model\Visitor::VISITOR_TYPE_CUSTOMER => __('Customer'), - \Magento\Log\Model\Visitor::VISITOR_TYPE_VISITOR => __('Visitor') + \Magento\Customer\Model\Visitor::VISITOR_TYPE_CUSTOMER => __('Customer'), + \Magento\Customer\Model\Visitor::VISITOR_TYPE_VISITOR => __('Visitor') ); } } diff --git a/app/code/Magento/Customer/Model/Resource/Visitor.php b/app/code/Magento/Customer/Model/Resource/Visitor.php new file mode 100644 index 0000000000000000000000000000000000000000..260bb66c547d58aba19b4aead580b2965ecdcb65 --- /dev/null +++ b/app/code/Magento/Customer/Model/Resource/Visitor.php @@ -0,0 +1,55 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Resource; + +/** + * Class Visitor + * @package Magento\Customer\Model\Resource + */ +class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb +{ + /** + * Define main table + * + * @return void + */ + protected function _construct() + { + $this->_init('customer_visitor', 'visitor_id'); + } + + /** + * Prepare data for save + * + * @param \Magento\Framework\Model\AbstractModel $visitor + * @return array + */ + protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $visitor) + { + return array( + 'session_id' => $visitor->getSessionId(), + ); + } +} diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index 793aab1e8d6bca23e97294a9a19797d4345f683b..6987d20357855b2315a7b71fed395aa1d4c75ab7 100755 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -126,7 +126,6 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\App\Http\Context $httpContext * @param Converter $converter * @param CustomerAccountServiceInterface $customerAccountService - * @param null $sessionName */ public function __construct( \Magento\Framework\App\Request\Http $request, @@ -147,8 +146,7 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Http\Context $httpContext, \Magento\Customer\Model\Converter $converter, - CustomerAccountServiceInterface $customerAccountService, - $sessionName = null + CustomerAccountServiceInterface $customerAccountService ) { $this->_coreUrl = $coreUrl; $this->_customerData = $customerData; @@ -170,7 +168,7 @@ class Session extends \Magento\Framework\Session\SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start($sessionName); + $this->start(); $this->_converter = $converter; $this->_eventManager->dispatch('customer_session_init', array('customer_session' => $this)); } @@ -401,24 +399,6 @@ class Session extends \Magento\Framework\Session\SessionManager } } - /** - * Customer authorization - * - * @param string $username - * @param string $password - * @return bool - */ - public function login($username, $password) - { - try { - $customer = $this->_customerAccountService->authenticate($username, $password); - $this->setCustomerDataAsLoggedIn($customer); - return true; - } catch (\Exception $e) { - return false; - } - } - /** * @param Customer $customer * @return $this diff --git a/app/code/Magento/Customer/Model/Session/Storage.php b/app/code/Magento/Customer/Model/Session/Storage.php index 9f0c1bceb65f60dd45b5405307a6541623f60fee..76e96ac03fa680c767d37f481175da1e014c9a0b 100644 --- a/app/code/Magento/Customer/Model/Session/Storage.php +++ b/app/code/Magento/Customer/Model/Session/Storage.php @@ -29,13 +29,13 @@ class Storage extends \Magento\Framework\Session\Storage { /** * @param \Magento\Customer\Model\Config\Share $configShare - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param string $namespace * @param array $data */ public function __construct( \Magento\Customer\Model\Config\Share $configShare, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $namespace = 'customer', array $data = array() ) { diff --git a/app/code/Magento/Customer/Model/Visitor.php b/app/code/Magento/Customer/Model/Visitor.php new file mode 100644 index 0000000000000000000000000000000000000000..242cdd822e7d6ffe881574f4c02f139e8cfcdcb2 --- /dev/null +++ b/app/code/Magento/Customer/Model/Visitor.php @@ -0,0 +1,254 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model; + +/** + * Class Visitor + * @package Magento\Customer\Model + */ +class Visitor extends \Magento\Framework\Model\AbstractModel +{ + const VISITOR_TYPE_CUSTOMER = 'c'; + + const VISITOR_TYPE_VISITOR = 'v'; + + /** + * @var string[] + */ + protected $ignoredUserAgents; + + /** + * @var \Magento\Framework\Session\SessionManagerInterface + */ + protected $session; + + /** + * @var \Magento\Framework\HTTP\Header + */ + protected $httpHeader; + + /** + * @var bool + */ + protected $skipRequestLogging = false; + + /** + * Ignored Modules + * + * @var array + */ + protected $ignores; + + /** + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Session\SessionManagerInterface $session + * @param \Magento\Framework\HTTP\Header $httpHeader + * @param \Magento\Framework\Model\Resource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\Db $resourceCollection + * @param array $ignoredUserAgents + * @param array $ignores + * @param array $data + */ + public function __construct( + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Framework\Session\SessionManagerInterface $session, + \Magento\Framework\HTTP\Header $httpHeader, + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\Db $resourceCollection = null, + array $ignoredUserAgents = array(), + array $ignores = array(), + $data = array() + ) { + $this->session = $session; + $this->httpHeader = $httpHeader; + $this->ignoredUserAgents = $ignoredUserAgents; + parent::__construct($context, $registry, $resource, $resourceCollection, $data); + $this->ignores = $ignores; + } + + /** + * Object initialization + * + * @return void + */ + protected function _construct() + { + $this->_init('Magento\Customer\Model\Resource\Visitor'); + $userAgent = $this->httpHeader->getHttpUserAgent(); + if ($this->ignoredUserAgents) { + if (in_array($userAgent, $this->ignoredUserAgents)) { + $this->skipRequestLogging = true; + } + } + } + + /** + * Skip request logging + * + * @param bool $skipRequestLogging + * @return \Magento\Customer\Model\Visitor + */ + public function setSkipRequestLogging($skipRequestLogging) + { + $this->skipRequestLogging = (bool)$skipRequestLogging; + return $this; + } + + /** + * Initialization visitor by request + * + * Used in event "controller_action_predispatch" + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function initByRequest($observer) + { + if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) { + return $this; + } + if ($this->session->getVisitorData()) { + $this->setData($this->session->getVisitorData()); + } + if (!$this->getId()) { + $this->setSessionId($this->session->getSessionId()); + $this->save(); + $this->_eventManager->dispatch('visitor_init', array('visitor' => $this)); + $this->session->setVisitorData($this->getData()); + } + return $this; + } + + /** + * Save visitor by request + * + * Used in event "controller_action_postdispatch" + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function saveByRequest($observer) + { + if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) { + return $this; + } + + try { + $this->save(); + $this->_eventManager->dispatch('visitor_activity_save', array('visitor' => $this)); + $this->session->setVisitorData($this->getData()); + } catch (\Exception $e) { + $this->_logger->logException($e); + } + return $this; + } + + /** + * Returns true if the module is required + * + * @param \Magento\Framework\Event\Observer $observer + * @return bool + */ + public function isModuleIgnored($observer) + { + if (is_array($this->ignores) && $observer) { + $curModule = $observer->getEvent()->getControllerAction()->getRequest()->getRouteName(); + if (isset($this->ignores[$curModule])) { + return true; + } + } + return false; + } + + /** + * Bind customer data when customer login + * + * Used in event "customer_login" + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function bindCustomerLogin($observer) + { + /** @var \Magento\Customer\Service\V1\Data\Customer $customer */ + $customer = $observer->getEvent()->getCustomer(); + if (!$this->getCustomerId()) { + $this->setDoCustomerLogin(true); + $this->setCustomerId($customer->getId()); + } + return $this; + } + + /** + * Bind customer data when customer logout + * + * Used in event "customer_logout" + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function bindCustomerLogout($observer) + { + if ($this->getCustomerId()) { + $this->setDoCustomerLogout(true); + } + return $this; + } + + /** + * Create binding of checkout quote + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function bindQuoteCreate($observer) + { + $quote = $observer->getEvent()->getQuote(); + if ($quote) { + if ($quote->getIsCheckoutCart()) { + $this->setQuoteId($quote->getId()); + $this->setDoQuoteCreate(true); + } + } + return $this; + } + + /** + * Destroy binding of checkout quote + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function bindQuoteDestroy($observer) + { + $quote = $observer->getEvent()->getQuote(); + if ($quote) { + $this->setDoQuoteDestroy(true); + } + return $this; + } +} diff --git a/app/code/Magento/Customer/Service/V1/AddressMetadataService.php b/app/code/Magento/Customer/Service/V1/AddressMetadataService.php index 6b7754efe17c835e7cdea98bfcb0882fad2faf5f..fd526f96749b7224a50a0238902c40f82d58900a 100644 --- a/app/code/Magento/Customer/Service/V1/AddressMetadataService.php +++ b/app/code/Magento/Customer/Service/V1/AddressMetadataService.php @@ -29,6 +29,7 @@ use Magento\Customer\Service\V1\Data\Eav\AttributeMetadataDataProvider; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Service\Config\MetadataConfig; +use Magento\Framework\Service\SimpleDataObjectConverter; /** * Service to fetch customer address related custom attributes @@ -145,7 +146,7 @@ class AddressMetadataService implements AddressMetadataServiceInterface } foreach ($this->getAllAttributesMetadata() as $attributeMetadata) { $attributeCode = $attributeMetadata->getAttributeCode(); - $camelCaseKey = \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($attributeCode); + $camelCaseKey = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode); $isDataObjectMethod = isset($this->addressDataObjectMethods['get' . $camelCaseKey]) || isset($this->addressDataObjectMethods['is' . $camelCaseKey]); diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php index e1c6efe12046e70052fc1bf30ddc4c31e297f178..4000b68b0a56f4ff3f5098a235643323c35a2849 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php @@ -51,7 +51,7 @@ use Magento\Framework\Service\V1\Data\Search\FilterGroup; use Magento\Framework\Service\V1\Data\SearchCriteria; use Magento\Framework\Service\V1\Data\SortOrder; use Magento\Framework\UrlInterface; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Handle various customer account actions @@ -88,7 +88,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface private $eventManager; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $storeManager; @@ -150,7 +150,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface /** * @param CustomerFactory $customerFactory * @param ManagerInterface $eventManager - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Random $mathRandom * @param Converter $converter * @param Validator $validator diff --git a/app/code/Magento/Customer/Service/V1/CustomerGroupService.php b/app/code/Magento/Customer/Service/V1/CustomerGroupService.php index 9f14aecfaa99814311a4d0077d2bd04849511705..60bd524faf707d608866e554f65734f5c8ed7aab 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerGroupService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerGroupService.php @@ -24,7 +24,7 @@ namespace Magento\Customer\Service\V1; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Customer\Model\Group as CustomerGroupModel; use Magento\Customer\Model\GroupFactory; use Magento\Customer\Model\GroupRegistry; @@ -58,7 +58,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface private $_scopeConfig; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $_storeManager; @@ -90,7 +90,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface /** * @param GroupFactory $groupFactory * @param ScopeConfigInterface $scopeConfig - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Data\SearchResultsBuilder $searchResultsBuilder * @param Data\CustomerGroupBuilder $customerGroupBuilder * @param TaxClassServiceInterface $taxClassService @@ -246,7 +246,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId ); - } catch (\Magento\Framework\Model\Exception $e) { + } catch (\Magento\Framework\App\InitException $e) { throw NoSuchEntityException::singleField('storeId', $storeId); } try { diff --git a/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php index c6aab6c9f9b206e8a8970d6885fd401ed11ac01c..c2926abcaf55beec204492f41696853573a19441 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php +++ b/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php @@ -52,7 +52,7 @@ interface CustomerGroupServiceInterface * * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria * @throws \Magento\Framework\Exception\InputException If there is a problem with the input - * @return \Magento\Customer\Service\V1\Data\SearchResults containing Data\CustomerGroup objects + * @return \Magento\Customer\Service\V1\Data\CustomerGroupSearchResults containing Data\CustomerGroup objects */ public function searchGroups(\Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria); diff --git a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php index 8d500fdd9bde5c4ab66851b5a2d08ca05d7dd71e..b37ac0978714ad35b43bca78dc2077ed77272105 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php @@ -29,6 +29,7 @@ use Magento\Customer\Service\V1\Data\Eav\AttributeMetadataDataProvider; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Service\Config\MetadataConfig; +use Magento\Framework\Service\SimpleDataObjectConverter; /** * Service to fetch customer related custom attributes @@ -146,7 +147,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface } foreach ($this->getAllAttributesMetadata() as $attributeMetadata) { $attributeCode = $attributeMetadata->getAttributeCode(); - $camelCaseKey = \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($attributeCode); + $camelCaseKey = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode); $isDataObjectMethod = isset($this->customerDataObjectMethods['get' . $camelCaseKey]) || isset($this->customerDataObjectMethods['is' . $camelCaseKey]); diff --git a/app/code/Magento/Install/Controller/Wizard/DownloadAuto.php b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResults.php similarity index 72% rename from app/code/Magento/Install/Controller/Wizard/DownloadAuto.php rename to app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResults.php index 5e178dc7c1a16d681fab8c7c93254f5128070a7c..4e2c8f70d06fd9a261800f9e6cbe0f0bcfebdddc 100644 --- a/app/code/Magento/Install/Controller/Wizard/DownloadAuto.php +++ b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResults.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,18 +21,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class DownloadAuto extends \Magento\Install\Controller\Wizard +namespace Magento\Customer\Service\V1\Data; + +/** + * SearchResults Service Data Object used for the search service requests + */ +class CustomerGroupSearchResults extends \Magento\Framework\Service\V1\Data\SearchResults { /** - * Download auto action + * Get items * - * @return void + * @return \Magento\Customer\Service\V1\Data\CustomerGroup[] */ - public function execute() + public function getItems() { - $step = $this->_getWizard()->getStepByName('download'); - $this->getResponse()->setRedirect($step->getNextUrl()); + return parent::getItems(); } } diff --git a/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php new file mode 100644 index 0000000000000000000000000000000000000000..a7cc9ad6026a8cdb3e301809d2deeabe77dcb47b --- /dev/null +++ b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php @@ -0,0 +1,75 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Service\V1\Data; + +use Magento\Framework\Service\Data\ObjectFactory; +use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +use Magento\Framework\Service\V1\Data\AbstractSearchResultsBuilder; +use Magento\Framework\Service\Data\AttributeValueBuilder; +use Magento\Framework\Service\Data\MetadataServiceInterface; + +/** + * Builder for the SearchResults Service Data Object + * + * @method \Magento\Customer\Service\V1\Data\CustomerGroupSearchResults create() + */ +class CustomerGroupSearchResultsBuilder extends AbstractSearchResultsBuilder +{ + /** + * Constructor + * + * @param ObjectFactory $objectFactory + * @param AttributeValueBuilder $valueBuilder + * @param MetadataServiceInterface $metadataService + * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param CustomerDetailsBuilder $itemObjectBuilder + */ + public function __construct( + ObjectFactory $objectFactory, + AttributeValueBuilder $valueBuilder, + MetadataServiceInterface $metadataService, + SearchCriteriaBuilder $searchCriteriaBuilder, + CustomerDetailsBuilder $itemObjectBuilder + ) { + parent::__construct( + $objectFactory, + $valueBuilder, + $metadataService, + $searchCriteriaBuilder, + $itemObjectBuilder + ); + } + + /** + * Set customer details items + * + * @param \Magento\Customer\Service\V1\Data\CustomerGroup[] $customerGroupItems + * @return $this + */ + public function setItems($customerGroupItems) + { + return parent::setItems($customerGroupItems); + } +} diff --git a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverter.php b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverter.php index 8f86564c8e02a94b88040a44f76d39ba57a9f160..507bc29f52cdcdc0231d7cfc36dad66e128fa8d5 100644 --- a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverter.php +++ b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverter.php @@ -86,21 +86,21 @@ class AttributeMetadataConverter $this->_attributeMetadataBuilder->setAttributeCode($attribute->getAttributeCode()) ->setFrontendInput($attribute->getFrontendInput()) - ->setInputFilter($attribute->getInputFilter()) + ->setInputFilter((string)$attribute->getInputFilter()) ->setStoreLabel($attribute->getStoreLabel()) ->setValidationRules($validationRules) - ->setVisible($attribute->getIsVisible()) - ->setRequired($attribute->getIsRequired()) - ->setMultilineCount($attribute->getMultilineCount()) - ->setDataModel($attribute->getDataModel()) + ->setVisible((boolean)$attribute->getIsVisible()) + ->setRequired((boolean)$attribute->getIsRequired()) + ->setMultilineCount((int)$attribute->getMultilineCount()) + ->setDataModel((string)$attribute->getDataModel()) ->setOptions($options) ->setFrontendClass($attribute->getFrontend()->getClass()) ->setFrontendLabel($attribute->getFrontendLabel()) + ->setNote((string)$attribute->getNote()) + ->setIsSystem((boolean)$attribute->getIsSystem()) + ->setIsUserDefined((boolean)$attribute->getIsUserDefined()) ->setBackendType($attribute->getBackendType()) - ->setNote($attribute->getNote()) - ->setIsSystem($attribute->getIsSystem()) - ->setIsUserDefined($attribute->getIsUserDefined()) - ->setSortOrder($attribute->getSortOrder()); + ->setSortOrder((int)$attribute->getSortOrder()); return $this->_attributeMetadataBuilder->create(); } diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index 9423c2a57353ea949a4f2ab8e577809d550a1efb..ecfc6424ec88260d9e3a2e7718d74ec8c2cb8f73 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -3,29 +3,28 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-newsletter": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/module-log": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-review": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", - "magento/module-authorization": "0.1.0-alpha94", - "magento/module-integration": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-newsletter": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-review": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/module-authorization": "0.1.0-alpha95", + "magento/module-integration": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/etc/acl.xml b/app/code/Magento/Customer/etc/acl.xml index 0544b9cd0e6145bee3c61b552f46e4178eb642fe..2c21ac3e63d99d0f4897abfcd73250e7657305a7 100644 --- a/app/code/Magento/Customer/etc/acl.xml +++ b/app/code/Magento/Customer/etc/acl.xml @@ -29,7 +29,6 @@ <resource id="Magento_Adminhtml::admin"> <resource id="Magento_Customer::customer" title="Customers" sortOrder="40"> <resource id="Magento_Customer::manage" title="All Customers" sortOrder="10" /> - <resource id="Magento_Customer::online" title="Now Online" sortOrder="20" /> </resource> <resource id="Magento_Adminhtml::stores"> <resource id="Magento_Adminhtml::stores_settings"> diff --git a/app/code/Magento/Customer/etc/adminhtml/di.xml b/app/code/Magento/Customer/etc/adminhtml/di.xml index 18759291cfbd655851d6ea0ce2cc3229a42c0f8f..cf67a2c6c8fcc4de19804ccd8967bef3805467dc 100644 --- a/app/code/Magento/Customer/etc/adminhtml/di.xml +++ b/app/code/Magento/Customer/etc/adminhtml/di.xml @@ -25,11 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Customer\Model\Customer" type="Magento\Customer\Model\Backend\Customer" /> - <type name="Magento\Customer\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Customer\Model\Resource\Customer\Collection"> <arguments> <argument name="modelName" xsi:type="string">Magento\Customer\Model\Backend\Customer</argument> diff --git a/app/code/Magento/Customer/etc/adminhtml/menu.xml b/app/code/Magento/Customer/etc/adminhtml/menu.xml index a924f1a5b8256ec9558afa8299bb38f43dce6a2f..e40abf8cacaf65b1b7592a0aeb5193fcd18a609d 100644 --- a/app/code/Magento/Customer/etc/adminhtml/menu.xml +++ b/app/code/Magento/Customer/etc/adminhtml/menu.xml @@ -27,7 +27,6 @@ <menu> <add id="Magento_Customer::customer" title="Customers" module="Magento_Customer" sortOrder="30" resource="Magento_Customer::customer"/> <add id="Magento_Customer::customer_manage" title="All Customers" module="Magento_Customer" sortOrder="10" parent="Magento_Customer::customer" action="customer/index/" resource="Magento_Customer::manage"/> - <add id="Magento_Customer::customer_group" title="Customer Groups" module="Magento_Customer" sortOrder="10" parent="Magento_Backend::other_settings" action="customer/group" resource="Magento_Customer::group"/> - <add id="Magento_Customer::customer_online" title="Now Online" module="Magento_Customer" sortOrder="30" parent="Magento_Customer::customer" action="customer/online" resource="Magento_Customer::online"/> + <add id="Magento_Customer::customer_group" title="Customer Groups" module="Magento_Customer" sortOrder="50" parent="Magento_Backend::other_settings" action="customer/group" resource="Magento_Customer::group"/> </menu> </config> diff --git a/app/code/Magento/Customer/etc/adminhtml/system.xml b/app/code/Magento/Customer/etc/adminhtml/system.xml index 63bb505e76df5e197f05bc53a2b94a648ac73af5..f16fe02965308de718d67a2b081527c8802fffb8 100644 --- a/app/code/Magento/Customer/etc/adminhtml/system.xml +++ b/app/code/Magento/Customer/etc/adminhtml/system.xml @@ -42,13 +42,6 @@ <source_model>Magento\Customer\Model\Config\Share</source_model> </field> </group> - <group id="online_customers" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0"> - <label>Online Customers Options</label> - <field id="online_minutes_interval" translate="label comment" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0"> - <label>Online Minutes Interval</label> - <comment>Leave empty for default (15 minutes).</comment> - </field> - </group> <group id="create_account" translate="label" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Create New Account Options</label> <field id="auto_group_assign" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index d0e5445bf4945bb529ce20ad0fd1750e98dd7bc7..fae0105f3303357073aae8aa3591e1bbdcecba99 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -111,4 +111,13 @@ </argument> </arguments> </type> + <type name="Magento\Customer\Model\Visitor"> + <arguments> + <argument name="ignoredUserAgents" xsi:type="array"> + <item name="google1" xsi:type="string">Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/)</item> + <item name="google2" xsi:type="string">Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</item> + <item name="google3" xsi:type="string">Googlebot/2.1 (+http://www.googlebot.com/bot.html)</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Customer/etc/frontend/di.xml b/app/code/Magento/Customer/etc/frontend/di.xml index 3946f5ec328d88f7dac9e83b1d167d00d2a35f4e..d2f6c3bde8823ddf886940a903df2267e1f35d8e 100644 --- a/app/code/Magento/Customer/etc/frontend/di.xml +++ b/app/code/Magento/Customer/etc/frontend/di.xml @@ -24,11 +24,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Customer\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/code/Magento/Customer/etc/frontend/events.xml b/app/code/Magento/Customer/etc/frontend/events.xml new file mode 100644 index 0000000000000000000000000000000000000000..2c360b2c57325ed95a8cf20c27780d91f0308e13 --- /dev/null +++ b/app/code/Magento/Customer/etc/frontend/events.xml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> + <event name="controller_action_predispatch"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="initByRequest" /> + </event> + <event name="controller_action_postdispatch"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="saveByRequest" /> + </event> + <event name="customer_data_object_login"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindCustomerLogin" /> + </event> + <event name="customer_logout"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindCustomerLogout" /> + </event> + <event name="sales_quote_save_after"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindQuoteCreate" /> + </event> + <event name="checkout_quote_destroy"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindQuoteDestroy" /> + </event> +</config> diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml index 57366ea6e061a25f1def4716e32ca3cca75bb4e4..e50495d8ebbe045bcee97e5e0c12fd04b9e5dc8e 100644 --- a/app/code/Magento/Customer/etc/module.xml +++ b/app/code/Magento/Customer/etc/module.xml @@ -41,7 +41,6 @@ <module name="Magento_Checkout"/> <module name="Magento_Wishlist"/> <module name="Magento_Index"/> - <module name="Magento_Log"/> <module name="Magento_Theme"/> <module name="Magento_Backend"/> <module name="Magento_Review"/> diff --git a/app/code/Magento/Customer/etc/webapi_rest/di.xml b/app/code/Magento/Customer/etc/webapi_rest/di.xml index 8eb5b6d92bad5930a8c69df36d255cf2cdea565b..265cd7ec07d2021223f49a2218ae6ad92abaf037 100644 --- a/app/code/Magento/Customer/etc/webapi_rest/di.xml +++ b/app/code/Magento/Customer/etc/webapi_rest/di.xml @@ -27,11 +27,6 @@ <type name="Magento\Framework\Authorization"> <plugin name="customerAuthorization" type="Magento\Customer\Model\Plugin\CustomerAuthorization" /> </type> - <type name="Magento\Customer\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Authorization\Model\CompositeUserContext"> <arguments> <argument name="userContexts" xsi:type="array"> diff --git a/app/code/Magento/Customer/i18n/de_DE.csv b/app/code/Magento/Customer/i18n/de_DE.csv index 3e4beea48892f32a4479ce96706e598e452e1a29..e138d63071cf90f8d6ef40ef8de27353c9aec7d5 100644 --- a/app/code/Magento/Customer/i18n/de_DE.csv +++ b/app/code/Magento/Customer/i18n/de_DE.csv @@ -124,7 +124,6 @@ Unknown,Unbekannt "Purchase Point","Gekauft von" Never,Niemals Offline,Offline -Online,Online Confirmed,Bestätigt "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -223,8 +222,6 @@ Visitor,Besucher "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers",Online-Kunden "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -354,8 +351,6 @@ Gender,Geschlecht "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/en_US.csv b/app/code/Magento/Customer/i18n/en_US.csv index 750c6cda24723a05a48cc281c2267a9f255e15a4..f3ed0e19fb9e3d087f254aa5694a15c5877161f7 100644 --- a/app/code/Magento/Customer/i18n/en_US.csv +++ b/app/code/Magento/Customer/i18n/en_US.csv @@ -124,7 +124,6 @@ Unknown,Unknown "Purchase Point","Purchase Point" Never,Never Offline,Offline -Online,Online Confirmed,Confirmed "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Visitor "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Online Customers" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Gender "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/es_ES.csv b/app/code/Magento/Customer/i18n/es_ES.csv index c0299f4a92309244d844f921b5eec6fc96ac0f9c..6ee5727639a0e87b37b1e8b2b606bcc51d7d11ed 100644 --- a/app/code/Magento/Customer/i18n/es_ES.csv +++ b/app/code/Magento/Customer/i18n/es_ES.csv @@ -124,7 +124,6 @@ Unknown,Desconocido "Purchase Point","Comprado a" Never,Nunca Offline,"Sin conexión" -Online,Conectado Confirmed,Confirmado "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Visitante "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Clientes conectados" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Género "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/fr_FR.csv b/app/code/Magento/Customer/i18n/fr_FR.csv index fd68872af3d29f7129f1b3483df0c66ca16375b2..e32c2759c36ce1355a2701d6fa58a33183142e54 100644 --- a/app/code/Magento/Customer/i18n/fr_FR.csv +++ b/app/code/Magento/Customer/i18n/fr_FR.csv @@ -124,7 +124,6 @@ Unknown,Inconnu "Purchase Point","Acheté à " Never,Jamais Offline,"Hors ligne" -Online,"En ligne" Confirmed,Confirmé "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Visiteur "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Utilisateurs en ligne" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Genre "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/nl_NL.csv b/app/code/Magento/Customer/i18n/nl_NL.csv index c4322feb6924758e2dbb3074bcff64e4e310d68c..bde6b074652d886e1e53606600c0dbb044e43596 100644 --- a/app/code/Magento/Customer/i18n/nl_NL.csv +++ b/app/code/Magento/Customer/i18n/nl_NL.csv @@ -124,7 +124,6 @@ Unknown,Onbekend "Purchase Point","Gekocht van" Never,Nooit Offline,Offline -Online,Online Confirmed,Bevestigd "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Bezoeker "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Online Klanten" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Geslacht "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/pt_BR.csv b/app/code/Magento/Customer/i18n/pt_BR.csv index ade84e7110e204d42bd94181b2a1c0793c66aa68..b02e6801702bab888b2741cb932bbf68bf5acf86 100644 --- a/app/code/Magento/Customer/i18n/pt_BR.csv +++ b/app/code/Magento/Customer/i18n/pt_BR.csv @@ -124,7 +124,6 @@ Unknown,Desconhecido "Purchase Point","Comprado De" Never,Nunca Offline,Offline -Online,Online Confirmed,Confirmado "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Visitante "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Clientes Conectados" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Sexo "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/zh_CN.csv b/app/code/Magento/Customer/i18n/zh_CN.csv index fab9fab5096c278a67b2e0a3e727ddad9a63d271..e344fa595c39e2e87f0340f5f88f143b18249a5a 100644 --- a/app/code/Magento/Customer/i18n/zh_CN.csv +++ b/app/code/Magento/Customer/i18n/zh_CN.csv @@ -124,7 +124,6 @@ Unknown,未知 "Purchase Point","Purchase Point" Never,æ°¸ä¸ Offline,离线 -Online,在线 Confirmed,已确认 "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,访客 "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers",在线客户 "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,性别 "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/sql/customer_setup/install-1.6.0.0.php b/app/code/Magento/Customer/sql/customer_setup/install-1.6.0.0.php index 943efd8259a2304c49d065b8acc1cec91d81099d..041ddc08a6bc8d502d6f216e4c5d112bee2df64f 100644 --- a/app/code/Magento/Customer/sql/customer_setup/install-1.6.0.0.php +++ b/app/code/Magento/Customer/sql/customer_setup/install-1.6.0.0.php @@ -1158,4 +1158,26 @@ $table = $installer->getConnection()->newTable( ); $installer->getConnection()->createTable($table); +/** + * Create table 'customer_visitor' + */ +$table = $installer->getConnection()->newTable( + $installer->getTable('customer_visitor') +)->addColumn( + 'visitor_id', + \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, + null, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Visitor ID' +)->addColumn( + 'session_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 64, + array('nullable' => true, 'default' => null), + 'Session ID' +)->setComment( + 'Visitor Table' +); +$installer->getConnection()->createTable($table); + $installer->endSetup(); diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml index bf6b44f9c1b18b6d075573507e36635a22243c7f..03053ea4bd547bcbd4857857784dff656938db9c 100644 --- a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml +++ b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml @@ -30,7 +30,8 @@ <referenceContainer name="left"> <block class="Magento\Customer\Block\Adminhtml\Edit\Tabs" name="customer_edit_tabs"> <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View" name="customer_edit_tab_view" template="tab/view.phtml"> - <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales" name="sales" template="tab/view/sales.phtml" before="-"/> + <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo" name="personal_info" template="tab/view/personal_info.phtml"/> + <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales" name="sales" template="tab/view/sales.phtml"/> <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\Accordion" name="accordion"/> </block> <action method="addTab"> diff --git a/app/code/Magento/Customer/view/adminhtml/templates/tab/view.phtml b/app/code/Magento/Customer/view/adminhtml/templates/tab/view.phtml index 56fe8a46b002422d3deefd889b4d769cf9ed5be6..95b09367f8e5eeee272c77c55fbeb721be3e5193 100644 --- a/app/code/Magento/Customer/view/adminhtml/templates/tab/view.phtml +++ b/app/code/Magento/Customer/view/adminhtml/templates/tab/view.phtml @@ -21,64 +21,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -?> -<?php + /** * Template for block \Magento\Customer\Block\Adminhtml\Edit\Tab\View */ -?> -<?php -$lastLoginDateAdmin = $this->getLastLoginDate(); -$lastLoginDateStore = $this->getStoreLastLoginDate(); - -$createDateAdmin = $this->getCreateDate(); -$createDateStore = $this->getStoreCreateDate(); -?> - -<div class="fieldset-wrapper customer-information"> - <div class="fieldset-wrapper-title"> - <span class="title"><?php echo __('Personal Information') ?></span> - </div> - <table class="data-table"> - <tbody> - <tr> - <th><?php echo __('Last Logged In:') ?></th> - <td><?php echo $lastLoginDateAdmin ?> (<?php echo $this->getCurrentStatus() ?>)</td> - </tr> - <?php if ($lastLoginDateAdmin != $lastLoginDateStore): ?> - <tr> - <th><?php echo __('Last Logged In (%1):', $this->getStoreLastLoginDateTimezone()) ?></th> - <td><?php echo $lastLoginDateStore ?> (<?php echo $this->getCurrentStatus() ?>)</td> - </tr> - <?php endif; ?> - <tr> - <th><?php echo __('Confirmed email:') ?></th> - <td><?php echo $this->getIsConfirmedStatus() ?></td> - </tr> - <tr> - <th><?php echo __('Account Created on:') ?></th> - <td><?php echo $createDateAdmin ?></td> - </tr> - <?php if ($createDateAdmin != $createDateStore): ?> - <tr> - <th><?php echo __('Account Created on (%1):', $this->getStoreCreateDateTimezone()) ?></th> - <td><?php echo $createDateStore ?></td> - </tr> - <?php endif; ?> - <tr> - <th><?php echo __('Account Created in:') ?></th> - <td><?php echo $this->getCreatedInStore() ?></td> - </tr> - <tr> - <th><?php echo __('Customer Group:') ?></th> - <td><?php echo $this->getGroupName() ?></td> - </tr> - </tbody> - </table> - <address> - <strong><?php echo __('Default Billing Address') ?></strong><br/> - <?php echo $this->getBillingAddressHtml() ?> - </address> -</div> -<?php echo $this->getChildHtml('', true); ?> +/** @var $this \Magento\Customer\Block\Adminhtml\Edit\Tab\View */ +echo $this->getChildHtml(); diff --git a/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml b/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml new file mode 100644 index 0000000000000000000000000000000000000000..d065d51400b9cbe32d04a9ed0b65a8ae97c3bdb8 --- /dev/null +++ b/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml @@ -0,0 +1,69 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/** + * Template for block \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Status\PersonalInfo + */ + +$createDateAdmin = $this->getCreateDate(); +$createDateStore = $this->getStoreCreateDate(); +?> + +<div class="fieldset-wrapper customer-information"> + <div class="fieldset-wrapper-title"> + <span class="title"><?php echo __('Personal Information') ?></span> + </div> + <table class="data-table"> + <tbody> + <?php echo $this->getChildHtml(); ?> + <tr> + <th><?php echo __('Confirmed email:') ?></th> + <td><?php echo $this->getIsConfirmedStatus() ?></td> + </tr> + <tr> + <th><?php echo __('Account Created on:') ?></th> + <td><?php echo $createDateAdmin ?></td> + </tr> + <?php if ($createDateAdmin != $createDateStore): ?> + <tr> + <th><?php echo __('Account Created on (%1):', $this->getStoreCreateDateTimezone()) ?></th> + <td><?php echo $createDateStore ?></td> + </tr> + <?php endif; ?> + <tr> + <th><?php echo __('Account Created in:') ?></th> + <td><?php echo $this->getCreatedInStore() ?></td> + </tr> + <tr> + <th><?php echo __('Customer Group:') ?></th> + <td><?php echo $this->getGroupName() ?></td> + </tr> + </tbody> + </table> + <address> + <strong><?php echo __('Default Billing Address') ?></strong><br/> + <?php echo $this->getBillingAddressHtml() ?> + </address> + +</div> diff --git a/app/code/Magento/CustomerImportExport/Model/Export/Address.php b/app/code/Magento/CustomerImportExport/Model/Export/Address.php index bd8929afe956d15a4878e18330c1d691aa70ae0e..cde53e340c30eb8ee555dfbba372b2279523ef85 100644 --- a/app/code/Magento/CustomerImportExport/Model/Export/Address.php +++ b/app/code/Magento/CustomerImportExport/Model/Export/Address.php @@ -118,7 +118,7 @@ class Address extends \Magento\ImportExport\Model\Export\Entity\AbstractEav /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -130,7 +130,7 @@ class Address extends \Magento\ImportExport\Model\Export\Entity\AbstractEav */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/CustomerImportExport/Model/Export/Customer.php b/app/code/Magento/CustomerImportExport/Model/Export/Customer.php index 58bda0850c83ab8d760bd6f71b11a1b16acfefbe..718cf7f4196be010e57ca0db64375fa0d800febb 100644 --- a/app/code/Magento/CustomerImportExport/Model/Export/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Export/Customer.php @@ -99,7 +99,7 @@ class Customer extends \Magento\ImportExport\Model\Export\Entity\AbstractEav /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -109,7 +109,7 @@ class Customer extends \Magento\ImportExport\Model\Export\Entity\AbstractEav */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php b/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php index 2af423a80986a09a06655d5f2a8a9f42e9312e6c..97bd975cdee9f00d1d3ef11e4af80afe7e796329 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php @@ -92,7 +92,7 @@ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entit * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory @@ -105,7 +105,7 @@ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entit \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory, diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Address.php b/app/code/Magento/CustomerImportExport/Model/Import/Address.php index e685f184a64c214c1153fa05debe215a7b9199d7..cdf4fcd913db8a056b800d80980e8e33a127dca4 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Address.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Address.php @@ -233,7 +233,7 @@ class Address extends AbstractCustomer * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory @@ -252,7 +252,7 @@ class Address extends AbstractCustomer \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory, diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index 86a218799485f81b89731a299357294897e29279..4977b6ddd2d6d74cf00377c8e5f2d619a1d40c04 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -139,7 +139,7 @@ class Customer extends AbstractCustomer * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory @@ -154,7 +154,7 @@ class Customer extends AbstractCustomer \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory, diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index 9760ec47fb6af2cd212275126e5f1f16185642c6..b49fe86e51de7cadb3e2580375c4888e507728b0 100644 --- a/app/code/Magento/CustomerImportExport/composer.json +++ b/app/code/Magento/CustomerImportExport/composer.json @@ -3,18 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-import-export": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-import-export": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CustomerImportExport/etc/module.xml b/app/code/Magento/CustomerImportExport/etc/module.xml index c86315663dcb0e4bb0b3b27797417011c07242e4..ad900498b030fd3da4d1dc5937549e99e49cdc5e 100644 --- a/app/code/Magento/CustomerImportExport/etc/module.xml +++ b/app/code/Magento/CustomerImportExport/etc/module.xml @@ -31,7 +31,6 @@ <module name="Magento_Customer"/> <module name="Magento_Eav"/> <module name="Magento_ImportExport"/> - <module name="Magento_Store"/> <module name="Magento_Directory"/> </depends> </module> diff --git a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/AssignThemeToStore.php b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/AssignThemeToStore.php index 889a71cb75d9f1ce65c31318757a0ecc46e7b422..e8c1c207390cda7461367c99fece14214e6fa72f 100644 --- a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/AssignThemeToStore.php +++ b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/AssignThemeToStore.php @@ -44,8 +44,8 @@ class AssignThemeToStore extends \Magento\DesignEditor\Controller\Adminhtml\Syst $defaultStore = -1; $emptyStores = -2; if ($stores == $defaultStore) { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); $ids = array_keys($storeManager->getStores()); $stores = array(array_shift($ids)); } elseif ($stores == $emptyStores) { diff --git a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php index 21dcd9aa839602052135dbdf16a0647c92e09e4c..2de881bb8c26078998c06a5e13b7e708dcefa508 100644 --- a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php +++ b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php @@ -74,9 +74,8 @@ class Standard extends \Magento\Core\App\Router\Base * @param \Magento\Framework\App\DefaultPathInterface $defaultPath * @param \Magento\Framework\App\ResponseFactory $responseFactory * @param \Magento\Framework\App\Route\Config $routeConfig - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo * @param string $routerId @@ -95,9 +94,8 @@ class Standard extends \Magento\Core\App\Router\Base \Magento\Framework\App\DefaultPathInterface $defaultPath, \Magento\Framework\App\ResponseFactory $responseFactory, \Magento\Framework\App\Route\Config $routeConfig, - \Magento\Framework\App\State $appState, \Magento\Framework\UrlInterface $url, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo, $routerId, @@ -114,7 +112,6 @@ class Standard extends \Magento\Core\App\Router\Base $defaultPath, $responseFactory, $routeConfig, - $appState, $url, $storeManager, $scopeConfig, diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index 09692fa19f65ca4b055218d227db837daa41f551..a45ad0cde17af44428ad2f5d2a4d01b1e4a53cfe 100644 --- a/app/code/Magento/DesignEditor/composer.json +++ b/app/code/Magento/DesignEditor/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-url-rewrite": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-url-rewrite": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 7bd9e54369fac9d66dce329cf31546795866e502..72e086e86201ad722df978b4884b8a995b84d980 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -168,7 +168,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin protected $_coreDate; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -221,7 +221,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin * @param \Magento\Shipping\Helper\Carrier $carrierHelper * @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Framework\Module\Dir\Reader $configReader - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\String $string * @param \Magento\Framework\Math\Division $mathDivision * @param \Magento\Framework\App\Filesystem $filesystem @@ -248,7 +248,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin \Magento\Shipping\Helper\Carrier $carrierHelper, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, \Magento\Framework\Module\Dir\Reader $configReader, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\String $string, \Magento\Framework\Math\Division $mathDivision, \Magento\Framework\App\Filesystem $filesystem, diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index ff8059e683063b83f34eb205ebf035489bf486c6..f78d20be33e0ce101296269b786c8794d02df172 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Directory/Controller/Currency/SwitchAction.php b/app/code/Magento/Directory/Controller/Currency/SwitchAction.php index c37f8e497c530bbb5f6200773616c34ca2355f6b..3d1af1076580d459dd01e00f310f0b0976ee0d77 100644 --- a/app/code/Magento/Directory/Controller/Currency/SwitchAction.php +++ b/app/code/Magento/Directory/Controller/Currency/SwitchAction.php @@ -31,8 +31,8 @@ class SwitchAction extends \Magento\Framework\App\Action\Action */ public function execute() { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); $currency = (string)$this->getRequest()->getParam('currency'); if ($currency) { $storeManager->getStore()->setCurrentCurrencyCode($currency); diff --git a/app/code/Magento/Directory/Helper/Data.php b/app/code/Magento/Directory/Helper/Data.php index fc182e6f199482fef0f89420fe2ae28d325d1557..a85dfddec4e59db2524cdcaa77e11c8579643495 100644 --- a/app/code/Magento/Directory/Helper/Data.php +++ b/app/code/Magento/Directory/Helper/Data.php @@ -95,7 +95,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_coreHelper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -115,7 +115,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Directory\Model\Resource\Country\Collection $countryCollection * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regCollectionFactory, * @param \Magento\Core\Helper\Data $coreHelper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ @@ -125,7 +125,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Directory\Model\Resource\Country\Collection $countryCollection, \Magento\Directory\Model\Resource\Region\CollectionFactory $regCollectionFactory, \Magento\Core\Helper\Data $coreHelper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { diff --git a/app/code/Magento/Directory/Helper/Url.php b/app/code/Magento/Directory/Helper/Url.php index feabdfd53505821c1bf93e73b10f52c05951007c..e093751a34572df25c487da9f760483231385b26 100644 --- a/app/code/Magento/Directory/Helper/Url.php +++ b/app/code/Magento/Directory/Helper/Url.php @@ -38,12 +38,12 @@ class Url extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\Data $coreData */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\Data $coreData ) { $this->_coreData = $coreData; diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php index d6a39c2e311c8d9358d09a5fc148841b110ab04b..b0268d944649a8cdc6de7290dba275ec0d404476 100644 --- a/app/code/Magento/Directory/Model/Currency.php +++ b/app/code/Magento/Directory/Model/Currency.php @@ -61,7 +61,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel protected $_localeFormat; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -84,7 +84,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Locale\FormatInterface $localeFormat - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Helper\Data $directoryHelper * @param Currency\FilterFactory $currencyFilterFactory * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency @@ -96,7 +96,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Locale\FormatInterface $localeFormat, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Directory\Model\Currency\FilterFactory $currencyFilterFactory, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, diff --git a/app/code/Magento/Directory/Model/Currency/DefaultLocator.php b/app/code/Magento/Directory/Model/Currency/DefaultLocator.php index 74960b21ec173110eee302fedd3959823309edec..bb8f6fccbc27751e298f0c56f1f43f2feea45d9d 100644 --- a/app/code/Magento/Directory/Model/Currency/DefaultLocator.php +++ b/app/code/Magento/Directory/Model/Currency/DefaultLocator.php @@ -35,17 +35,17 @@ class DefaultLocator /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $configuration - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $configuration, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_configuration = $configuration; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Directory/Model/Currency/Filter.php b/app/code/Magento/Directory/Model/Currency/Filter.php index be2a436864889fefcc697862ce13c27fe062e279..6e5700f289b1624be6806f4e23843b923c24e4f1 100644 --- a/app/code/Magento/Directory/Model/Currency/Filter.php +++ b/app/code/Magento/Directory/Model/Currency/Filter.php @@ -49,7 +49,7 @@ class Filter implements \Zend_Filter_Interface protected $_localeFormat; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,14 +60,14 @@ class Filter implements \Zend_Filter_Interface /** * @param \Magento\Framework\Locale\FormatInterface $localeFormat - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency * @param string $code * @param int $rate */ public function __construct( \Magento\Framework\Locale\FormatInterface $localeFormat, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, $code, $rate = 1 diff --git a/app/code/Magento/Directory/Model/Observer.php b/app/code/Magento/Directory/Model/Observer.php index fd4ba63b2c2c99b6f045c2d0679f63bc3cfcb384..b441a8781eff0a429fa25ebaa8a6b47de2176883 100644 --- a/app/code/Magento/Directory/Model/Observer.php +++ b/app/code/Magento/Directory/Model/Observer.php @@ -61,7 +61,7 @@ class Observer protected $_transportBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -79,7 +79,7 @@ class Observer * @param \Magento\Directory\Model\Currency\Import\Factory $importFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation */ @@ -87,7 +87,7 @@ class Observer \Magento\Directory\Model\Currency\Import\Factory $importFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation ) { diff --git a/app/code/Magento/Directory/Model/PriceCurrency.php b/app/code/Magento/Directory/Model/PriceCurrency.php index 99d76248942eb4f05f401c27ea89aec863363bbd..e89210b81bef7f4a3acc7d2a42a11e98745a1166 100644 --- a/app/code/Magento/Directory/Model/PriceCurrency.php +++ b/app/code/Magento/Directory/Model/PriceCurrency.php @@ -23,7 +23,7 @@ */ namespace Magento\Directory\Model; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Logger; /** @@ -32,7 +32,7 @@ use Magento\Framework\Logger; class PriceCurrency implements \Magento\Framework\Pricing\PriceCurrencyInterface { /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index e68271a1929dba17f71338516ef9dbf7b1c9a95a..3a7c4476593230224d8fd294f51981878d71bf15 100644 --- a/app/code/Magento/Directory/composer.json +++ b/app/code/Magento/Directory/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php index 6a48e2440c8e35f98608000d440e2a86820a808c..7000fddc04483f52178b07001a0eaf2ae5bd8fcc 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php @@ -294,7 +294,7 @@ class Links extends \Magento\Backend\Block\Template if ($fileExist) { $name = '<a href="' . $this->getUrl( 'adminhtml/downloadable_product_edit/link', - array('id' => $item->getId(), '_secure' => true) + array('id' => $item->getId(), 'type' => 'link', '_secure' => true) ) . '">' . $fileHelper->getFileFromPathFile( $linkFile ) . '</a>'; @@ -316,10 +316,16 @@ class Links extends \Magento\Backend\Block\Template $fileExist = $fileHelper->ensureFileInFilesystem($file); if ($fileExist) { + $name = '<a href="' . $this->getUrl( + 'adminhtml/downloadable_product_edit/link', + array('id' => $item->getId(), 'type' => 'sample', '_secure' => true) + ) . '">' . $fileHelper->getFileFromPathFile( + $sampleFile + ) . '</a>'; $tmpLinkItem['sample_file_save'] = array( array( 'file' => $item->getSampleFile(), - 'name' => $fileHelper->getFileFromPathFile($sampleFile), + 'name' => $name, 'size' => $fileHelper->getFileSize($file), 'status' => 'old' ) diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php index 8fe24c383f0c25bb503ab7c8468926eeed81adc2..65c2eaf73130343fcab4bd7f917ae3f0ce287191 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php @@ -177,10 +177,16 @@ class Samples extends \Magento\Backend\Block\Widget $fileExist = $fileHelper->ensureFileInFilesystem($file); if ($fileExist) { + $name = '<a href="' . $this->getUrl( + 'adminhtml/downloadable_product_edit/sample', + array('id' => $item->getId(), '_secure' => true) + ) . '">' . $fileHelper->getFileFromPathFile( + $sampleFile + ) . '</a>'; $tmpSampleItem['file_save'] = array( array( 'file' => $sampleFile, - 'name' => $fileHelper->getFileFromPathFile($sampleFile), + 'name' => $name, 'size' => $fileHelper->getFileSize($file), 'status' => 'old' ) diff --git a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Link.php b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Link.php index 468b2245c2f329060c3abd2d25a2ddcf316dcfbe..bf17bfc37deadc31cba20ca7f798eb61fd08d673 100644 --- a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Link.php +++ b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Link.php @@ -98,22 +98,38 @@ class Link extends \Magento\Catalog\Controller\Adminhtml\Product\Edit public function execute() { $linkId = $this->getRequest()->getParam('id', 0); + $type = $this->getRequest()->getParam('type', 0); /** @var \Magento\Downloadable\Model\Link $link */ $link = $this->_createLink()->load($linkId); if ($link->getId()) { $resource = ''; $resourceType = ''; - if ($link->getLinkType() == DownloadHelper::LINK_TYPE_URL) { - $resource = $link->getLinkUrl(); - $resourceType = DownloadHelper::LINK_TYPE_URL; - } elseif ($link->getLinkType() == DownloadHelper::LINK_TYPE_FILE) { - $resource = $this->_objectManager->get( - 'Magento\Downloadable\Helper\File' - )->getFilePath( - $this->_getLink()->getBasePath(), - $link->getLinkFile() - ); - $resourceType = DownloadHelper::LINK_TYPE_FILE; + if ($type == 'link') { + if ($link->getLinkType() == DownloadHelper::LINK_TYPE_URL) { + $resource = $link->getLinkUrl(); + $resourceType = DownloadHelper::LINK_TYPE_URL; + } elseif ($link->getLinkType() == DownloadHelper::LINK_TYPE_FILE) { + $resource = $this->_objectManager->get( + 'Magento\Downloadable\Helper\File' + )->getFilePath( + $this->_getLink()->getBasePath(), + $link->getLinkFile() + ); + $resourceType = DownloadHelper::LINK_TYPE_FILE; + } + } else { + if ($link->getSampleType() == DownloadHelper::LINK_TYPE_URL) { + $resource = $link->getSampleUrl(); + $resourceType = DownloadHelper::LINK_TYPE_URL; + } elseif ($link->getSampleType() == DownloadHelper::LINK_TYPE_FILE) { + $resource = $this->_objectManager->get( + 'Magento\Downloadable\Helper\File' + )->getFilePath( + $this->_getLink()->getBaseSamplePath(), + $link->getSampleFile() + ); + $resourceType = DownloadHelper::LINK_TYPE_FILE; + } } try { $this->_processDownload($resource, $resourceType); @@ -121,6 +137,5 @@ class Link extends \Magento\Catalog\Controller\Adminhtml\Product\Edit $this->messageManager->addError(__('Something went wrong while getting the requested content.')); } } - exit(0); } } diff --git a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Sample.php b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Sample.php new file mode 100644 index 0000000000000000000000000000000000000000..7e92e41eac9915ccda3602a2d7b982a5e4c89551 --- /dev/null +++ b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Sample.php @@ -0,0 +1,79 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit; + +use Magento\Downloadable\Helper\Download as DownloadHelper; + +class Sample extends \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link +{ + /** + * @return \Magento\Downloadable\Model\Sample + */ + protected function _createLink() + { + return $this->_objectManager->create('Magento\Downloadable\Model\Sample'); + } + + /** + * @return \Magento\Downloadable\Model\Sample + */ + protected function _getLink() + { + return $this->_objectManager->get('Magento\Downloadable\Model\Sample'); + } + + /** + * Download sample action + * + * @return void + */ + public function execute() + { + $sampleId = $this->getRequest()->getParam('id', 0); + /** @var \Magento\Downloadable\Model\Sample $sample */ + $sample = $this->_createLink()->load($sampleId); + if ($sample->getId()) { + $resource = ''; + $resourceType = ''; + if ($sample->getSampleType() == DownloadHelper::LINK_TYPE_URL) { + $resource = $sample->getSampleUrl(); + $resourceType = DownloadHelper::LINK_TYPE_URL; + } elseif ($sample->getSampleType() == DownloadHelper::LINK_TYPE_FILE) { + $resource = $this->_objectManager->get( + 'Magento\Downloadable\Helper\File' + )->getFilePath( + $this->_getLink()->getBasePath(), + $sample->getSampleFile() + ); + $resourceType = DownloadHelper::LINK_TYPE_FILE; + } + try { + $this->_processDownload($resource, $resourceType); + } catch (\Magento\Framework\Model\Exception $e) { + $this->messageManager->addError(__('Something went wrong while getting the requested content.')); + } + } + } +} diff --git a/app/code/Magento/Downloadable/Model/Resource/Link.php b/app/code/Magento/Downloadable/Model/Resource/Link.php index 01e173b9e0e30117af863f5ae8684656cd3f5c1d..5c602b50b9db9da8fb5338c23ad2b8ba446b2a18 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Link.php +++ b/app/code/Magento/Downloadable/Model/Resource/Link.php @@ -48,7 +48,7 @@ class Link extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_currencyFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -57,14 +57,14 @@ class Link extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $configuration * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $configuration, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_catalogData = $catalogData; $this->_configuration = $configuration; diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index 3d75efdf54ec20d080aa8e1b50aa1c165b84cab9..b57f50f4d99af2a29532cbc8ffd7958a4c0c79d2 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php index b2c0303adea9b3e1f4f7ae8a22ddc75d92e73d0c..def7f690b711364146430324e96cb529b766f74e 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute.php @@ -84,7 +84,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -100,7 +100,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im \Magento\Core\Helper\Data $coreData, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php index c289d5d71e25340cf001c527dab0e27383231df0..3df4e1509cacd56e1434051601b2859615d5a1b6 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php @@ -97,7 +97,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractModel protected $_eavTypeFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -117,7 +117,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractModel * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -130,7 +130,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractModel \Magento\Core\Helper\Data $coreData, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php index e9fad9f11e2b0ef4f1cbb1fb7d1d6f04892e7ff4..a51cf76e66b09b12e343e6851e2d329d1d80c9e1 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php @@ -26,15 +26,15 @@ namespace Magento\Eav\Model\Entity\Attribute\Backend; class Store extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Logger $logger - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; parent::__construct($logger); diff --git a/app/code/Magento/Eav/Model/Form.php b/app/code/Magento/Eav/Model/Form.php index 123fbc855bae457707c5df926bc0037f54ab5afd..ba7f8593681a9620dac79e3772e9775c0b93c6f2 100644 --- a/app/code/Magento/Eav/Model/Form.php +++ b/app/code/Magento/Eav/Model/Form.php @@ -122,7 +122,7 @@ abstract class Form protected $_validator = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -157,7 +157,7 @@ abstract class Form protected $_validatorConfigFactory; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Module\Dir\Reader $modulesReader * @param \Magento\Eav\Model\AttributeDataFactory $attrDataFactory @@ -168,7 +168,7 @@ abstract class Form * @throws \Magento\Framework\Model\Exception */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Module\Dir\Reader $modulesReader, \Magento\Eav\Model\AttributeDataFactory $attrDataFactory, diff --git a/app/code/Magento/Eav/Model/Form/Fieldset.php b/app/code/Magento/Eav/Model/Form/Fieldset.php index 137cc88a0ace1eede57152e7a0fa1c79ec7bb580..415c2b173da5665e1e28942a57b6181ffcf80768 100644 --- a/app/code/Magento/Eav/Model/Form/Fieldset.php +++ b/app/code/Magento/Eav/Model/Form/Fieldset.php @@ -46,14 +46,14 @@ class Fieldset extends \Magento\Framework\Model\AbstractModel protected $_eventPrefix = 'eav_form_fieldset'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -61,7 +61,7 @@ class Fieldset extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php index c924148a9e1df9ea0dd477d38b48b1de4b23701c..c9f5205c1cad75e6126d353582c2557f9fc8d7a2 100644 --- a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php @@ -57,7 +57,7 @@ abstract class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\C protected $_eavConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -67,7 +67,7 @@ abstract class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\C * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -77,7 +77,7 @@ abstract class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\C \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php index db3dde8c4ef17cb77fb165ee9e649852a42957e0..e7d4999e4358754481ae131516c3cbdedfefd6cc 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php @@ -43,7 +43,7 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb protected static $_entityAttributes = array(); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,12 +56,12 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb * Class constructor * * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Type $eavEntityType */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, Type $eavEntityType ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php index b8b92b7edc8e52397990ad549df67d2cf6f73fc4..515e2ea7fc509aad284b8a13fe33cd2ade7f86ad 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php @@ -43,7 +43,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac protected $_coreResource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -53,7 +53,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\App\Resource $coreResource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -63,7 +63,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Resource $coreResource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php index 1f9ef354d78acff7f820170ae82062a9495f1817..c0d193e404826c83f6baba42c29e7aebed4c0676 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php @@ -59,7 +59,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac protected $_entityType; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -74,7 +74,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -84,7 +84,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php index 303d6cb1c6e35b5f733dbc3d4d8add4f98c7ba9d..c736e52a7ca76224f7f5d887f6afecd285e9ff4e 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php @@ -36,7 +36,7 @@ use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; use Magento\Framework\Model\Resource\Db\AbstractDb; use Magento\Framework\Logger; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection { @@ -57,7 +57,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param Logger $logger * @param FetchStrategyInterface $fetchStrategy * @param ManagerInterface $eventManager - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param AbstractDb $resource */ diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index 11532e364891c1f9a5c128233fe82aaa216e1d5a..7937cc3ea93daee1819978cc55ea57c2969106fa 100644 --- a/app/code/Magento/Eav/composer.json +++ b/app/code/Magento/Eav/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php index 4d3556ad19636527a6eec237220a5b7ef86c5674..f216daea28818a9f7b630a95e763172b8fbf6362 100644 --- a/app/code/Magento/Email/Model/AbstractTemplate.php +++ b/app/code/Magento/Email/Model/AbstractTemplate.php @@ -87,7 +87,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn protected $_appEmulation; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -96,7 +96,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -104,7 +104,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Core\Model\App\Emulation $appEmulation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { $this->_design = $design; diff --git a/app/code/Magento/Email/Model/BackendTemplate.php b/app/code/Magento/Email/Model/BackendTemplate.php index e55cfd3270d9b8752a45b4408e50ba2424242faf..d146153758219149497d70d5736363c327a18a4c 100644 --- a/app/code/Magento/Email/Model/BackendTemplate.php +++ b/app/code/Magento/Email/Model/BackendTemplate.php @@ -40,7 +40,7 @@ class BackendTemplate extends Template * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\View\FileSystem $viewFileSystem @@ -57,7 +57,7 @@ class BackendTemplate extends Template \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Core\Model\App\Emulation $appEmulation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\View\FileSystem $viewFileSystem, diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index 2557b3263ee05e37a4290ca5e6d9f00dd37c635c..41cce270d9a431214aa52e1baf62195a1454d4b3 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -25,7 +25,7 @@ namespace Magento\Email\Model; use Magento\Email\Model\Template\Filter; use Magento\Framework\Filter\Template as FilterTemplate; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Template model @@ -175,7 +175,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\View\FileSystem $viewFileSystem diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php index 4bbe60dbf22cbf9aaf92cb967c01167e94ed8699..b58333b2b3ee576c9f895e848e78dc57b229124a 100644 --- a/app/code/Magento/Email/Model/Template/Filter.php +++ b/app/code/Magento/Email/Model/Template/Filter.php @@ -88,7 +88,7 @@ class Filter extends \Magento\Framework\Filter\Template protected $_variableFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -135,7 +135,7 @@ class Filter extends \Magento\Framework\Filter\Template * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Core\Model\VariableFactory $coreVariableFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\View\LayoutFactory $layoutFactory * @param \Magento\Framework\App\State $appState @@ -151,7 +151,7 @@ class Filter extends \Magento\Framework\Filter\Template \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Core\Model\VariableFactory $coreVariableFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Framework\App\State $appState, diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index b34bb25f2bf1bc66c4b59c12ec31e18032d17c4e..f9d14e6c5a9c9250cf7a52cfd116df187fb29895 100644 --- a/app/code/Magento/Email/composer.json +++ b/app/code/Magento/Email/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 1daa81c68b19218e9b315c93d665d79d46a17ebc..0357d50e863ef77f331e64f7a60e7cb1d00c612e 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -121,7 +121,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C protected $_customizableContainerTypes = array('YOUR_PACKAGING'); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -151,7 +151,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C * @param \Magento\Directory\Helper\Data $directoryData * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService * @param \Magento\Framework\Logger $logger - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Module\Dir\Reader $configReader * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory * @param array $data @@ -174,7 +174,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C \Magento\Directory\Helper\Data $directoryData, \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, \Magento\Framework\Logger $logger, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Module\Dir\Reader $configReader, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, array $data = array() diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 90065ec7d1116e820712a774c936898b4d3040da..852b8cd0614c30968d4045bc792f03eeca412185 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GiftMessage/Helper/Message.php b/app/code/Magento/GiftMessage/Helper/Message.php index 89f72ee85a9148e19a76703b23ebc69c6d2429c2..31b0bb2ec4dc80fb64ecca786e6023b8c748b89c 100644 --- a/app/code/Magento/GiftMessage/Helper/Message.php +++ b/app/code/Magento/GiftMessage/Helper/Message.php @@ -80,7 +80,7 @@ class Message extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -93,7 +93,7 @@ class Message extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Catalog\Model\ProductFactory $productFactory, diff --git a/app/code/Magento/GiftMessage/Service/V1/WriteService.php b/app/code/Magento/GiftMessage/Service/V1/WriteService.php index e2831e8315abf2b68ac6e49ad5bfe2e7e600ac45..b603464d644e402d59a2578ec958025486c9b67e 100644 --- a/app/code/Magento/GiftMessage/Service/V1/WriteService.php +++ b/app/code/Magento/GiftMessage/Service/V1/WriteService.php @@ -37,7 +37,7 @@ class WriteService implements WriteServiceInterface protected $quoteRepository; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -58,14 +58,14 @@ class WriteService implements WriteServiceInterface /** * @param \Magento\Sales\Model\QuoteRepository $quoteRepository - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager * @param \Magento\GiftMessage\Helper\Message $helper * @param \Magento\Catalog\Service\V1\Product\ProductLoader $productLoader */ public function __construct( \Magento\Sales\Model\QuoteRepository $quoteRepository, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager, \Magento\GiftMessage\Helper\Message $helper, \Magento\Catalog\Service\V1\Product\ProductLoader $productLoader diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index 56ad6d817653c9dea89a2a409129df6a632262b4..70536951d15edd84c4362d056664a5b78917a72f 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-multishipping": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-multishipping": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index a8be39827c9f0174e6b7ccc6578ae55ac9d08a8e..71158c07b85744753194f1bc4a0f7066f7294cde 100644 --- a/app/code/Magento/GoogleAdwords/composer.json +++ b/app/code/Magento/GoogleAdwords/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/Model/Observer.php b/app/code/Magento/GoogleAnalytics/Model/Observer.php index 5aebc6cd31f0c4e554fc6c9f38e5af08d08619c8..4edcce47f5833abbce1df4e954e7f7f2a2871438 100644 --- a/app/code/Magento/GoogleAnalytics/Model/Observer.php +++ b/app/code/Magento/GoogleAnalytics/Model/Observer.php @@ -44,17 +44,17 @@ class Observer protected $_layout; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\GoogleAnalytics\Helper\Data $googleAnalyticsData */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\GoogleAnalytics\Helper\Data $googleAnalyticsData ) { diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 42da737f20b5aaecaa94d075e0768cbedf208ad1..1d7cdd63d97dcaeb126f2e619efe3ad6cc0f040d 100644 --- a/app/code/Magento/GoogleAnalytics/composer.json +++ b/app/code/Magento/GoogleAnalytics/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index 45eb649b57aea8841663ceee7599b925046403ca..56f957632a58b5b950a2eb7124e343a74797c98f 100644 --- a/app/code/Magento/GoogleOptimizer/composer.json +++ b/app/code/Magento/GoogleOptimizer/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-google-analytics": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-google-analytics": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php index 74e74bb29299df39c0b53bab5958abf03070672f..85f0bae83abcd70f5e24f553720e073485a96884 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php @@ -97,7 +97,7 @@ class Items extends \Magento\Backend\App\Action public function _getStore() { $store = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( (int)$this->getRequest()->getParam('store', 0) ); diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php index fa10e9f73a6faaae914b69f1c74ae6be2bb540e6..a59a4adf6c1c6c25b746267a3fe665978d74418b 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php @@ -60,7 +60,7 @@ class Index extends \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\ 'adminhtml/*/', array( 'store' => $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), '_current' => true ) diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php index f4d3e8a2cee1013aaf66ce4fc57479c0dd753086..068c00b7e6143d9d103452c3e56288c7335ae78c 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php @@ -114,9 +114,9 @@ class Types extends \Magento\Backend\App\Action { $storeId = (int)$this->getRequest()->getParam('store', 0); if ($storeId == 0) { - return $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getDefaultStoreView(); + return $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getDefaultStoreView(); } - return $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore($storeId); + return $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore($storeId); } /** diff --git a/app/code/Magento/GoogleShopping/Helper/Data.php b/app/code/Magento/GoogleShopping/Helper/Data.php index 087094958009c1bd9480e9741d7a2c19fd98fe68..50fc41175da4198187569c3952e2d88aaf921fd0 100644 --- a/app/code/Magento/GoogleShopping/Helper/Data.php +++ b/app/code/Magento/GoogleShopping/Helper/Data.php @@ -40,19 +40,19 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\Stdlib\String $string - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\Stdlib\String $string, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->string = $string; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php index 81a8cbcc4174a9372ac3af761e90f93a8a67e1df..30253a5836f98423e2a369824d4ee34b9718713c 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php @@ -56,7 +56,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -78,7 +78,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute * @param \Magento\GoogleShopping\Helper\Product $gsProduct * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\GoogleShopping\Model\Config $config * @param \Magento\Customer\Service\V1\CustomerGroupService $customerGroupService @@ -96,7 +96,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute \Magento\GoogleShopping\Helper\Product $gsProduct, \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Tax\Helper\Data $taxData, \Magento\GoogleShopping\Model\Config $config, \Magento\Customer\Service\V1\CustomerGroupService $customerGroupService, diff --git a/app/code/Magento/GoogleShopping/Model/Config.php b/app/code/Magento/GoogleShopping/Model/Config.php index 607debd2b43db09c114e0d493076cc5fe80e54a7..252b032e68175934d1356ea62f2353e02afd2c41 100644 --- a/app/code/Magento/GoogleShopping/Model/Config.php +++ b/app/code/Magento/GoogleShopping/Model/Config.php @@ -47,7 +47,7 @@ class Config extends \Magento\Framework\Object /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -58,13 +58,13 @@ class Config extends \Magento\Framework\Object /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param array $data */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Encryption\EncryptorInterface $encryptor, array $data = array() ) { @@ -120,7 +120,7 @@ class Config extends \Magento\Framework\Object */ public function getAccountPassword($storeId = null) { - return $this->_encryptor->decrypt($this->getConfigData('password', $storeId)); + return $this->getConfigData('password', $storeId); } /** diff --git a/app/code/Magento/GoogleShopping/Model/MassOperations.php b/app/code/Magento/GoogleShopping/Model/MassOperations.php index 180aa443eeec639e5638e2fde1c0451a61c2d729..498849c9ec92ed834cb0b6b91ba379450e6a7932 100644 --- a/app/code/Magento/GoogleShopping/Model/MassOperations.php +++ b/app/code/Magento/GoogleShopping/Model/MassOperations.php @@ -50,7 +50,7 @@ class MassOperations /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -87,7 +87,7 @@ class MassOperations * @param \Magento\GoogleShopping\Model\ItemFactory $itemFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Framework\Notification\NotifierInterface $notifier - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Logger $logger * @param \Magento\GoogleShopping\Helper\Data $gleShoppingData * @param \Magento\GoogleShopping\Helper\Category $gleShoppingCategory @@ -98,7 +98,7 @@ class MassOperations \Magento\GoogleShopping\Model\ItemFactory $itemFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Framework\Notification\NotifierInterface $notifier, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Logger $logger, \Magento\GoogleShopping\Helper\Data $gleShoppingData, \Magento\GoogleShopping\Helper\Category $gleShoppingCategory, diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 8b3c590709a311135a4f2388117aa6b9fddac369..12d9330d1294aaee04dc0c1a95e5300797fb4211 100644 --- a/app/code/Magento/GoogleShopping/composer.json +++ b/app/code/Magento/GoogleShopping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/etc/config.xml b/app/code/Magento/GoogleShopping/etc/config.xml index 7c040bdfcdb324725c4fef602b7936a1e91d21fc..0b461d386bf045f103ccf8f8ad83b8682ac5f265 100644 --- a/app/code/Magento/GoogleShopping/etc/config.xml +++ b/app/code/Magento/GoogleShopping/etc/config.xml @@ -300,6 +300,7 @@ <google_product_category /> <product_type /> </base_attributes> + <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> </googleshopping> </google> </default> diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json index 5d10224499c3d7ddc5d733cda3c663f81ced87ec..766e679ced63d54f682e92fc46175fc7476be472 100644 --- a/app/code/Magento/GroupedImportExport/composer.json +++ b/app/code/Magento/GroupedImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-import-export": "0.1.0-alpha94", - "magento/module-catalog-import-export": "0.1.0-alpha94", - "magento/module-grouped-product": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-import-export": "0.1.0-alpha95", + "magento/module-catalog-import-export": "0.1.0-alpha95", + "magento/module-grouped-product": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php b/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php index d6df970824f23faf4c9e96447422a3977e97210e..71a160d088f41dd00e00a24339c79673dcc2aa4b 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php +++ b/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php @@ -29,7 +29,7 @@ namespace Magento\GroupedProduct\Model\Product; class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -39,11 +39,11 @@ class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterfa protected $commonPriceModel; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel ) { $this->storeManager = $storeManager; diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php index 154086e87ced19c3026d01aa6226446096cf6f0b..9308008bb7ad0966fa17e416956b04b491a1aa91 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php @@ -77,7 +77,7 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -105,7 +105,7 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\Logger $logger * @param \Magento\GroupedProduct\Model\Resource\Product\Link $catalogProductLink - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus * @param \Magento\Framework\App\State $appState * @param array $data @@ -124,7 +124,7 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType \Magento\Framework\Registry $coreRegistry, \Magento\Framework\Logger $logger, \Magento\GroupedProduct\Model\Resource\Product\Link $catalogProductLink, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus, \Magento\Framework\App\State $appState, array $data = array() diff --git a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php index 49d28eedeed30aee55cf3907551c00209d8784e3..dfd18080b65712d3d9c3ef02500c8db13ca5c4ff 100644 --- a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php +++ b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php @@ -54,7 +54,7 @@ class AssociatedProductsCollection extends \Magento\Catalog\Model\Resource\Produ * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -79,7 +79,7 @@ class AssociatedProductsCollection extends \Magento\Catalog\Model\Resource\Produ \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index 08d83fa0bc082d22e85f5d6d3533fe27a3947cf8..9058151754d08f843d0018a18c080b04f44d28e7 100644 --- a/app/code/Magento/GroupedProduct/composer.json +++ b/app/code/Magento/GroupedProduct/composer.json @@ -3,22 +3,22 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/ImportExport/Helper/Data.php b/app/code/Magento/ImportExport/Helper/Data.php index 2fab16f07a581a0fa4e50ad901b97f58219b32cb..b92bd27b0ccc6ab828ac4bc8535a5e3ba565291a 100644 --- a/app/code/Magento/ImportExport/Helper/Data.php +++ b/app/code/Magento/ImportExport/Helper/Data.php @@ -47,7 +47,7 @@ class Data extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\File\Size $fileSize @@ -56,7 +56,7 @@ class Data extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\File\Size $fileSize, diff --git a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php index b94f98e7c11425079224ac4feeb04bc98f9ca8eb..ddf58edca2944132289f850d2026d0b7e4861f22 100644 --- a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php @@ -49,7 +49,7 @@ abstract class AbstractEntity /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -174,14 +174,14 @@ abstract class AbstractEntity /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param array $data */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, array $data = array() diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php index b9589a417b818ab8925be4f654bf1e79bfc640d8..00ba286891452425d28e664ca265a89985d152f5 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php @@ -77,7 +77,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Export\AbstractEn /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -86,7 +86,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Export\AbstractEn */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php index 4763d417ac9ef31305a7733296662219f266c377..8efcb89c5adc0983f7bb8f1b6846f4005dd0766a 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php @@ -157,7 +157,7 @@ abstract class AbstractEntity protected $_localeDate; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -165,13 +165,13 @@ abstract class AbstractEntity * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $config * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $config, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_localeDate = $localeDate; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php index 35bbaf35742c8f0d47b4dfadd037efd771453308..919242d296281d9a19a00023a06f39860e00af52 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php @@ -36,7 +36,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Import\AbstractEn /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -96,7 +96,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Import\AbstractEn * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param array $data @@ -108,7 +108,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Import\AbstractEn \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, array $data = array() diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index 6e31d471500ea07f37c8a692b76c960c9410a190..f2211bd99785d102587b5a761841934d746b4906 100644 --- a/app/code/Magento/ImportExport/composer.json +++ b/app/code/Magento/ImportExport/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Index/App/Indexer.php b/app/code/Magento/Index/App/Indexer.php index 5a9bd968aa8632578ed0c758e00316c2ecbf8eb0..530a44aceb29663ee4ef83682a980eb5d8c35217 100644 --- a/app/code/Magento/Index/App/Indexer.php +++ b/app/code/Magento/Index/App/Indexer.php @@ -26,6 +26,7 @@ namespace Magento\Index\App; use Magento\Framework\App\Console\Response; +use Magento\Framework\App; use Magento\Framework\AppInterface; class Indexer implements AppInterface @@ -96,4 +97,12 @@ class Indexer implements AppInterface $this->_response->setCode(0); return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Index/App/Shell.php b/app/code/Magento/Index/App/Shell.php index e1489af69cdb7ed0fa3204025d0868cb97049465..0898d2529433ed596776a6b54dacc29e548003ab 100644 --- a/app/code/Magento/Index/App/Shell.php +++ b/app/code/Magento/Index/App/Shell.php @@ -26,6 +26,7 @@ namespace Magento\Index\App; use Magento\Framework\App\Console\Response; +use Magento\Framework\App\Bootstrap; use Magento\Framework\AppInterface; class Shell implements AppInterface @@ -76,4 +77,12 @@ class Shell implements AppInterface } return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Index/composer.json b/app/code/Magento/Index/composer.json index 7e8a5dbe6d0a35a7976ce58081d9f5548e27829d..7eedb06bfd4b46d96773e981120551d40b0915f3 100644 --- a/app/code/Magento/Index/composer.json +++ b/app/code/Magento/Index/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Indexer/App/Indexer.php b/app/code/Magento/Indexer/App/Indexer.php index b09b2c129847a3a084e148a1c185ca8ce73e4354..44fb9a96e731ba2588a4c283d691a31d17e47fe5 100644 --- a/app/code/Magento/Indexer/App/Indexer.php +++ b/app/code/Magento/Indexer/App/Indexer.php @@ -23,6 +23,8 @@ */ namespace Magento\Indexer\App; +use Magento\Framework\App; + class Indexer implements \Magento\Framework\AppInterface { /** @@ -76,4 +78,12 @@ class Indexer implements \Magento\Framework\AppInterface return 0; } + + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Indexer/App/Shell.php b/app/code/Magento/Indexer/App/Shell.php index b6ecaa5ecdaa2c00f47875fb5ed06cb9897dde0a..293668d7b3a43197c213723685605f1dde30c7fa 100644 --- a/app/code/Magento/Indexer/App/Shell.php +++ b/app/code/Magento/Indexer/App/Shell.php @@ -23,6 +23,8 @@ */ namespace Magento\Indexer\App; +use Magento\Framework\App\Bootstrap; + class Shell implements \Magento\Framework\AppInterface { /** @@ -74,4 +76,12 @@ class Shell implements \Magento\Framework\AppInterface } return $this->response; } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index bfd847402f0f3b7f70ef9e6e2969e4aca09746bf..866f2f5b127ed8991d4ce63474a3cfba46798723 100644 --- a/app/code/Magento/Indexer/composer.json +++ b/app/code/Magento/Indexer/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Install/App/Action/Plugin/Design.php b/app/code/Magento/Install/App/Action/Plugin/Design.php deleted file mode 100644 index d1b05d3e988d91ab5f47b9fd65838088b01aec89..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/App/Action/Plugin/Design.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\App\Action\Plugin; - -use Magento\Framework\App\RequestInterface; - -class Design -{ - /** - * @var \Magento\Framework\App\RequestInterface - */ - protected $_request; - - /** - * @var \Magento\Framework\App\AreaList - */ - protected $_areaList; - - /** - * @var \Magento\Framework\App\State - */ - protected $appState; - - /** - * @var \Magento\Framework\View\Design\Theme\ListInterface - */ - protected $_themeList; - - /** - * @var \Magento\Framework\View\DesignInterface - */ - protected $_viewDesign; - - /** - * @param RequestInterface $request - * @param \Magento\Framework\App\AreaList $areaList - * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\View\DesignInterface $viewDesign - * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList - */ - public function __construct( - \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\App\AreaList $areaList, - \Magento\Framework\App\State $appState, - \Magento\Framework\View\DesignInterface $viewDesign, - \Magento\Framework\View\Design\Theme\ListInterface $themeList - ) { - $this->_viewDesign = $viewDesign; - $this->_themeList = $themeList; - $this->_request = $request; - $this->_areaList = $areaList; - $this->appState = $appState; - } - - /** - * Initialize design - * - * @param \Magento\Framework\App\ActionInterface $subject - * @param RequestInterface $request - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request) - { - $areaCode = $this->appState->getAreaCode(); - $area = $this->_areaList->getArea($areaCode); - $area->load(\Magento\Framework\App\Area::PART_CONFIG); - - $themePath = $this->_viewDesign->getConfigurationDesignTheme($areaCode); - $themeFullPath = $areaCode . \Magento\Framework\View\Design\ThemeInterface::PATH_SEPARATOR . $themePath; - $themeModel = $this->_themeList->getThemeByFullPath($themeFullPath); - $this->_viewDesign->setDesignTheme($themeModel); - - $area->detectDesign($this->_request); - $area->load(\Magento\Framework\App\Area::PART_TRANSLATE); - } -} diff --git a/app/code/Magento/Install/App/Action/Plugin/Dir.php b/app/code/Magento/Install/App/Action/Plugin/Dir.php deleted file mode 100644 index 83409bce18c87ff16061a4053b593166444d3a90..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/App/Action/Plugin/Dir.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\App\Action\Plugin; - -use Magento\Framework\App\Filesystem; -use Magento\Framework\Filesystem\FilesystemException; -use Magento\Framework\Filesystem\Directory\Write; -use Magento\Framework\App\State; -use Magento\Framework\Logger; - -class Dir -{ - /** - * Application state - * - * @var State - */ - protected $appState; - - /** - * Directory list - * - * @var Write - */ - protected $varDirectory; - - /** - * Logger - * - * @var Logger - */ - protected $logger; - - /** - * @param State $state - * @param Filesystem $filesystem - * @param Logger $logger - */ - public function __construct(State $state, Filesystem $filesystem, Logger $logger) - { - $this->appState = $state; - $this->varDirectory = $filesystem->getDirectoryWrite(Filesystem::VAR_DIR); - $this->logger = $logger; - } - - /** - * Clear temporary directories - * - * @param \Magento\Install\Controller\Index\Index $subject - * @param \Magento\Framework\App\RequestInterface $request - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function beforeDispatch( - \Magento\Install\Controller\Index\Index $subject, - \Magento\Framework\App\RequestInterface $request - ) { - if (!$this->appState->isInstalled()) { - foreach ($this->varDirectory->read() as $dir) { - if ($this->varDirectory->isDirectory($dir)) { - try { - $this->varDirectory->delete($dir); - } catch (FilesystemException $exception) { - $this->logger->log($exception->getMessage()); - } - } - } - } - } -} diff --git a/app/code/Magento/Install/App/Action/Plugin/Install.php b/app/code/Magento/Install/App/Action/Plugin/Install.php deleted file mode 100644 index 3fc8581891bc94ca94c165d03867bdab563a904c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/App/Action/Plugin/Install.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\App\Action\Plugin; - -class Install -{ - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @var \Magento\Framework\App\ResponseInterface - */ - protected $_response; - - /** - * @var \Magento\Framework\UrlInterface - */ - protected $_url; - - /** - * @var \Magento\Framework\App\ActionFlag - */ - protected $_actionFlag; - - /** - * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\App\ResponseInterface $response - * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Framework\App\ActionFlag $actionFlag - */ - public function __construct( - \Magento\Framework\App\State $appState, - \Magento\Framework\App\ResponseInterface $response, - \Magento\Framework\UrlInterface $url, - \Magento\Framework\App\ActionFlag $actionFlag - ) { - $this->_appState = $appState; - $this->_response = $response; - $this->_url = $url; - $this->_actionFlag = $actionFlag; - } - - /** - * Dispatch request - * - * @param \Magento\Framework\App\Action\Action $subject - * @param callable $proceed - * @param \Magento\Framework\App\RequestInterface $request - * @return \Magento\Framework\App\ResponseInterface - */ - public function aroundDispatch( - \Magento\Framework\App\Action\Action $subject, - \Closure $proceed, - \Magento\Framework\App\RequestInterface $request - ) { - if (!$this->_appState->isInstalled()) { - $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true); - $this->_response->setRedirect($this->_url->getUrl('install')); - return $this->_response; - } - return $proceed($request); - } -} diff --git a/app/code/Magento/Install/App/Console.php b/app/code/Magento/Install/App/Console.php index 9c9158fff8132fab9e0a78c8121e303f09ebf97e..37ecc5abf2004101796c1cec80faed1da68e38fa 100644 --- a/app/code/Magento/Install/App/Console.php +++ b/app/code/Magento/Install/App/Console.php @@ -26,6 +26,7 @@ namespace Magento\Install\App; use Magento\Framework\App\Console\Response; +use Magento\Framework\App\Bootstrap; class Console implements \Magento\Framework\AppInterface { @@ -89,38 +90,14 @@ class Console implements \Magento\Framework\AppInterface $this->_loader = $loader; $this->_state = $state; $this->_installerFactory = $installerFactory; - $this->_arguments = $this->_buildInitArguments($arguments); + $this->_arguments = $arguments; $this->_output = $output; $this->_response = $response; $this->_objectManager = $objectManager; } /** - * Customize application init arguments - * - * @param array $args - * @return array - */ - protected function _buildInitArguments(array $args) - { - $directories = array(); - if (!empty($args[\Magento\Install\Model\Installer\Console::OPTION_URIS])) { - $uris = unserialize(base64_decode($args[\Magento\Install\Model\Installer\Console::OPTION_URIS])); - foreach ($uris as $code => $uri) { - $args[\Magento\Framework\App\Filesystem::PARAM_APP_DIRS][$code]['uri'] = $uri; - } - } - if (!empty($args[\Magento\Install\Model\Installer\Console::OPTION_DIRS])) { - $dirs = unserialize(base64_decode($args[\Magento\Install\Model\Installer\Console::OPTION_DIRS])); - foreach ($dirs as $code => $dir) { - $args[\Magento\Framework\App\Filesystem::PARAM_APP_DIRS][$code]['path'] = $dir; - } - } - return $args; - } - - /** - * Install/Uninstall application + * Install application * * @param \Magento\Install\Model\Installer\Console $installer * @return void @@ -136,18 +113,11 @@ class Console implements \Magento\Framework\AppInterface $config = (array)include $this->_arguments['config']; $this->_arguments = array_merge((array)$config, $this->_arguments); } - $isUninstallMode = isset($this->_arguments['uninstall']); - if ($isUninstallMode) { - $result = $installer->uninstall(); - } else { - $result = $installer->install($this->_arguments); - } + + $result = $installer->install($this->_arguments); + if (!$installer->hasErrors()) { - if ($isUninstallMode) { - $msg = $result ? 'Uninstalled successfully' : 'Ignoring attempt to uninstall non-installed application'; - } else { - $msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : ''); - } + $msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : ''); $this->_output->success($msg . PHP_EOL); } else { $this->_output->error(implode(PHP_EOL, $installer->getErrors()) . PHP_EOL); @@ -164,15 +134,9 @@ class Console implements \Magento\Framework\AppInterface $areaCode = 'install'; $this->_state->setAreaCode($areaCode); $this->_objectManager->configure($this->_loader->load($areaCode)); - if (isset($this->_arguments['uninstall'])) { - $sessionConsole = $this->_objectManager->create('\Magento\Framework\Session\SessionConsole'); - $installerModel = $this->_objectManager - ->create('Magento\Install\Model\Installer', ['session' => $sessionConsole]); - $installer = $this->_installerFactory - ->create(['installArgs' => $this->_arguments, 'installer' => $installerModel]); - } else { - $installer = $this->_installerFactory->create(array('installArgs' => $this->_arguments)); - } + + /** @var \Magento\Install\Model\Installer\Console $installer */ + $installer = $this->_installerFactory->create(array('installArgs' => $this->_arguments)); if (isset($this->_arguments['show_locales'])) { $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableLocales())); @@ -197,4 +161,12 @@ class Console implements \Magento\Framework\AppInterface $this->_response->setCode(0); return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Install/Controller/Wizard.php b/app/code/Magento/Install/Controller/Wizard.php deleted file mode 100644 index 3957dd78c5d820c5526ac07d5b682d2c5477a2c2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Controller/Wizard.php +++ /dev/null @@ -1,167 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller; - -use Magento\Framework\App\RequestInterface; - -/** - * Installation wizard controller - */ -class Wizard extends \Magento\Framework\App\Action\Action -{ - /** - * Application state - * - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * Installer Model - * - * @var \Magento\Install\Model\Installer - */ - protected $_installer; - - /** - * Install Wizard - * - * @var \Magento\Install\Model\Wizard - */ - protected $_wizard; - - /** - * Install Session - * - * @var \Magento\Framework\Session\Generic - */ - protected $_session; - - /** - * DB Updater - * - * @var \Magento\Framework\Module\UpdaterInterface - */ - protected $_dbUpdater; - - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\Config\Scope $configScope - * @param \Magento\Install\Model\Installer $installer - * @param \Magento\Install\Model\Wizard $wizard - * @param \Magento\Framework\Session\Generic $session - * @param \Magento\Framework\Module\UpdaterInterface $dbUpdater - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\State $appState - */ - public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\Config\Scope $configScope, - \Magento\Install\Model\Installer $installer, - \Magento\Install\Model\Wizard $wizard, - \Magento\Framework\Session\Generic $session, - \Magento\Framework\Module\UpdaterInterface $dbUpdater, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\App\State $appState - ) { - $this->_storeManager = $storeManager; - parent::__construct($context); - $configScope->setCurrentScope('install'); - $this->_installer = $installer; - $this->_wizard = $wizard; - $this->_session = $session; - $this->_dbUpdater = $dbUpdater; - $this->_appState = $appState; - } - - /** - * Perform necessary checks for all actions - * - * Redirect out if system is already installed - * Throw a bootstrap exception if page cannot be displayed due to mis-configured base directories - * - * @param RequestInterface $request - * @return \Magento\Framework\App\ResponseInterface - */ - public function dispatch(RequestInterface $request) - { - if ($this->_appState->isInstalled()) { - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); - $this->_redirect('/'); - } - return parent::dispatch($request); - } - - /** - * Retrieve installer object - * - * @return \Magento\Install\Model\Installer - */ - protected function _getInstaller() - { - return $this->_installer; - } - - /** - * Retrieve wizard - * - * @return \Magento\Install\Model\Wizard - */ - protected function _getWizard() - { - return $this->_wizard; - } - - /** - * Prepare layout - * - * @return $this - */ - protected function _prepareLayout() - { - $this->_view->loadLayout('install_wizard'); - $step = $this->_getWizard()->getStepByRequest($this->getRequest()); - if ($step) { - $step->setActive(true); - } - - $this->_view->getLayout()->addBlock('Magento\Install\Block\State', 'install.state', 'left'); - return $this; - } - - /** - * Checking installation status - * - * @return bool - * @SuppressWarnings(PHPMD.ExitExpression) - */ - protected function _checkIfInstalled() - { - if ($this->_getInstaller()->isApplicationInstalled()) { - $this->getResponse()->setRedirect($this->_storeManager->getStore()->getBaseUrl())->sendResponse(); - exit; - } - return true; - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/AdministratorPost.php b/app/code/Magento/Install/Controller/Wizard/AdministratorPost.php deleted file mode 100644 index eb8054d751bbbf981e92c229e018a579ebe87bc3..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Controller/Wizard/AdministratorPost.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller\Wizard; - -class AdministratorPost extends \Magento\Install\Controller\Wizard -{ - /** - * Process administrator installation POST data - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - - $step = $this->_wizard->getStepByName('administrator'); - $adminData = $this->getRequest()->getPost('admin'); - $encryptionKey = $this->getRequest()->getPost('encryption_key'); - - try { - $encryptionKey = $this->_getInstaller()->getValidEncryptionKey($encryptionKey); - $this->_getInstaller()->createAdministrator($adminData); - $this->_getInstaller()->installEncryptionKey($encryptionKey); - $this->getResponse()->setRedirect($step->getNextUrl()); - } catch (\Exception $e) { - $this->_session->setAdminData($adminData); - if ($e instanceof \Magento\Framework\Model\Exception) { - $this->messageManager->addMessages($e->getMessages()); - } else { - $this->messageManager->addError($e->getMessage()); - } - $this->getResponse()->setRedirect($step->getUrl()); - } - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/Config.php b/app/code/Magento/Install/Controller/Wizard/Config.php deleted file mode 100644 index eed5fe1e447352b9a191d77bcdbd930b028e04b6..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Controller/Wizard/Config.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller\Wizard; - -class Config extends \Magento\Install\Controller\Wizard -{ - /** - * Configuration data installation - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - $this->_getInstaller()->checkServer(); - - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); - - $data = $this->getRequest()->getQuery('config'); - if ($data) { - $this->_session->setLocaleData($data); - } - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - $this->_view->getLayout()->addBlock('Magento\Install\Block\Config', 'install.config', 'content'); - - $this->_view->renderLayout(); - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/ConfigPost.php b/app/code/Magento/Install/Controller/Wizard/ConfigPost.php deleted file mode 100644 index 725f4c1ebb68dab11bb31fb8915b7b310b6f9809..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Controller/Wizard/ConfigPost.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller\Wizard; - -use \Magento\Framework\App\ResponseInterface; - -class ConfigPost extends \Magento\Install\Controller\Wizard -{ - /** - * Process configuration POST data - * - * @return ResponseInterface|void - */ - public function execute() - { - $this->_checkIfInstalled(); - $step = $this->_getWizard()->getStepByName('config'); - - $config = $this->getRequest()->getPost('config'); - $connectionConfig = $this->getRequest()->getPost('connection'); - - if ($config && $connectionConfig && isset($connectionConfig[$config['db_model']])) { - - $data = array_merge($config, $connectionConfig[$config['db_model']]); - - $this->_session->setConfigData( - $data - )->setSkipUrlValidation( - $this->getRequest()->getPost('skip_url_validation') - )->setSkipBaseUrlValidation( - $this->getRequest()->getPost('skip_base_url_validation') - ); - try { - $this->_getInstaller()->installConfig($data); - return $this->_redirect('*/*/installDb'); - } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); - $this->getResponse()->setRedirect($step->getUrl()); - } - } - $this->getResponse()->setRedirect($step->getUrl()); - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/DownloadPost.php b/app/code/Magento/Install/Controller/Wizard/DownloadPost.php deleted file mode 100644 index 794557e3a04e0ae10425dc5c04e4fb0043310368..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Controller/Wizard/DownloadPost.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller\Wizard; - -class DownloadPost extends \Magento\Install\Controller\Wizard -{ - /** - * Download post action - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - switch ($this->getRequest()->getPost('continue')) { - case 'auto': - $this->_forward('downloadAuto'); - break; - - case 'manual': - $this->_forward('downloadManual'); - break; - - case 'svn': - $step = $this->_getWizard()->getStepByName('download'); - $this->getResponse()->setRedirect($step->getNextUrl()); - break; - - default: - $this->_redirect('*/*/download'); - break; - } - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/Install.php b/app/code/Magento/Install/Controller/Wizard/Install.php deleted file mode 100644 index be896613ba68d6a1bf949f706994020fff250a75..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Controller/Wizard/Install.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller\Wizard; - -class Install extends \Magento\Install\Controller\Wizard -{ - /** - * Install success callback - * - * @return void - */ - public function installSuccessCallback() - { - echo 'parent.installSuccess()'; - } - - /** - * Install failure callback - * - * @return void - */ - public function installFailureCallback() - { - echo 'parent.installFailure()'; - } - - /** - * Install action - * - * @return void - * @SuppressWarnings(PHPMD.ExitExpression) - */ - public function execute() - { - $pear = \Magento\Framework\Pear::getInstance(); - $params = array('comment' => __("Downloading and installing Magento, please wait...") . "\r\n\r\n"); - if ($this->getRequest()->getParam('do')) { - $state = $this->getRequest()->getParam('state', 'beta'); - if ($state) { - $result = $pear->runHtmlConsole( - array( - 'comment' => __("Setting preferred state to: %1", $state) . "\r\n\r\n", - 'command' => 'config-set', - 'params' => array('preferred_state', $state) - ) - ); - if ($result instanceof PEAR_Error) { - $this->installFailureCallback(); - exit; - } - } - $params['command'] = 'install'; - $params['options'] = array('onlyreqdeps' => 1); - $params['params'] = $this->_objectManager->get('Magento\Install\Model\Installer\Pear')->getPackages(); - $params['success_callback'] = array($this, 'installSuccessCallback'); - $params['failure_callback'] = array($this, 'installFailureCallback'); - } - $pear->runHtmlConsole($params); - $this->getResponse()->clearAllHeaders(); - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/InstallDb.php b/app/code/Magento/Install/Controller/Wizard/InstallDb.php deleted file mode 100644 index 07a7f9fe1761f24f0958388245264b4c168e5e2e..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Controller/Wizard/InstallDb.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller\Wizard; - -class InstallDb extends \Magento\Install\Controller\Wizard -{ - /** - * Install DB - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - $step = $this->_getWizard()->getStepByName('config'); - try { - $this->_getInstaller()->installDb(); - /** - * Clear session config data - */ - $this->_session->getConfigData(true); - - $this->_storeManager->getStore()->resetConfig(); - $this->_dbUpdater->updateData(); - - $this->getResponse()->setRedirect($step->getNextUrl()); - } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); - $this->getResponse()->setRedirect($step->getUrl()); - } - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/Locale.php b/app/code/Magento/Install/Controller/Wizard/Locale.php deleted file mode 100644 index 6cd04ddec47bf294a5e529814a62a040e31b4887..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Controller/Wizard/Locale.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller\Wizard; - -class Locale extends \Magento\Install\Controller\Wizard -{ - /** - * Localization settings - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - $this->_view->getLayout()->addBlock('Magento\Install\Block\Locale', 'install.locale', 'content'); - $this->_view->getLayout()->getBlock('install.locale')->setLocaleCode($this->_session->getLocale()); - $this->_view->renderLayout(); - } -} diff --git a/app/code/Magento/Install/Model/Installer.php b/app/code/Magento/Install/Model/Installer.php index dbd71b9cffd35989faf4029efe4247e751d4ff98..5d5984ce81edbca779456990eb4a2eebd8cad3c4 100644 --- a/app/code/Magento/Install/Model/Installer.php +++ b/app/code/Magento/Install/Model/Installer.php @@ -38,7 +38,7 @@ class Installer extends \Magento\Framework\Object /** * DB updated model * - * @var \Magento\Framework\Module\UpdaterInterface + * @var \Magento\Framework\Module\Updater */ protected $_dbUpdater; @@ -102,7 +102,7 @@ class Installer extends \Magento\Framework\Object /** * Store Manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -183,7 +183,7 @@ class Installer extends \Magento\Framework\Object /** * @param \Magento\Framework\App\Config\ReinitableConfigInterface $config - * @param \Magento\Framework\Module\UpdaterInterface $dbUpdater + * @param \Magento\Framework\Module\Updater $dbUpdater * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Cache\StateInterface $cacheState @@ -191,7 +191,7 @@ class Installer extends \Magento\Framework\Object * @param \Magento\Framework\App\Arguments $arguments * @param \Magento\Framework\App\AreaList $areaList * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\User\Model\UserFactory $userModelFactory * @param Installer\Filesystem $filesystem * @param Installer\Pear $installerPear @@ -210,7 +210,7 @@ class Installer extends \Magento\Framework\Object */ public function __construct( \Magento\Framework\App\Config\ReinitableConfigInterface $config, - \Magento\Framework\Module\UpdaterInterface $dbUpdater, + \Magento\Framework\Module\Updater $dbUpdater, \Magento\Framework\App\CacheInterface $cache, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Cache\StateInterface $cacheState, @@ -218,7 +218,7 @@ class Installer extends \Magento\Framework\Object \Magento\Framework\App\Arguments $arguments, \Magento\Framework\App\AreaList $areaList, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\User\Model\UserFactory $userModelFactory, \Magento\Install\Model\Installer\Filesystem $filesystem, \Magento\Install\Model\Installer\Pear $installerPear, @@ -262,16 +262,6 @@ class Installer extends \Magento\Framework\Object parent::__construct($data); } - /** - * Checking install status of application - * - * @return bool - */ - public function isApplicationInstalled() - { - return $this->_appState->isInstalled(); - } - /** * Get data model * @@ -376,7 +366,8 @@ class Installer extends \Magento\Framework\Object $data = $this->_installerDb->checkDbConnectionData($data); - $this->_installerConfig->setConfigData($data)->install(); + $data = $this->_installerConfig->install($data); + $this->getDataModel()->setConfigData($data); $this->_arguments->reload(); $this->_resource->setTablePrefix($data['db_prefix']); @@ -416,12 +407,18 @@ class Installer extends \Magento\Framework\Object $unsecureBaseUrl = $this->_storeManager->getStore()->getBaseUrl('web'); if (!empty($data['unsecure_base_url'])) { $unsecureBaseUrl = $data['unsecure_base_url']; - $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $unsecureBaseUrl); + $this->_installSetup->setConfigData( + \Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, + $unsecureBaseUrl + ); } if (!empty($data['use_secure'])) { $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_FRONTEND, 1); - $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $data['secure_base_url']); + $this->_installSetup->setConfigData( + \Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, + $data['secure_base_url'] + ); if (!empty($data['use_secure_admin'])) { $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, 1); } @@ -440,7 +437,10 @@ class Installer extends \Magento\Framework\Object $this->_installSetup->setConfigData($this->_localeDate->getDefaultTimezonePath(), $locale['timezone']); } if (!empty($locale['currency'])) { - $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, $locale['currency']); + $this->_installSetup->setConfigData( + \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, + $locale['currency'] + ); $this->_installSetup->setConfigData( \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_DEFAULT, $locale['currency'] diff --git a/app/code/Magento/Install/Model/Installer/AbstractInstaller.php b/app/code/Magento/Install/Model/Installer/AbstractInstaller.php deleted file mode 100644 index 533e052cf6b6db35f2021f5563f4c12812cac510..0000000000000000000000000000000000000000 --- a/app/code/Magento/Install/Model/Installer/AbstractInstaller.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - - -/** - * Abstract installer model - * - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Install\Model\Installer; - -class AbstractInstaller -{ - /** - * Installer model - * - * @var \Magento\Install\Model\Installer - */ - protected $installer; - - /** - * @param \Magento\Install\Model\Installer $installer - */ - public function __construct(\Magento\Install\Model\Installer $installer) - { - $this->_installer = $installer; - } - - /** - * Installer singleton - * - * @var \Magento\Install\Model\Installer - */ - protected $_installer; - - /** - * Get installer singleton - * - * @return \Magento\Install\Model\Installer - */ - protected function _getInstaller() - { - return $this->_installer; - } - - /** - * Validate session storage value (files or db) - * If empty, will return 'files' - * - * @param string $value - * @return string - * @throws \Exception - */ - protected function _checkSessionSave($value) - { - if (empty($value)) { - return 'files'; - } - if (!in_array($value, array('files', 'db'), true)) { - throw new \Exception('session_save value must be "files" or "db".'); - } - return $value; - } - - /** - * Validate backend area frontname value. - * If empty, "backend" will be returned - * - * @param string $value - * @return string - * @throws \Exception - */ - protected function _checkBackendFrontname($value) - { - if (empty($value)) { - return 'backend'; - } - if (!preg_match('/^[a-z]+[a-z0-9_]+$/', $value)) { - throw new \Exception( - 'backend_frontname value must contain only letters (a-z), numbers (0-9)' . - ' or underscore(_), first character should be a letter.' - ); - } - return $value; - } -} diff --git a/app/code/Magento/Install/Model/Installer/Config.php b/app/code/Magento/Install/Model/Installer/Config.php index 1311d7d9a08ab6787cb06d5798178625a1a3fd49..a8940519f1ec9a91d07101b1cb55beba882f4e94 100644 --- a/app/code/Magento/Install/Model/Installer/Config.php +++ b/app/code/Magento/Install/Model/Installer/Config.php @@ -26,7 +26,7 @@ namespace Magento\Install\Model\Installer; /** * Config installer */ -class Config extends \Magento\Install\Model\Installer\AbstractInstaller +class Config { const TMP_INSTALL_DATE_VALUE = 'd-d-d-d-d'; @@ -44,11 +44,6 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller */ protected $_request; - /** - * @var array - */ - protected $_configData = array(); - /** * @var \Magento\Framework\App\Filesystem */ @@ -67,7 +62,7 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller /** * Store Manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -77,20 +72,17 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller protected $messageManager; /** - * @param \Magento\Install\Model\Installer $installer * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\App\Filesystem $filesystem - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( - \Magento\Install\Model\Installer $installer, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\Filesystem $filesystem, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Message\ManagerInterface $messageManager ) { - parent::__construct($installer); $this->_request = $request; $this->_storeManager = $storeManager; $this->_filesystem = $filesystem; @@ -99,35 +91,14 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller $this->messageManager = $messageManager; } - /** - * @param array $data - * @return $this - */ - public function setConfigData($data) - { - if (is_array($data)) { - $this->_configData = $data; - } - return $this; - } - - /** - * @return array - */ - public function getConfigData() - { - return $this->_configData; - } - /** * Generate installation data and record them into local.xml using local.xml.template * - * @return void + * @param array $config + * @return array */ - public function install() + public function install($config) { - $data = $this->getConfigData(); - $defaults = array( 'root_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR), 'app_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::APP_DIR), @@ -135,46 +106,46 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller 'base_url' => $this->_request->getDistroBaseUrl() ); foreach ($defaults as $index => $value) { - if (!isset($data[$index])) { - $data[$index] = $value; + if (!isset($config[$index])) { + $config[$index] = $value; } } - if (isset($data['unsecure_base_url'])) { - $data['unsecure_base_url'] .= substr($data['unsecure_base_url'], -1) != '/' ? '/' : ''; - if (strpos($data['unsecure_base_url'], 'http') !== 0) { - $data['unsecure_base_url'] = 'http://' . $data['unsecure_base_url']; + if (isset($config['unsecure_base_url'])) { + $config['unsecure_base_url'] .= substr($config['unsecure_base_url'], -1) != '/' ? '/' : ''; + if (strpos($config['unsecure_base_url'], 'http') !== 0) { + $config['unsecure_base_url'] = 'http://' . $config['unsecure_base_url']; } - if (!$this->_getInstaller()->getDataModel()->getSkipBaseUrlValidation()) { - $this->_checkUrl($data['unsecure_base_url']); + if (empty($config['skip_base_url_validation'])) { + $this->_checkUrl($config['unsecure_base_url']); } } - if (isset($data['secure_base_url'])) { - $data['secure_base_url'] .= substr($data['secure_base_url'], -1) != '/' ? '/' : ''; - if (strpos($data['secure_base_url'], 'http') !== 0) { - $data['secure_base_url'] = 'https://' . $data['secure_base_url']; + if (isset($config['secure_base_url'])) { + $config['secure_base_url'] .= substr($config['secure_base_url'], -1) != '/' ? '/' : ''; + if (strpos($config['secure_base_url'], 'http') !== 0) { + $config['secure_base_url'] = 'https://' . $config['secure_base_url']; } - if (!empty($data['use_secure']) && !$this->_getInstaller()->getDataModel()->getSkipUrlValidation()) { - $this->_checkUrl($data['secure_base_url']); + if (!empty($config['use_secure']) && empty($config['skip_url_validation'])) { + $this->_checkUrl($config['secure_base_url']); } } - $data['date'] = self::TMP_INSTALL_DATE_VALUE; - $data['key'] = self::TMP_ENCRYPT_KEY_VALUE; - $data['var_dir'] = $data['root_dir'] . '/var'; + $config['date'] = self::TMP_INSTALL_DATE_VALUE; + $config['key'] = self::TMP_ENCRYPT_KEY_VALUE; + $config['var_dir'] = $config['root_dir'] . '/var'; - $data['use_script_name'] = isset($data['use_script_name']) ? 'true' : 'false'; - - $this->_getInstaller()->getDataModel()->setConfigData($data); + $config['use_script_name'] = isset($config['use_script_name']) ? 'true' : 'false'; $contents = $this->_configDirectory->readFile('local.xml.template'); - foreach ($data as $index => $value) { + foreach ($config as $index => $value) { $contents = str_replace('{{' . $index . '}}', '<![CDATA[' . $value . ']]>', $contents); } $this->_configDirectory->writeFile($this->_localConfigFile, $contents); $this->_configDirectory->changePermissions($this->_localConfigFile, 0777); + + return $config; } /** diff --git a/app/code/Magento/Install/Model/Installer/Console.php b/app/code/Magento/Install/Model/Installer/Console.php index 4016b8f1a7b1d0489e218a482f34df2299c7e8c3..f2f0fdd6ae22c73b385b3c35474ed4f24ae685ca 100644 --- a/app/code/Magento/Install/Model/Installer/Console.php +++ b/app/code/Magento/Install/Model/Installer/Console.php @@ -27,21 +27,8 @@ */ namespace Magento\Install\Model\Installer; -use Magento\Framework\App\Filesystem as AppFilesystem; -use Magento\Framework\Filesystem\FilesystemException; -use Magento\Framework\Message\MessageInterface; - -class Console extends \Magento\Install\Model\Installer\AbstractInstaller +class Console { - /**#@+ - * Installation options for application initialization - */ - const OPTION_URIS = 'install_option_uris'; - - const OPTION_DIRS = 'install_option_dirs'; - - /**#@- */ - /** * Available installation options * @@ -49,13 +36,6 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ protected $installParameters = []; - /** - * Stores errors on file delete - * - * @var array - */ - protected $fileDeleteErrors = []; - /** * Required parameters with descriptions * @@ -100,11 +80,6 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller 'cleanup_database' => 'Clean up database before installation. Flag value. Disabled by default' ]; - /** - * @var AppFilesystem - */ - protected $_filesystem; - /** * Installer data model to store data between installations steps * @@ -113,16 +88,16 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller protected $_dataModel; /** - * Resource config + * Installer model * - * @var \Magento\Framework\App\Resource\Config + * @var \Magento\Install\Model\Installer */ - protected $_resourceConfig; + protected $installer; /** * DB updater * - * @var \Magento\Framework\Module\UpdaterInterface + * @var \Magento\Framework\Module\Updater */ protected $_dbUpdater; @@ -133,13 +108,6 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ protected $_installerData = null; - /** - * Application State - * - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * Locale Lists * @@ -150,40 +118,39 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller /** * Magento Object Manager * - * @var \Magento\Framework\ObjectManager + * @var \Magento\Framework\Message\ManagerInterface + */ + protected $messageManager; + + /** + * @var \Magento\Install\Model\Installer\Db\Mysql4 */ - protected $_objectManager; + protected $db; /** * @param \Magento\Install\Model\Installer $installer - * @param \Magento\Framework\App\Resource\Config $resourceConfig - * @param \Magento\Framework\Module\UpdaterInterface $dbUpdater - * @param AppFilesystem $filesystem + * @param \Magento\Framework\Module\Updater $dbUpdater * @param \Magento\Install\Model\Installer\Data $installerData - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Locale\ListsInterface $localeLists - * @param \Magento\Framework\ObjectManager $objectManager + * @param \Magento\Install\Model\Installer\Db\Mysql4 $db + * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( \Magento\Install\Model\Installer $installer, - \Magento\Framework\App\Resource\Config $resourceConfig, - \Magento\Framework\Module\UpdaterInterface $dbUpdater, - AppFilesystem $filesystem, + \Magento\Framework\Module\Updater $dbUpdater, \Magento\Install\Model\Installer\Data $installerData, - \Magento\Framework\App\State $appState, \Magento\Framework\Locale\ListsInterface $localeLists, - \Magento\Framework\ObjectManager $objectManager + Db\Mysql4 $db, + \Magento\Framework\Message\ManagerInterface $messageManager ) { - parent::__construct($installer); - $this->_resourceConfig = $resourceConfig; + $this->installer = $installer; $this->_dbUpdater = $dbUpdater; - $this->_filesystem = $filesystem; $this->_installerData = $installerData; - $this->_installer->setDataModel($this->_installerData); - $this->_appState = $appState; + $this->installer->setDataModel($this->_installerData); $this->_localeLists = $localeLists; - $this->_objectManager = $objectManager; $this->installParameters = array_keys($this->requiredParameters + $this->optionalParameters); + $this->db = $db; + $this->messageManager = $messageManager; } /** @@ -283,14 +250,6 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller return false; } - /** - * Check if already installed - */ - if ($this->_appState->isInstalled()) { - $this->addError('ERROR: Magento is already installed.'); - return false; - } - /** * Skip URL validation, if set */ @@ -351,15 +310,13 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller return false; } - $installer = $this->_getInstaller(); - /** * Install configuration */ - $installer->installConfig($this->_installerData->getConfigData()); + $this->installer->installConfig($this->_installerData->getConfigData()); if (!empty($options['cleanup_database'])) { - $this->_cleanUpDatabase(); + $this->db->cleanUpDatabase(); } if ($this->hasErrors()) { @@ -369,7 +326,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller /** * Install database */ - $installer->installDb(); + $this->installer->installDb(); if ($this->hasErrors()) { return false; @@ -382,27 +339,19 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller * Create primary administrator user & install encryption key */ $encryptionKey = !empty($options['encryption_key']) ? $options['encryption_key'] : null; - $encryptionKey = $installer->getValidEncryptionKey($encryptionKey); - $installer->createAdministrator($this->_installerData->getAdminData()); - $installer->installEncryptionKey($encryptionKey); + $encryptionKey = $this->installer->getValidEncryptionKey($encryptionKey); + $this->installer->createAdministrator($this->_installerData->getAdminData()); + $this->installer->installEncryptionKey($encryptionKey); /** * Installation finish */ - $installer->finish(); + $this->installer->finish(); if ($this->hasErrors()) { return false; } - /** - * Change directories mode to be writable by apache user - */ - $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR)->changePermissions( - '', - 0777 - ); - return $encryptionKey; } catch (\Exception $e) { if ($e instanceof \Magento\Framework\Model\Exception) { @@ -416,94 +365,12 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller } } else { - $this->addError('ERROR: ' . $e->getMessage()); + $this->addError('ERROR: ' . $e->getMessage() . $e->getTraceAsString()); } return false; } } - /** - * Cleanup database use system configuration - * - * @return void - */ - protected function _cleanUpDatabase() - { - $modelName = 'Magento\Install\Model\Installer\Db\Mysql4'; - /** @var $resourceModel \Magento\Install\Model\Installer\Db\AbstractDb */ - $resourceModel = $this->_objectManager->get($modelName); - $resourceModel->cleanUpDatabase(); - } - - /** - * Remove temp directory - * - * @return void - */ - - protected function _removeTempDir() - { - $varDirectory = $this->_filesystem->getDirectoryWrite(AppFilesystem::VAR_DIR); - foreach ($varDirectory->read() as $path) { - if ($varDirectory->isDirectory($path)) { - try { - $varDirectory->delete($path); - } catch (FilesystemException $e) { - $this->fileDeleteErrors[] = $e->getMessage(); - } - } - } - } - - /** - * Remove local.xml - * - * @return void - */ - - protected function _removeLocalXml() - { - try { - $this->_filesystem->getDirectoryWrite(AppFilesystem::CONFIG_DIR)->delete('local.xml'); - } catch (FilesystemException $e) { - $this->fileDeleteErrors[] = $e->getMessage(); - } - } - - /** - * Display files that were not deleted on uninstall - * - * @return void - */ - - protected function _displayFileDeleteErrors() - { - foreach ($this->fileDeleteErrors as $errors) { - $unDeletedFile = trim(explode(" ", $errors)[2]); - echo "Please delete the file manually : $unDeletedFile \n"; - } - } - - /** - * Uninstall the application - * - * @return bool - */ - public function uninstall() - { - if (!$this->_appState->isInstalled()) { - return false; - } - - $this->_cleanUpDatabase(); - $this->_removeTempDir(); - $this->_removeLocalXml(); - if (!empty($this->fileDeleteErrors)) { - $this->_displayFileDeleteErrors(); - } - return true; - } - /** * Retrieve available locale codes * @@ -560,21 +427,54 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ public function checkServer() { - \Magento\Framework\Phrase::setRenderer( - $this->_objectManager->get('Magento\Framework\Phrase\RendererInterface') - ); - - $installer = $this->_getInstaller(); - $result = $installer->checkServer(); + $result = $this->installer->checkServer(); if (!$result) { - /** @var \Magento\Framework\Message\ManagerInterface $messageManager*/ - $messageManager = $this->_objectManager->get('Magento\Framework\Message\ManagerInterface'); - /** @var \Magento\Framework\Message\MessageInterface $message */ - foreach ($messageManager->getMessages()->getItems() as $message) { + foreach ($this->messageManager->getMessages()->getItems() as $message) { $this->addError($message->toString()); } } return $this; } + + /** + * Validate session storage value (files or db) + * If empty, will return 'files' + * + * @param string $value + * @return string + * @throws \Exception + */ + protected function _checkSessionSave($value) + { + if (empty($value)) { + return 'files'; + } + if (!in_array($value, array('files', 'db'), true)) { + throw new \Exception('session_save value must be "files" or "db".'); + } + return $value; + } + + /** + * Validate backend area frontname value. + * If empty, "backend" will be returned + * + * @param string $value + * @return string + * @throws \Exception + */ + protected function _checkBackendFrontname($value) + { + if (empty($value)) { + return 'backend'; + } + if (!preg_match('/^[a-z]+[a-z0-9_]+$/', $value)) { + throw new \Exception( + 'backend_frontname value must contain only letters (a-z), numbers (0-9)' . + ' or underscore(_), first character should be a letter.' + ); + } + return $value; + } } diff --git a/app/code/Magento/Install/Model/Installer/Db.php b/app/code/Magento/Install/Model/Installer/Db.php index e1d58e869e26d78129ed1cc58229d67252b8838c..a2139e0e533f2aee304434a57f26dff0fecbf325 100644 --- a/app/code/Magento/Install/Model/Installer/Db.php +++ b/app/code/Magento/Install/Model/Installer/Db.php @@ -27,7 +27,7 @@ */ namespace Magento\Install\Model\Installer; -class Db extends \Magento\Install\Model\Installer\AbstractInstaller +class Db { /** * Database resource @@ -43,7 +43,7 @@ class Db extends \Magento\Install\Model\Installer\AbstractInstaller /** * Database model factory - * + * * @var \Magento\Install\Model\Installer\Db\Factory */ protected $_dbFactory; @@ -56,18 +56,15 @@ class Db extends \Magento\Install\Model\Installer\AbstractInstaller protected $_dbConfig; /** - * @param \Magento\Install\Model\Installer $installer * @param \Magento\Framework\Logger $logger * @param \Magento\Install\Model\Installer\Db\Factory $dbFactory * @param array $dbConfig */ public function __construct( - \Magento\Install\Model\Installer $installer, \Magento\Framework\Logger $logger, \Magento\Install\Model\Installer\Db\Factory $dbFactory, array $dbConfig ) { - parent::__construct($installer); $this->_logger = $logger; $this->_dbConfig = $dbConfig; $this->_dbFactory = $dbFactory; diff --git a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php index c22d08822e6d5ad972f093a6e8820c44d5f294a0..918b2ed34155a7ff0b6fadc14b6f21bf8d60a8d7 100644 --- a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php +++ b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php @@ -197,7 +197,7 @@ abstract class AbstractDb /** * Clean up database * - * @return \Magento\Install\Model\Installer\Db\AbstractDb + * @return void */ abstract public function cleanUpDatabase(); } diff --git a/app/code/Magento/Install/Model/Installer/Db/Mysql4.php b/app/code/Magento/Install/Model/Installer/Db/Mysql4.php index bd0c3ff66c78bca89c883cf04d02e8d737dfa791..f1b25bdbaccf81771dc89045215908532e07e04e 100644 --- a/app/code/Magento/Install/Model/Installer/Db/Mysql4.php +++ b/app/code/Magento/Install/Model/Installer/Db/Mysql4.php @@ -58,16 +58,13 @@ class Mysql4 extends \Magento\Install\Model\Installer\Db\AbstractDb } /** - * Clean database - * - * @return $this + * {@inheritdoc} */ public function cleanUpDatabase() { - $connection = $this->_getConnection(); $connectionData = $this->getConnectionData(); + $connection = $this->_getConnection(); $connection->query('DROP DATABASE IF EXISTS ' . $connectionData['dbName']); $connection->query('CREATE DATABASE ' . $connectionData['dbName']); - return $this; } } diff --git a/app/code/Magento/Install/Model/Installer/Filesystem.php b/app/code/Magento/Install/Model/Installer/Filesystem.php index b47754e505a06fc61eecf78917361fa28e379e70..69534670555951f8783efc63680ecf386536b551 100644 --- a/app/code/Magento/Install/Model/Installer/Filesystem.php +++ b/app/code/Magento/Install/Model/Installer/Filesystem.php @@ -26,7 +26,7 @@ namespace Magento\Install\Model\Installer; /** * Filesystem installer */ -class Filesystem extends \Magento\Install\Model\Installer\AbstractInstaller +class Filesystem { /**#@+ * @deprecated since 1.7.1.0 @@ -62,18 +62,15 @@ class Filesystem extends \Magento\Install\Model\Installer\AbstractInstaller protected $messageManager; /** - * @param \Magento\Install\Model\Installer $installer * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Install\Model\Config $installConfig * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( - \Magento\Install\Model\Installer $installer, \Magento\Framework\App\Filesystem $filesystem, \Magento\Install\Model\Config $installConfig, \Magento\Framework\Message\ManagerInterface $messageManager ) { - parent::__construct($installer); $this->_filesystem = $filesystem; $this->_installConfig = $installConfig; $this->messageManager = $messageManager; diff --git a/app/code/Magento/Install/Model/Installer/Pear.php b/app/code/Magento/Install/Model/Installer/Pear.php index eed98694448c49d5b2cd27d5e764dd29cae2ba31..099ed6f848ed54e062ea646f861b077261e3b819 100644 --- a/app/code/Magento/Install/Model/Installer/Pear.php +++ b/app/code/Magento/Install/Model/Installer/Pear.php @@ -26,7 +26,7 @@ namespace Magento\Install\Model\Installer; /** * PEAR Packages Download Manager */ -class Pear extends \Magento\Install\Model\Installer\AbstractInstaller +class Pear { /** * @var \Magento\Framework\Message\ManagerInterface @@ -34,14 +34,11 @@ class Pear extends \Magento\Install\Model\Installer\AbstractInstaller protected $messageManager; /** - * @param \Magento\Install\Model\Installer $installer * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( - \Magento\Install\Model\Installer $installer, \Magento\Framework\Message\ManagerInterface $messageManager ) { - parent::__construct($installer); $this->messageManager = $messageManager; } diff --git a/app/code/Magento/Install/Model/Uninstaller.php b/app/code/Magento/Install/Model/Uninstaller.php new file mode 100644 index 0000000000000000000000000000000000000000..2af58797e3fc57659b313936bedf60ac3ab8a34e --- /dev/null +++ b/app/code/Magento/Install/Model/Uninstaller.php @@ -0,0 +1,160 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Install\Model; + +use Magento\Framework\App\Filesystem; +use Magento\Framework\Filesystem\FilesystemException; + +/** + * A model for uninstalling Magento application + */ +class Uninstaller +{ + /** + * A service for cleaning up directories + * + * @var Filesystem + */ + protected $filesystem; + + /** + * A service for recreating database + * + * @var Installer\Db\Mysql4 + */ + private $db; + + /** + * Logger + * + * @var \Zend_Log + */ + private $log; + + /** + * Constructor + * + * @param Filesystem $filesystem + * @param Installer\Db\Mysql4 $db + * @param \Zend_Log $log + */ + public function __construct( + Filesystem $filesystem, + Installer\Db\Mysql4 $db, + \Zend_Log $log + ) { + $this->filesystem = $filesystem; + $this->db = $db; + $this->log = $log; + } + + /** + * Uninstalls the application + * + * @return void + */ + public function uninstall() + { + $this->log('Starting uninstall'); + $this->recreateDatabase(); + $this->log('File system cleanup:'); + $this->deleteDirContents(Filesystem::VAR_DIR); + $this->deleteDirContents(Filesystem::STATIC_VIEW_DIR); + $this->deleteLocalXml(); + $this->log('Uninstall complete.'); + } + + /** + * Log output + * + * @param string $message + * @param int $level + * @return void + */ + private function log($message, $level = \Zend_Log::INFO) + { + $this->log->log($message, $level); + } + + /** + * Deletes the database and creates it again + * + * @return void + */ + private function recreateDatabase() + { + $connectionData = $this->db->getConnectionData(); + if (empty($connectionData['dbName'])) { + $this->log('No database connection defined - skipping cleanup'); + } else { + $this->log("Recreating database '{$connectionData['dbName']}'"); + $this->db->cleanUpDatabase(); + } + } + + /** + * Removes contents of a directory + * + * @param string $type + * @return void + */ + private function deleteDirContents($type) + { + $dir = $this->filesystem->getDirectoryWrite($type); + $dirPath = $dir->getAbsolutePath(); + foreach ($dir->read() as $path) { + if (preg_match('/^\./', $path)) { + continue; + } + $this->log("{$dirPath}{$path}"); + try { + $dir->delete($path); + } catch (FilesystemException $e) { + $this->log($e->getMessage()); + } + } + } + + /** + * Removes deployment configuration + * + * @return void + */ + protected function deleteLocalXml() + { + $configDir = $this->filesystem->getDirectoryWrite(Filesystem::CONFIG_DIR); + $localXml = "{$configDir->getAbsolutePath()}local.xml"; + if (!$configDir->isFile('local.xml')) { + $this->log("The file '{$localXml}' doesn't exist - skipping cleanup"); + return; + } + try { + $this->log($localXml); + $configDir->delete('local.xml'); + } catch (FilesystemException $e) { + $this->log($e->getMessage()); + } + } +} diff --git a/app/code/Magento/Install/composer.json b/app/code/Magento/Install/composer.json index 5b3da388d636856e61eb2eeb1861e910330be161..5bea19a8a3ae3610b4545c77c675d571fcd4fdf5 100644 --- a/app/code/Magento/Install/composer.json +++ b/app/code/Magento/Install/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-user": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-user": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Install/etc/di.xml b/app/code/Magento/Install/etc/di.xml index c502e62e5a7adc0a6baa0c47d50c770e7b8e2096..d324d9ebac622d45777eac2c21ba38535e6b0dde 100644 --- a/app/code/Magento/Install/etc/di.xml +++ b/app/code/Magento/Install/etc/di.xml @@ -113,11 +113,6 @@ <argument name="session" xsi:type="object">Magento\Install\Model\Session</argument> </arguments> </type> - <type name="Magento\Install\Controller\Wizard"> - <arguments> - <argument name="session" xsi:type="object">Magento\Install\Model\Session</argument> - </arguments> - </type> <type name="Magento\Install\Model\Installer"> <arguments> <argument name="session" xsi:type="object">Magento\Install\Model\Session</argument> @@ -128,11 +123,6 @@ <argument name="session" xsi:type="object">Magento\Install\Model\Session</argument> </arguments> </type> - <type name="Magento\Install\Model\Installer\AbstractInstaller"> - <arguments> - <argument name="installer" xsi:type="object">Magento\Install\Model\Installer\Proxy</argument> - </arguments> - </type> <type name="Magento\Framework\App\AreaList"> <arguments> <argument name="areas" xsi:type="array"> @@ -148,9 +138,6 @@ <argument name="areaCode" xsi:type="string">adminhtml</argument> </arguments> </type> - <type name="Magento\Framework\App\Action\Action"> - <plugin name="installInitializer" type="Magento\Install\App\Action\Plugin\Install" sortOrder="5"/> - </type> <type name="Magento\Install\Model\Setup"> <arguments> <argument name="resourceName" xsi:type="string">core_setup</argument> diff --git a/app/code/Magento/Install/etc/install/di.xml b/app/code/Magento/Install/etc/install/di.xml index 607cfefdd0805879984a57e3952428795317c25c..4bb37d60fd469bb13453241b813d3c373867ff31 100644 --- a/app/code/Magento/Install/etc/install/di.xml +++ b/app/code/Magento/Install/etc/install/di.xml @@ -25,24 +25,4 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Core\Model\Theme" type="Magento\Core\Model\Theme\Data" /> - <type name="Magento\Framework\App\RouterList" shared="true"> - <arguments> - <argument name="routerList" xsi:type="array"> - <item name="install" xsi:type="array"> - <item name="class" xsi:type="string">Magento\Core\App\Router\Base</item> - <item name="disable" xsi:type="boolean">false</item> - <item name="sortOrder" xsi:type="string">20</item> - </item> - </argument> - </arguments> - </type> - <type name="Magento\Install\Controller\Index\Index"> - <plugin name="installInitializer" disabled="true" /> - <plugin name="designLoader" type="Magento\Install\App\Action\Plugin\Design" /> - <plugin name="directoryCleaner" type="Magento\Install\App\Action\Plugin\Dir" sortOrder="10"/> - </type> - <type name="Magento\Install\Controller\Wizard"> - <plugin name="installInitializer" disabled="true" /> - <plugin name="designLoader" type="Magento\Install\App\Action\Plugin\Design" /> - </type> </config> diff --git a/app/code/Magento/Install/Controller/Wizard/End.php b/app/code/Magento/Integration/Helper/Validator.php similarity index 55% rename from app/code/Magento/Install/Controller/Wizard/End.php rename to app/code/Magento/Integration/Helper/Validator.php index ce9238c03484c3a1391e9ddd59646b27b3a5d9af..edf4750590262fd65cfe7f3c28696fbc5c129ed6 100644 --- a/app/code/Magento/Install/Controller/Wizard/End.php +++ b/app/code/Magento/Integration/Helper/Validator.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,33 +21,35 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class End extends \Magento\Install\Controller\Wizard +namespace Magento\Integration\Helper; + +use Magento\Framework\Exception\InputException; + +/** + * Validator Helper for user credentials + */ +class Validator { /** - * End installation + * Validate user credentials * + * @param string $username + * @param string $password + * @throws InputException * @return void */ - public function execute() + public function validateCredentials($username, $password) { - $this->_checkIfInstalled(); - - if ($this->_appState->isInstalled()) { - $this->_redirect('*/*'); - return; + $exception = new InputException(); + if (!is_string($username) || strlen($username) == 0) { + $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'username']); + } + if (!is_string($username) || strlen($password) == 0) { + $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'password']); + } + if ($exception->wasErrorAdded()) { + throw $exception; } - - $this->_getInstaller()->finish(); - - $this->_objectManager->get('Magento\Install\Model\Survey')->saveSurveyViewed(true); - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - - $this->_view->getLayout()->addBlock('Magento\Install\Block\End', 'install.end', 'content'); - $this->_view->renderLayout(); - $this->_session->clearStorage(); } } diff --git a/app/code/Magento/Integration/Service/V1/TokenService.php b/app/code/Magento/Integration/Service/V1/AdminTokenService.php similarity index 58% rename from app/code/Magento/Integration/Service/V1/TokenService.php rename to app/code/Magento/Integration/Service/V1/AdminTokenService.php index 49bf1f5d5b3e437260dcb1589c1561db61fa0af1..59974924d665db01ea2d07a72a0d4edb55808311 100644 --- a/app/code/Magento/Integration/Service/V1/TokenService.php +++ b/app/code/Magento/Integration/Service/V1/AdminTokenService.php @@ -24,21 +24,19 @@ namespace Magento\Integration\Service\V1; -use Magento\Customer\Service\V1\CustomerAccountServiceInterface as CustomerAccountService; use Magento\Framework\Exception\AuthenticationException; -use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\LocalizedException; -use Magento\Integration\Model\Oauth\Token\Factory as TokenModelFactory; +use Magento\Integration\Helper\Validator; use Magento\Integration\Model\Oauth\Token as Token; -use Magento\User\Model\User as UserModel; +use Magento\Integration\Model\Oauth\Token\Factory as TokenModelFactory; use Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory as TokenCollectionFactory; +use Magento\User\Model\User as UserModel; /** - * Class to handle token generation for Admins and Customers + * Class to handle token generation for Admins * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class TokenService implements TokenServiceInterface +class AdminTokenService implements AdminTokenServiceInterface { /** * Token Model @@ -55,37 +53,35 @@ class TokenService implements TokenServiceInterface private $userModel; /** - * Customer Account Service - * - * @var CustomerAccountService + * @var \Magento\Integration\Helper\Validator */ - private $customerAccountService; + private $validatorHelper; /** * Token Collection Factory * * @var TokenCollectionFactory */ - public $tokenModelCollectionFactory; + private $tokenModelCollectionFactory; /** * Initialize service * * @param TokenModelFactory $tokenModelFactory * @param UserModel $userModel - * @param CustomerAccountService $customerAccountService * @param TokenCollectionFactory $tokenModelCollectionFactory + * @param \Magento\Integration\Helper\Validator $validatorHelper */ public function __construct( TokenModelFactory $tokenModelFactory, UserModel $userModel, - CustomerAccountService $customerAccountService, - TokenCollectionFactory $tokenModelCollectionFactory + TokenCollectionFactory $tokenModelCollectionFactory, + Validator $validatorHelper ) { $this->tokenModelFactory = $tokenModelFactory; $this->userModel = $userModel; - $this->customerAccountService = $customerAccountService; $this->tokenModelCollectionFactory = $tokenModelCollectionFactory; + $this->validatorHelper = $validatorHelper; } /** @@ -93,7 +89,7 @@ class TokenService implements TokenServiceInterface */ public function createAdminAccessToken($username, $password) { - $this->validateCredentials($username, $password); + $this->validatorHelper->validateCredentials($username, $password); try { $this->userModel->login($username, $password); if (!$this->userModel->getId()) { @@ -113,11 +109,7 @@ class TokenService implements TokenServiceInterface } /** - * Revoke token by admin id. - * - * @param int $adminId - * @return bool - * @throws \Magento\Framework\Exception\LocalizedException + * {@inheritdoc} */ public function revokeAdminAccessToken($adminId) { @@ -134,59 +126,4 @@ class TokenService implements TokenServiceInterface } return true; } - - /** - * {@inheritdoc} - */ - public function createCustomerAccessToken($username, $password) - { - $this->validateCredentials($username, $password); - $customerDataObject = $this->customerAccountService->authenticate($username, $password); - return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken(); - } - - /** - * Revoke token by customer id. - * - * @param int $customerId - * @return bool - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function revokeCustomerAccessToken($customerId) - { - $tokenCollection = $this->tokenModelCollectionFactory->create()->addFilterByCustomerId($customerId); - if ($tokenCollection->getSize() == 0) { - throw new LocalizedException("This customer has no tokens."); - } - try { - foreach ($tokenCollection as $token) { - $token->setRevoked(1)->save(); - } - } catch (\Exception $e) { - throw new LocalizedException("The tokens could not be revoked."); - } - return true; - } - - /** - * Validate user credentials - * - * @param string $username - * @param string $password - * @return void - * @throws \Magento\Framework\Exception\InputException - */ - protected function validateCredentials($username, $password) - { - $exception = new InputException(); - if (!is_string($username) || strlen($username) == 0) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'username']); - } - if (!is_string($username) || strlen($password) == 0) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'password']); - } - if ($exception->wasErrorAdded()) { - throw $exception; - } - } } diff --git a/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php b/app/code/Magento/Integration/Service/V1/AdminTokenServiceInterface.php similarity index 78% rename from app/code/Magento/Integration/Service/V1/TokenServiceInterface.php rename to app/code/Magento/Integration/Service/V1/AdminTokenServiceInterface.php index 0f374a7a638a7da5071c570e073ffb66a8af981f..c613b2718d5eb6e0bc2019f6decdb1110c4d4c4d 100644 --- a/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php +++ b/app/code/Magento/Integration/Service/V1/AdminTokenServiceInterface.php @@ -29,9 +29,9 @@ use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\LocalizedException; /** - * Interface providing token generation for Admins and Customers + * Interface providing token generation for Admins */ -interface TokenServiceInterface +interface AdminTokenServiceInterface { /** * Create access token for admin given the admin credentials. @@ -46,13 +46,11 @@ interface TokenServiceInterface public function createAdminAccessToken($username, $password); /** - * Create access token for admin given the customer credentials. + * Revoke token by admin id. * - * @param string $username - * @param string $password - * @return string Token created - * @throws InputException For invalid input - * @throws AuthenticationException + * @param int $adminId + * @return bool + * @throws \Magento\Framework\Exception\LocalizedException */ - public function createCustomerAccessToken($username, $password); + public function revokeAdminAccessToken($adminId); } diff --git a/app/code/Magento/Integration/Service/V1/CustomerTokenService.php b/app/code/Magento/Integration/Service/V1/CustomerTokenService.php new file mode 100644 index 0000000000000000000000000000000000000000..6fdd3a7b3aa152c1ba55bd143cd8c29f693fe401 --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/CustomerTokenService.php @@ -0,0 +1,110 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Integration\Service\V1; + +use Magento\Customer\Service\V1\CustomerAccountServiceInterface as CustomerAccountService; +use Magento\Framework\Exception\LocalizedException; +use Magento\Integration\Helper\Validator; +use Magento\Integration\Model\Oauth\Token\Factory as TokenModelFactory; +use Magento\Integration\Model\Oauth\Token as Token; +use Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory as TokenCollectionFactory; + +class CustomerTokenService implements CustomerTokenServiceInterface +{ + /** + * Token Model + * + * @var TokenModelFactory + */ + private $tokenModelFactory; + + /** + * Customer Account Service + * + * @var CustomerAccountService + */ + private $customerAccountService; + + /** + * @var \Magento\Integration\Helper\Validator + */ + private $validatorHelper; + + /** + * Token Collection Factory + * + * @var TokenCollectionFactory + */ + private $tokenModelCollectionFactory; + + /** + * Initialize service + * + * @param TokenModelFactory $tokenModelFactory + * @param CustomerAccountService $customerAccountService + * @param TokenCollectionFactory $tokenModelCollectionFactory + * @param \Magento\Integration\Helper\Validator $validatorHelper + */ + public function __construct( + TokenModelFactory $tokenModelFactory, + CustomerAccountService $customerAccountService, + TokenCollectionFactory $tokenModelCollectionFactory, + Validator $validatorHelper + ) { + $this->tokenModelFactory = $tokenModelFactory; + $this->customerAccountService = $customerAccountService; + $this->tokenModelCollectionFactory = $tokenModelCollectionFactory; + $this->validatorHelper = $validatorHelper; + } + + /** + * {@inheritdoc} + */ + public function createCustomerAccessToken($username, $password) + { + $this->validatorHelper->validateCredentials($username, $password); + $customerDataObject = $this->customerAccountService->authenticate($username, $password); + return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken(); + } + + /** + * {@inheritdoc} + */ + public function revokeCustomerAccessToken($customerId) + { + $tokenCollection = $this->tokenModelCollectionFactory->create()->addFilterByCustomerId($customerId); + if ($tokenCollection->getSize() == 0) { + throw new LocalizedException("This customer has no tokens."); + } + try { + foreach ($tokenCollection as $token) { + $token->setRevoked(1)->save(); + } + } catch (\Exception $e) { + throw new LocalizedException("The tokens could not be revoked."); + } + return true; + } +} diff --git a/app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php b/app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..bfac3a193ddd2f75b7b5d4091b842770fb1c92b6 --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php @@ -0,0 +1,52 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Integration\Service\V1; + +use Magento\Framework\Exception\AuthenticationException; + +/** + * Interface providing token generation for Customers + */ +interface CustomerTokenServiceInterface +{ + /** + * Create access token for admin given the customer credentials. + * + * @param string $username + * @param string $password + * @return string Token created + * @throws AuthenticationException + */ + public function createCustomerAccessToken($username, $password); + + /** + * Revoke token by customer id. + * + * @param int $customerId + * @return bool + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function revokeCustomerAccessToken($customerId); +} diff --git a/app/code/Magento/Integration/Service/V1/Oauth.php b/app/code/Magento/Integration/Service/V1/Oauth.php index 0456688ad2172e9e9733027af6339ef1d7d430ef..85ef600b63c2b6bdc2e2e749436a03ac792a4c4b 100644 --- a/app/code/Magento/Integration/Service/V1/Oauth.php +++ b/app/code/Magento/Integration/Service/V1/Oauth.php @@ -40,7 +40,7 @@ use Magento\Integration\Model\Oauth\Consumer as ConsumerModel; class Oauth implements OauthInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -82,7 +82,7 @@ class Oauth implements OauthInterface /** * Initialize dependencies. * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param ConsumerFactory $consumerFactory * @param TokenFactory $tokenFactory * @param IntegrationOauthHelper $dataHelper @@ -92,7 +92,7 @@ class Oauth implements OauthInterface * @param TokenProvider $tokenProvider */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, ConsumerFactory $consumerFactory, TokenFactory $tokenFactory, IntegrationOauthHelper $dataHelper, diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index b8808f56f12da2840c871bbd991f1db512c8d013..afe75132936fd40da68ec286c8f1b3bd31c9d23a 100644 --- a/app/code/Magento/Integration/composer.json +++ b/app/code/Magento/Integration/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-user": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", - "magento/module-authorization": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-user": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/module-authorization": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Integration/etc/di.xml b/app/code/Magento/Integration/etc/di.xml index b1460317df48edde0b4df2515ba732f7650fdec8..bcb6a1ec1707269d5d7f305782cb02d1e274a858 100644 --- a/app/code/Magento/Integration/etc/di.xml +++ b/app/code/Magento/Integration/etc/di.xml @@ -30,7 +30,8 @@ <preference for="Magento\Framework\Oauth\ConsumerInterface" type="Magento\Integration\Model\Oauth\Consumer"/> <preference for="Magento\Framework\Oauth\NonceGeneratorInterface" type="Magento\Integration\Model\Oauth\Nonce\Generator"/> <preference for="Magento\Framework\Oauth\TokenProviderInterface" type="Magento\Integration\Model\Oauth\Token\Provider"/> - <preference for="Magento\Integration\Service\V1\TokenServiceInterface" type="Magento\Integration\Service\V1\TokenService" /> + <preference for="Magento\Integration\Service\V1\CustomerTokenServiceInterface" type="Magento\Integration\Service\V1\CustomerTokenService" /> + <preference for="Magento\Integration\Service\V1\AdminTokenServiceInterface" type="Magento\Integration\Service\V1\AdminTokenService" /> <type name="Magento\Integration\Model\Oauth\Nonce\Generator"> <arguments> <argument name="date" xsi:type="object">Magento\Framework\Stdlib\DateTime\DateTime\Proxy</argument> diff --git a/app/code/Magento/Integration/etc/webapi.xml b/app/code/Magento/Integration/etc/webapi.xml index 2153888cff31988074bcf6d13f0861767df1454a..fc128e88959cf5a611de171672e774a9ddc56b81 100644 --- a/app/code/Magento/Integration/etc/webapi.xml +++ b/app/code/Magento/Integration/etc/webapi.xml @@ -26,13 +26,13 @@ <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> <route url="/V1/integration/admin/token" method="POST"> - <service class="Magento\Integration\Service\V1\TokenServiceInterface" method="createAdminAccessToken"/> + <service class="Magento\Integration\Service\V1\AdminTokenServiceInterface" method="createAdminAccessToken"/> <resources> <resource ref="anonymous"/> </resources> </route> <route url="/V1/integration/customer/token" method="POST"> - <service class="Magento\Integration\Service\V1\TokenServiceInterface" method="createCustomerAccessToken"/> + <service class="Magento\Integration\Service\V1\CustomerTokenServiceInterface" method="createCustomerAccessToken"/> <resources> <resource ref="anonymous"/> </resources> diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index eae263773ed79fceb29b4ae3ddc9f9de9e689400..7d6c1dff5077711ce259499eb9796cda98d8326b 100644 --- a/app/code/Magento/LayeredNavigation/composer.json +++ b/app/code/Magento/LayeredNavigation/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Log/App/Shell.php b/app/code/Magento/Log/App/Shell.php index eebdacb3bf00dab51bcbd7bfee3f147f2a538ecb..58bc842e92d47c76d7a51cc8ec55071ac586f713 100644 --- a/app/code/Magento/Log/App/Shell.php +++ b/app/code/Magento/Log/App/Shell.php @@ -26,6 +26,7 @@ namespace Magento\Log\App; use Magento\Framework\App\Console\Response; +use Magento\Framework\App\Bootstrap; use Magento\Framework\AppInterface; class Shell implements AppInterface @@ -72,4 +73,12 @@ class Shell implements AppInterface $this->_response->setCode(0); return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php b/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php new file mode 100644 index 0000000000000000000000000000000000000000..a027e24c4522dd831eebd3b2b3ea2f3675fd1756 --- /dev/null +++ b/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php @@ -0,0 +1,163 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View; + +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; + +/** + * Class Status + * @package Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View + */ +class Status extends \Magento\Backend\Block\Template +{ + /** + * @var \Magento\Customer\Service\V1\Data\Customer + */ + protected $customer; + + /** + * @var \Magento\Log\Model\Customer + */ + protected $customerLog; + + /** + * @var \Magento\Log\Model\Visitor + */ + protected $modelLog; + + /** + * @var \Magento\Log\Model\CustomerFactory + */ + protected $logFactory; + + /** + * @var \Magento\Customer\Service\V1\Data\CustomerBuilder + */ + protected $customerBuilder; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Log\Model\CustomerFactory $logFactory + * @param \Magento\Log\Model\Log $modelLog + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Log\Model\CustomerFactory $logFactory, + \Magento\Log\Model\Log $modelLog, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, + array $data = array() + ) { + $this->logFactory = $logFactory; + $this->modelLog = $modelLog; + $this->dateTime = $dateTime; + $this->customerBuilder = $customerBuilder; + parent::__construct($context, $data); + } + + /** + * @return string + */ + public function getStoreLastLoginDateTimezone() + { + return $this->_scopeConfig->getValue( + $this->_localeDate->getDefaultTimezonePath(), + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getCustomer()->getStoreId() + ); + } + + /** + * @return \Magento\Customer\Service\V1\Data\Customer + */ + public function getCustomer() + { + if (!$this->customer) { + $this->customer = $this->customerBuilder->populateWithArray( + $this->_backendSession->getCustomerData()['account'] + )->create(); + } + return $this->customer; + } + + /** + * Get customer's current status + * + * @return string + */ + public function getCurrentStatus() + { + $log = $this->getCustomerLog(); + $interval = $this->modelLog->getOnlineMinutesInterval(); + if ($log->getLogoutAt() || + strtotime($this->dateTime->now()) - strtotime($log->getLastVisitAt()) > $interval * 60 + ) { + return __('Offline'); + } + return __('Online'); + } + + /** + * Get customer last login date + * + * @return string + */ + public function getLastLoginDate() + { + $date = $this->getCustomerLog()->getLoginAt(); + if ($date) { + return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); + } + return __('Never'); + } + + /** + * @return string + */ + public function getStoreLastLoginDate() + { + $date = $this->getCustomerLog()->getLoginAtTimestamp(); + if ($date) { + $date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true); + return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); + } + return __('Never'); + } + + /** + * Load Customer Log model + * + * @return \Magento\Log\Model\Customer + */ + public function getCustomerLog() + { + if (!$this->customerLog) { + $this->customerLog = $this->logFactory->create()->loadByCustomer($this->getCustomer()->getId()); + } + return $this->customerLog; + } +} diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online.php b/app/code/Magento/Log/Block/Adminhtml/Online.php similarity index 92% rename from app/code/Magento/Customer/Block/Adminhtml/Online.php rename to app/code/Magento/Log/Block/Adminhtml/Online.php index b7eaf9dd1d487d4288646ed8b9590f6d72eb4b6e..d488b0ea3584523f6b6b75c85b9892545b77cbae 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Customer\Block\Adminhtml; +namespace Magento\Log\Block\Adminhtml; /** * Adminhtml online customers page content block @@ -48,7 +48,7 @@ class Online extends \Magento\Backend\Block\Template */ protected function _prepareLayout() { - $this->addChild('filterForm', 'Magento\Customer\Block\Adminhtml\Online\Filter'); + $this->addChild('filterForm', 'Magento\Log\Block\Adminhtml\Online\Filter'); return parent::_prepareLayout(); } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online/Filter.php b/app/code/Magento/Log/Block/Adminhtml/Online/Filter.php similarity index 97% rename from app/code/Magento/Customer/Block/Adminhtml/Online/Filter.php rename to app/code/Magento/Log/Block/Adminhtml/Online/Filter.php index 247f96f518e17a9d96bca0cc91a5c99767ca7caf..2621c053cea957727cff1ec6e1fb20799dfa0497 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online/Filter.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online/Filter.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Customer\Block\Adminhtml\Online; +namespace Magento\Log\Block\Adminhtml\Online; /** * Adminhtml customers online filter diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Ip.php b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Ip.php similarity index 95% rename from app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Ip.php rename to app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Ip.php index 4f49679629635288bb27ddfc1f8b74003de42b0c..5d244b707aa0013a66a75d0c7bf46c6497c0bbe0 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Ip.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Ip.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Customer\Block\Adminhtml\Online\Grid\Renderer; +namespace Magento\Log\Block\Adminhtml\Online\Grid\Renderer; /** * Adminhtml customers online grid block item renderer by ip. diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Type.php b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Type.php similarity index 95% rename from app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Type.php rename to app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Type.php index 39bb982bc8e6e213f34ef84eb7e346fa1ab34aa4..edef644a2d600cd9f64bca918b20b340c6f98d80 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Type.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Type.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Customer\Block\Adminhtml\Online\Grid\Renderer; +namespace Magento\Log\Block\Adminhtml\Online\Grid\Renderer; /** * Adminhtml customers online grid renderer for customer type. diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Url.php b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Url.php similarity index 95% rename from app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Url.php rename to app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Url.php index 3d8cb77d2a88f3921ed3a3db34b85383092e7068..2e5d3ef0d9547f3b0c4bc2cce8a9589185e6c8dd 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Url.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Url.php @@ -22,14 +22,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Log\Block\Adminhtml\Online\Grid\Renderer; /** * Adminhtml Online Customer last URL renderer * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Online\Grid\Renderer; - class Url extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Online/Index.php b/app/code/Magento/Log/Controller/Adminhtml/Online/Index.php similarity index 92% rename from app/code/Magento/Customer/Controller/Adminhtml/Online/Index.php rename to app/code/Magento/Log/Controller/Adminhtml/Online/Index.php index dab423fbba51c2bc259b85407036d35da3c532bb..564ef7a9a03cdbc1f8735504327e27b4bd873040 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Online/Index.php +++ b/app/code/Magento/Log/Controller/Adminhtml/Online/Index.php @@ -22,7 +22,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Customer\Controller\Adminhtml\Online; +namespace Magento\Log\Controller\Adminhtml\Online; class Index extends \Magento\Backend\App\Action { @@ -31,7 +31,7 @@ class Index extends \Magento\Backend\App\Action */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Magento_Customer::online'); + return $this->_authorization->isAllowed('Magento_Log::online'); } /** diff --git a/app/code/Magento/Log/Model/Aggregation.php b/app/code/Magento/Log/Model/Aggregation.php index e2aff2868e858cc2904873a0fedab8562aa3f4e4..ab695cbad7c965122078cdd01c78c8bb28b4631c 100644 --- a/app/code/Magento/Log/Model/Aggregation.php +++ b/app/code/Magento/Log/Model/Aggregation.php @@ -41,14 +41,14 @@ class Aggregation extends \Magento\Framework\Model\AbstractModel protected $_lastRecord; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -56,7 +56,7 @@ class Aggregation extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Log/Model/Cron.php b/app/code/Magento/Log/Model/Cron.php index bfc4125ef5b39d2bd256ea0960a62c64aff7aa39..68ce14f15d3b8bd8c53ba360c8d0935cdd72461b 100644 --- a/app/code/Magento/Log/Model/Cron.php +++ b/app/code/Magento/Log/Model/Cron.php @@ -55,7 +55,7 @@ class Cron extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -79,7 +79,7 @@ class Cron extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Log\Model\Log $log - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -91,7 +91,7 @@ class Cron extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Log\Model\Log $log, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Log/Model/Log.php b/app/code/Magento/Log/Model/Log.php index 6ab9e33a0c1065834217f470f48716e62ad0e0de..a3841892b636513661d6a3493e0ccb04605bd6ab 100644 --- a/app/code/Magento/Log/Model/Log.php +++ b/app/code/Magento/Log/Model/Log.php @@ -45,6 +45,8 @@ class Log extends \Magento\Framework\Model\AbstractModel { const XML_LOG_CLEAN_DAYS = 'system/log/clean_after_day'; + const DEFAULT_ONLINE_MINUTES_INTERVAL = 15; + /** * Core store config * @@ -105,4 +107,18 @@ class Log extends \Magento\Framework\Model\AbstractModel $this->getResource()->clean($this); return $this; } + + /** + * Return Online Minutes Interval + * + * @return int Minutes Interval + */ + public function getOnlineMinutesInterval() + { + $configValue = $this->_scopeConfig->getValue( + 'customer/online_customers/online_minutes_interval', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + return intval($configValue) > 0 ? intval($configValue) : self::DEFAULT_ONLINE_MINUTES_INTERVAL; + } } diff --git a/app/code/Magento/Log/Model/Resource/Visitor.php b/app/code/Magento/Log/Model/Resource/Visitor.php index 4e8ef5ce019848e841b8039b8edfd2faa54460ba..dded53fd5cc02fd7063e864c700109852c7b8d8e 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor.php +++ b/app/code/Magento/Log/Model/Resource/Visitor.php @@ -28,6 +28,13 @@ namespace Magento\Log\Model\Resource; */ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb { + /** + * Primary key auto increment flag + * + * @var bool + */ + protected $_isPkAutoIncrement = false; + /** * Magento string lib * @@ -41,20 +48,20 @@ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_date; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime\DateTime $date - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\String $string */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\String $string ) { $this->_date = $date; @@ -82,7 +89,7 @@ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $visitor) { return array( - 'session_id' => $visitor->getSessionId(), + 'visitor_id' => $visitor->getVisitorId(), 'first_visit_at' => $visitor->getFirstVisitAt(), 'last_visit_at' => $visitor->getLastVisitAt(), 'last_url_id' => $visitor->getLastUrlId() ? $visitor->getLastUrlId() : 0, diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php index dcf29183f7bb3f55b9c0e732975e7c19f5d290cd..2ea289f812160682bcef8bc31903b0ed947f47f5 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php @@ -147,7 +147,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac { if ($fieldName == 'type' && is_array($condition) && isset($condition['eq'])) { $fieldName = 'customer_id'; - if ($condition['eq'] === \Magento\Log\Model\Visitor::VISITOR_TYPE_VISITOR) { + if ($condition['eq'] === \Magento\Customer\Model\Visitor::VISITOR_TYPE_VISITOR) { $condition = array('null' => 1); } else { $condition = array('moreq' => 1); diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online.php b/app/code/Magento/Log/Model/Resource/Visitor/Online.php index 5e9ef54f5a7a522c027be291a0231eecf44137fc..38dbffc2f36d3b185af8f5ee2f74ff078c9771f4 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Online.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Online.php @@ -24,7 +24,7 @@ namespace Magento\Log\Model\Resource\Visitor; /** - * Log Prepare Online visitors resource + * Log Prepare Online visitors resource * * @author Magento Core Team <core@magentocommerce.com> */ @@ -95,7 +95,7 @@ class Online extends \Magento\Framework\Model\Resource\Db\AbstractDb while ($row = $query->fetch()) { $visitors[$row['visitor_id']] = $row; $lastUrls[$row['last_url_id']] = $row['visitor_id']; - $visitors[$row['visitor_id']]['visitor_type'] = \Magento\Log\Model\Visitor::VISITOR_TYPE_VISITOR; + $visitors[$row['visitor_id']]['visitor_type'] = \Magento\Customer\Model\Visitor::VISITOR_TYPE_VISITOR; $visitors[$row['visitor_id']]['customer_id'] = null; } @@ -144,7 +144,7 @@ class Online extends \Magento\Framework\Model\Resource\Db\AbstractDb $query = $readAdapter->query($select); while ($row = $query->fetch()) { - $visitors[$row['visitor_id']]['visitor_type'] = \Magento\Log\Model\Visitor::VISITOR_TYPE_CUSTOMER; + $visitors[$row['visitor_id']]['visitor_type'] = \Magento\Customer\Model\Visitor::VISITOR_TYPE_CUSTOMER; $visitors[$row['visitor_id']]['customer_id'] = $row['customer_id']; } diff --git a/app/code/Magento/Log/Model/Visitor.php b/app/code/Magento/Log/Model/Visitor.php index f16f6e1acb9eab729d07dcc2d01967ee27abd6c6..ae58e1f065840c7ac1fc91a7c7511ebd5484b68c 100644 --- a/app/code/Magento/Log/Model/Visitor.php +++ b/app/code/Magento/Log/Model/Visitor.php @@ -24,83 +24,47 @@ namespace Magento\Log\Model; /** - * @method \Magento\Log\Model\Resource\Visitor _getResource() - * @method \Magento\Log\Model\Resource\Visitor getResource() + * @method Resource\Visitor _getResource() + * @method Resource\Visitor getResource() * @method string getSessionId() - * @method \Magento\Log\Model\Visitor setSessionId(string $value) - * @method \Magento\Log\Model\Visitor setFirstVisitAt(string $value) - * @method \Magento\Log\Model\Visitor setLastVisitAt(string $value) + * @method Visitor setSessionId(string $value) + * @method Visitor setFirstVisitAt(string $value) + * @method Visitor setLastVisitAt(string $value) + * @method Visitor setVisitorId(int $value) + * @method Visitor setIsNewVisitor(bool $value) + * @method Visitor getIsNewVisitor() + * @method Visitor getVisitorId() * @method int getLastUrlId() - * @method \Magento\Log\Model\Visitor setLastUrlId(int $value) + * @method Visitor setLastUrlId(int $value) * @method int getStoreId() - * @method \Magento\Log\Model\Visitor setStoreId(int $value) + * @method Visitor setStoreId(int $value) */ class Visitor extends \Magento\Framework\Model\AbstractModel { - const DEFAULT_ONLINE_MINUTES_INTERVAL = 15; - - const VISITOR_TYPE_CUSTOMER = 'c'; - - const VISITOR_TYPE_VISITOR = 'v'; - - /** - * @var bool - */ - protected $_skipRequestLogging = false; - - /** - * @var string[] - */ - protected $_ignoredUserAgents; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - - /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_coreConfig; - /** - * Ignored Modules - * - * @var array + * @var \Magento\Framework\StoreManagerInterface */ - protected $_ignores; - - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $_storeManager; + protected $storeManager; /** * @var \Magento\Framework\Session\SessionManagerInterface */ - protected $_session; - - /** - * @var \Magento\Sales\Model\QuoteFactory - */ - protected $_quoteFactory; + protected $session; /** * @var \Magento\Framework\HTTP\Header */ - protected $_httpHeader; + protected $httpHeader; /** * @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress */ - protected $_remoteAddress; + protected $remoteAddress; /** * @var \Magento\Framework\HTTP\PhpEnvironment\ServerAddress */ - protected $_serverAddress; + protected $serverAddress; /** * @var \Magento\Framework\Stdlib\DateTime @@ -110,54 +74,37 @@ class Visitor extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Framework\Session\SessionManagerInterface $session - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\HTTP\Header $httpHeader * @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress * @param \Magento\Framework\HTTP\PhpEnvironment\ServerAddress $serverAddress * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection - * @param array $ignoredUserAgents - * @param array $ignores * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Framework\Session\SessionManagerInterface $session, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\HTTP\Header $httpHeader, \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, \Magento\Framework\HTTP\PhpEnvironment\ServerAddress $serverAddress, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Module\Manager $moduleManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, - array $ignoredUserAgents = array(), - array $ignores = array(), array $data = array() ) { - $this->_scopeConfig = $scopeConfig; - $this->_quoteFactory = $quoteFactory; - $this->_session = $session; - $this->_storeManager = $storeManager; - $this->_coreConfig = $coreConfig; - $this->_ignoredUserAgents = $ignoredUserAgents; - $this->_httpHeader = $httpHeader; - $this->_remoteAddress = $remoteAddress; - $this->_serverAddress = $serverAddress; + $this->session = $session; + $this->storeManager = $storeManager; + $this->httpHeader = $httpHeader; + $this->remoteAddress = $remoteAddress; + $this->serverAddress = $serverAddress; $this->dateTime = $dateTime; parent::__construct($context, $registry, $resource, $resourceCollection, $data); - $this->_ignores = $ignores; } /** @@ -168,12 +115,6 @@ class Visitor extends \Magento\Framework\Model\AbstractModel protected function _construct() { $this->_init('Magento\Log\Model\Resource\Visitor'); - $userAgent = $this->_httpHeader->getHttpUserAgent(); - if ($this->_ignoredUserAgents) { - if (in_array($userAgent, $this->_ignoredUserAgents)) { - $this->_skipRequestLogging = true; - } - } } /** @@ -183,18 +124,7 @@ class Visitor extends \Magento\Framework\Model\AbstractModel */ protected function _getSession() { - return $this->_session; - } - - /** - * Skip request logging - * - * @param bool $skipRequestLogging - * @return void - */ - public function setSkipRequestLogging($skipRequestLogging) - { - $this->_skipRequestLogging = (bool)$skipRequestLogging; + return $this->session; } /** @@ -207,36 +137,21 @@ class Visitor extends \Magento\Framework\Model\AbstractModel $clean = true; $this->addData( array( - 'server_addr' => $this->_serverAddress->getServerAddress(true), - 'remote_addr' => $this->_remoteAddress->getRemoteAddress(true), - 'http_secure' => $this->_storeManager->getStore()->isCurrentlySecure(), - 'http_host' => $this->_httpHeader->getHttpHost($clean), - 'http_user_agent' => $this->_httpHeader->getHttpUserAgent($clean), - 'http_accept_language' => $this->_httpHeader->getHttpAcceptLanguage($clean), - 'http_accept_charset' => $this->_httpHeader->getHttpAcceptCharset($clean), - 'request_uri' => $this->_httpHeader->getRequestUri($clean), - 'session_id' => $this->_getSession()->getSessionId(), - 'http_referer' => $this->_httpHeader->getHttpReferer($clean) + 'server_addr' => $this->serverAddress->getServerAddress(true), + 'remote_addr' => $this->remoteAddress->getRemoteAddress(true), + 'http_secure' => $this->storeManager->getStore()->isCurrentlySecure(), + 'http_host' => $this->httpHeader->getHttpHost($clean), + 'http_user_agent' => $this->httpHeader->getHttpUserAgent($clean), + 'http_accept_language' => $this->httpHeader->getHttpAcceptLanguage($clean), + 'http_accept_charset' => $this->httpHeader->getHttpAcceptCharset($clean), + 'request_uri' => $this->httpHeader->getRequestUri($clean), + 'http_referer' => $this->httpHeader->getHttpReferer($clean) ) ); return $this; } - /** - * Return Online Minutes Interval - * - * @return int Minutes Interval - */ - public function getOnlineMinutesInterval() - { - $configValue = $this->_scopeConfig->getValue( - 'customer/online_customers/online_minutes_interval', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); - return intval($configValue) > 0 ? intval($configValue) : self::DEFAULT_ONLINE_MINUTES_INTERVAL; - } - /** * Retrieve url from model data * @@ -283,21 +198,15 @@ class Visitor extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Event\Observer $observer * @return \Magento\Log\Model\Visitor */ - public function initByRequest($observer) + public function logNewVisitor($observer) { - if ($this->_skipRequestLogging || $this->isModuleIgnored($observer)) { - return $this; - } - - $this->setData($this->_getSession()->getVisitorData()); + $visitor = $observer->getEvent()->getVisitor(); + $this->setData($visitor->getData()); $this->initServerData(); - - if (!$this->getId()) { - $this->setFirstVisitAt($this->dateTime->now()); - $this->setIsNewVisitor(true); - $this->save(); - $this->_eventManager->dispatch('visitor_init', array('visitor' => $this)); - } + $this->setFirstVisitAt($this->dateTime->now()); + $this->setIsNewVisitor(true); + $this->save(); + $visitor->setData($this->getData()); return $this; } @@ -309,130 +218,20 @@ class Visitor extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Event\Observer $observer * @return \Magento\Log\Model\Visitor */ - public function saveByRequest($observer) + public function logVisitorActivity($observer) { - if ($this->_skipRequestLogging || $this->isModuleIgnored($observer)) { - return $this; - } - + $visitor = $observer->getEvent()->getVisitor(); try { - $this->setLastVisitAt($this->dateTime->now()); - $this->save(); - $this->_getSession()->setVisitorData($this->getData()); + $this->setData($visitor->getData()); + if ($this->getId() && $this->getVisitorId()) { + $this->initServerData(); + $this->setLastVisitAt($this->dateTime->now()); + $this->save(); + $visitor->setData($this->getData()); + } } catch (\Exception $e) { $this->_logger->logException($e); } return $this; } - - /** - * Bind customer data when customer login - * - * Used in event "customer_login" - * - * @param \Magento\Framework\Event\Observer $observer - * @return \Magento\Log\Model\Visitor - */ - public function bindCustomerLogin($observer) - { - /** @var \Magento\Customer\Service\V1\Data\Customer $customer */ - $customer = $observer->getEvent()->getCustomer(); - if (!$this->getCustomerId()) { - $this->setDoCustomerLogin(true); - $this->setCustomerId($customer->getId()); - } - } - - /** - * Bind customer data when customer logout - * - * Used in event "customer_logout" - * - * @param \Magento\Framework\Event\Observer $observer - * @return \Magento\Log\Model\Visitor - */ - public function bindCustomerLogout($observer) - { - if ($this->getCustomerId()) { - $this->setDoCustomerLogout(true); - } - } - - /** - * Create binding of checkout quote - * - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function bindQuoteCreate($observer) - { - $quote = $observer->getEvent()->getQuote(); - if ($quote) { - if ($quote->getIsCheckoutCart()) { - $this->setQuoteId($quote->getId()); - $this->setDoQuoteCreate(true); - } - } - return $this; - } - - /** - * Destroy binding of checkout quote - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function bindQuoteDestroy($observer) - { - $quote = $observer->getEvent()->getQuote(); - if ($quote) { - $this->setDoQuoteDestroy(true); - } - return $this; - } - - /** - * Methods for research (depends from customer online admin section) - * - * @param array $data - * @return $this - */ - public function addIpData($data) - { - $ipData = array(); - $data->setIpData($ipData); - return $this; - } - - /** - * Load quote data into $data - * - * @param object $data - * @return $this - */ - public function addQuoteData($data) - { - $quoteId = $data->getQuoteId(); - if (intval($quoteId) <= 0) { - return $this; - } - $data->setQuoteData($this->_quoteFactory->create()->load($quoteId)); - return $this; - } - - /** - * Returns true if the module is required - * - * @param \Magento\Framework\Event\Observer $observer - * @return bool - */ - public function isModuleIgnored($observer) - { - if (is_array($this->_ignores) && $observer) { - $curModule = $observer->getEvent()->getControllerAction()->getRequest()->getRouteName(); - if (isset($this->_ignores[$curModule])) { - return true; - } - } - return false; - } } diff --git a/app/code/Magento/Log/Model/Visitor/Online.php b/app/code/Magento/Log/Model/Visitor/Online.php index de4b28b329432e2a31a20dd3d206822908ebca00..637bedfc7f4b4e14f03b19e7d433f0bb6aaf8bab 100644 --- a/app/code/Magento/Log/Model/Visitor/Online.php +++ b/app/code/Magento/Log/Model/Visitor/Online.php @@ -158,7 +158,7 @@ class Online extends \Magento\Framework\Model\AbstractModel ) ); if (!$value) { - $value = \Magento\Log\Model\Visitor::DEFAULT_ONLINE_MINUTES_INTERVAL; + $value = \Magento\Log\Model\Log::DEFAULT_ONLINE_MINUTES_INTERVAL; } return $value; } diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index 3af9521f0a166e6f2620ce7ed3b336025465183e..1a2c5bb38194cc2416d24662d701ccb8689a34b7 100644 --- a/app/code/Magento/Log/composer.json +++ b/app/code/Magento/Log/composer.json @@ -3,17 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Log/etc/acl.xml b/app/code/Magento/Log/etc/acl.xml new file mode 100644 index 0000000000000000000000000000000000000000..19a7be98f3ab70065a5cb918686f11581638e454 --- /dev/null +++ b/app/code/Magento/Log/etc/acl.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> + <acl> + <resources> + <resource id="Magento_Adminhtml::admin"> + <resource id="Magento_Customer::customer"> + <resource id="Magento_Log::online" title="Now Online" sortOrder="20" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/Magento/Install/etc/frontend/routes.xml b/app/code/Magento/Log/etc/adminhtml/menu.xml similarity index 77% rename from app/code/Magento/Install/etc/frontend/routes.xml rename to app/code/Magento/Log/etc/adminhtml/menu.xml index 0a76f3dab22ba0576c50ebe7542ae95ac1615d74..7e9f8a1691c12e12d39026919af09b09beb942a7 100644 --- a/app/code/Magento/Install/etc/frontend/routes.xml +++ b/app/code/Magento/Log/etc/adminhtml/menu.xml @@ -23,10 +23,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd"> - <router id="standard"> - <route id="install" frontName="install"> - <module name="Magento_Install" /> - </route> - </router> -</config> \ No newline at end of file +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd"> + <menu> + <add id="Magento_Log::visitor_online" title="Now Online" module="Magento_Log" sortOrder="30" parent="Magento_Customer::customer" action="visitor/online" resource="Magento_Log::online"/> + </menu> +</config> diff --git a/app/code/Magento/Install/etc/adminhtml/routes.xml b/app/code/Magento/Log/etc/adminhtml/routes.xml similarity index 91% rename from app/code/Magento/Install/etc/adminhtml/routes.xml rename to app/code/Magento/Log/etc/adminhtml/routes.xml index 6561687d7773fb8250d0755ce934e75471934e24..42b1cd19d43c4445e7f8ba81a53ad227c0942d05 100644 --- a/app/code/Magento/Install/etc/adminhtml/routes.xml +++ b/app/code/Magento/Log/etc/adminhtml/routes.xml @@ -25,8 +25,8 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd"> <router id="admin"> - <route id="adminhtml"> - <module name="Magento_Install" before="Magento_Adminhtml" /> + <route id="visitor" frontName="visitor"> + <module name="Magento_Log" /> </route> </router> </config> diff --git a/app/code/Magento/Log/etc/adminhtml/system.xml b/app/code/Magento/Log/etc/adminhtml/system.xml index 439095e613d20a8284e5bb8fe1f358c2e5116ce6..23868256a5c08529cd32679cdd17503a0525c549 100644 --- a/app/code/Magento/Log/etc/adminhtml/system.xml +++ b/app/code/Magento/Log/etc/adminhtml/system.xml @@ -25,6 +25,15 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/system_file.xsd"> <system> + <section id="customer" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1"> + <group id="online_customers" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Online Customers Options</label> + <field id="online_minutes_interval" translate="label comment" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Online Minutes Interval</label> + <comment>Leave empty for default (15 minutes).</comment> + </field> + </group> + </section> <section id="system"> <group id="log" translate="label" type="text" sortOrder="200" showInDefault="1" showInWebsite="0" showInStore="0"> <label>Log Cleaning</label> diff --git a/app/code/Magento/Log/etc/di.xml b/app/code/Magento/Log/etc/di.xml index 2a45826caf27d53467a4e3ec7253f7dea9c61bab..87c4ef9d486e938a134ccfac359e1987d86bc4bd 100644 --- a/app/code/Magento/Log/etc/di.xml +++ b/app/code/Magento/Log/etc/di.xml @@ -29,13 +29,4 @@ <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManager\Proxy</argument> </arguments> </type> - <type name="Magento\Log\Model\Visitor"> - <arguments> - <argument name="ignoredUserAgents" xsi:type="array"> - <item name="google1" xsi:type="string">Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/)</item> - <item name="google2" xsi:type="string">Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</item> - <item name="google3" xsi:type="string">Googlebot/2.1 (+http://www.googlebot.com/bot.html)</item> - </argument> - </arguments> - </type> </config> diff --git a/app/code/Magento/Log/etc/frontend/events.xml b/app/code/Magento/Log/etc/frontend/events.xml index f8eae9512b1142fb766ff4bbac67b1565ed2b3f3..484ea6a536e7d91be88c2d2ef97328c914a838fd 100644 --- a/app/code/Magento/Log/etc/frontend/events.xml +++ b/app/code/Magento/Log/etc/frontend/events.xml @@ -24,22 +24,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> - <event name="controller_action_predispatch"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="initByRequest" /> + <event name="visitor_init"> + <observer name="log" instance="Magento\Log\Model\Visitor" method="logNewVisitor" /> </event> - <event name="controller_action_postdispatch"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="saveByRequest" /> - </event> - <event name="customer_data_object_login"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="bindCustomerLogin" /> - </event> - <event name="customer_logout"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="bindCustomerLogout" /> - </event> - <event name="sales_quote_save_after"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="bindQuoteCreate" /> - </event> - <event name="checkout_quote_destroy"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="bindQuoteDestroy" /> + <event name="visitor_activity_save"> + <observer name="log" instance="Magento\Log\Model\Visitor" method="logVisitorActivity" /> </event> </config> diff --git a/app/code/Magento/Log/etc/module.xml b/app/code/Magento/Log/etc/module.xml index f9ec0aeae871ecc6babb00b51ecbc2fd8a9cf80d..068b3a77f6a52aa17e4cf93e260faf3990d369bb 100644 --- a/app/code/Magento/Log/etc/module.xml +++ b/app/code/Magento/Log/etc/module.xml @@ -35,7 +35,6 @@ <module name="Magento_Core"/> <module name="Magento_Customer"/> <module name="Magento_Eav"/> - <module name="Magento_Sales"/> <module name="Magento_Backend"/> </depends> </module> diff --git a/app/code/Magento/Log/i18n/de_DE.csv b/app/code/Magento/Log/i18n/de_DE.csv index a0b3a6563e884049f5af55e332b7dad882b5c9c4..6bca6e7ceca1d5c0c8182e3f8d637d5f83bb3692 100644 --- a/app/code/Magento/Log/i18n/de_DE.csv +++ b/app/code/Magento/Log/i18n/de_DE.csv @@ -6,3 +6,8 @@ Frequency,Frequenz "Log Cleaning","Aufräumen des Verlaufs" "Save Log, Days","Speichere Verlauf, Tage" "Enable Log Cleaning","Aufräumen des Verlaufs anschalten" +Online,Online +"Customers Now Online","Customers Now Online" +"Online Customers",Online-Kunden +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/en_US.csv b/app/code/Magento/Log/i18n/en_US.csv index 3ef19efb16ca22264ee7cadfb3dbc81c31e10a4e..4db797aec00a5f4799aa5a77519fcfdbbb6ad028 100644 --- a/app/code/Magento/Log/i18n/en_US.csv +++ b/app/code/Magento/Log/i18n/en_US.csv @@ -6,3 +6,8 @@ Frequency,Frequency "Log Cleaning","Log Cleaning" "Save Log, Days","Save Log, Days" "Enable Log Cleaning","Enable Log Cleaning" +"Customers Now Online","Customers Now Online" +Online,Online +"Online Customers","Online Customers" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/es_ES.csv b/app/code/Magento/Log/i18n/es_ES.csv index 4235ce8fc77662e510c40d9aa9eb4d7cfe6fd37b..d9c1ce5abda5663410cb515307c4e6fb0d5d1dac 100644 --- a/app/code/Magento/Log/i18n/es_ES.csv +++ b/app/code/Magento/Log/i18n/es_ES.csv @@ -6,3 +6,8 @@ Frequency,Frecuencia "Log Cleaning","Limpieza de registros" "Save Log, Days","Guardar registro (dÃas)" "Enable Log Cleaning","Activar limpieza de registros" +Online,Conectado +"Customers Now Online","Customers Now Online" +"Online Customers","Clientes conectados" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/fr_FR.csv b/app/code/Magento/Log/i18n/fr_FR.csv index b5cc876151c4327cc23870ee1f50db9f8e4661bf..2e38a7eede332f35e03f9bcca8a761170e27440a 100644 --- a/app/code/Magento/Log/i18n/fr_FR.csv +++ b/app/code/Magento/Log/i18n/fr_FR.csv @@ -6,3 +6,8 @@ Frequency,Fréquence "Log Cleaning","Effacement des logs" "Save Log, Days","Enregistrer logs, jours" "Enable Log Cleaning","Activer l'effacement des logs" +Online,"En ligne" +"Customers Now Online","Customers Now Online" +"Online Customers","Utilisateurs en ligne" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/nl_NL.csv b/app/code/Magento/Log/i18n/nl_NL.csv index 79b61bb74235384ce5a12ec6bd1bbd228833f2d4..2b67d714f0e9851fb2836e94f834ec9c39bbf897 100644 --- a/app/code/Magento/Log/i18n/nl_NL.csv +++ b/app/code/Magento/Log/i18n/nl_NL.csv @@ -6,3 +6,8 @@ Frequency,Frequentie "Log Cleaning","Log aan het schonen" "Save Log, Days","Log opslaan, dagen" "Enable Log Cleaning","Schonen van log toestaan" +Online,Online +"Customers Now Online","Customers Now Online" +"Online Customers","Online Klanten" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/pt_BR.csv b/app/code/Magento/Log/i18n/pt_BR.csv index 6f2c8ab8e44e41ab4425e97530a3b7a18cfd4f58..a8120528e30d919dcffeb348fcfdb969d31911c6 100644 --- a/app/code/Magento/Log/i18n/pt_BR.csv +++ b/app/code/Magento/Log/i18n/pt_BR.csv @@ -6,3 +6,9 @@ Frequency,Freqüência "Log Cleaning","Limpeza de Registro" "Save Log, Days","Salvar Registro, Dias" "Enable Log Cleaning","Ativar Limpeza de Registro" +Online,Online +"Customers Now Online","Customers Now Online" +"Online Customers","Clientes Conectados" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" + diff --git a/app/code/Magento/Log/i18n/zh_CN.csv b/app/code/Magento/Log/i18n/zh_CN.csv index 72a7f3132d43248880312e4c0a4c1a9ae75861c8..26c5dc7ad755274fc0edcdc6f2a0f1bbd0e3f715 100644 --- a/app/code/Magento/Log/i18n/zh_CN.csv +++ b/app/code/Magento/Log/i18n/zh_CN.csv @@ -6,3 +6,8 @@ Frequency,频率 "Log Cleaning",æ—¥å¿—æ¸…ç† "Save Log, Days",ä¿å˜æ—¥å¿—,天 "Enable Log Cleaning",å¯ç”¨æ—¥å¿—æ¸…ç† +Online,在线 +"Customers Now Online","Customers Now Online" +"Online Customers",在线客户 +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/sql/log_setup/install-1.6.0.0.php b/app/code/Magento/Log/sql/log_setup/install-1.6.0.0.php index 943671375bad872a48bf282ef69733c602ceb6a7..35be24be9ccbee2a7472a4932e524ee9754e7999 100644 --- a/app/code/Magento/Log/sql/log_setup/install-1.6.0.0.php +++ b/app/code/Magento/Log/sql/log_setup/install-1.6.0.0.php @@ -260,12 +260,6 @@ $table = $installer->getConnection()->newTable( null, array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), 'Visitor ID' -)->addColumn( - 'session_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 64, - array('nullable' => true, 'default' => null), - 'Session ID' )->addColumn( 'first_visit_at', \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, @@ -294,6 +288,15 @@ $table = $installer->getConnection()->newTable( 'Log Visitors Table' ); $installer->getConnection()->createTable($table); +$installer->getConnection()->addForeignKey( + $installer->getFkName('log_visitor', 'visitor_id', 'customer_visitor', 'visitor_id'), + $installer->getTable('log_visitor'), + 'visitor_id', + $installer->getTable('customer_visitor'), + 'visitor_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE +); /** * Create table 'log_visitor_info' diff --git a/app/code/Magento/Log/view/adminhtml/layout/customer_index_edit.xml b/app/code/Magento/Log/view/adminhtml/layout/customer_index_edit.xml new file mode 100644 index 0000000000000000000000000000000000000000..ceb709e78325426b124e63ec769f2484ccb26933 --- /dev/null +++ b/app/code/Magento/Log/view/adminhtml/layout/customer_index_edit.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="personal_info"> + <block class="Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status" name="view_customer_status" template="customer/status.phtml"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_online_index.xml b/app/code/Magento/Log/view/adminhtml/layout/customer_online_index.xml similarity index 95% rename from app/code/Magento/Customer/view/adminhtml/layout/customer_online_index.xml rename to app/code/Magento/Log/view/adminhtml/layout/customer_online_index.xml index 9adff30add807e19171e87fecae77179990b1ac9..e54d025b6cfd2df905de55b09c0d94ffa422bc88 100644 --- a/app/code/Magento/Customer/view/adminhtml/layout/customer_online_index.xml +++ b/app/code/Magento/Log/view/adminhtml/layout/customer_online_index.xml @@ -25,8 +25,8 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceContainer name="content"> - <block class="Magento\Customer\Block\Adminhtml\Online" name="adminhtml.block.customer.online.grid.container"> - <block class="Magento\Backend\Block\Widget\Grid" name="adminhtml.block.customer.online.grid" as="grid"> + <block class="Magento\Log\Block\Adminhtml\Online" name="adminhtml.block.log.online.grid.container"> + <block class="Magento\Backend\Block\Widget\Grid" name="adminhtml.block.log.online.grid" as="grid"> <arguments> <argument name="id" xsi:type="string">onlineGrid</argument> <argument name="dataSource" xsi:type="object">Magento\Log\Model\Resource\Visitor\Online\Grid\Collection</argument> @@ -34,7 +34,7 @@ <argument name="default_dir" xsi:type="string">DESC</argument> <argument name="save_parameters_in_session" xsi:type="string">1</argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="adminhtml.customer.online.grid.columnSet"> + <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="adminhtml.log.online.grid.columnSet"> <arguments> <argument name="rowUrl" xsi:type="array"> <item name="generatorClass" xsi:type="string">Magento\Log\Model\Resource\Visitor\Online\Grid\Row\UrlGenerator</item> @@ -80,7 +80,7 @@ <argument name="header" xsi:type="string" translate="true">IP Address</argument> <argument name="default" xsi:type="string">n/a</argument> <argument name="filter" xsi:type="string">0</argument> - <argument name="renderer" xsi:type="string">Magento\Customer\Block\Adminhtml\Online\Grid\Renderer\Ip</argument> + <argument name="renderer" xsi:type="string">Magento\Log\Block\Adminhtml\Online\Grid\Renderer\Ip</argument> <argument name="index" xsi:type="string">remote_addr</argument> </arguments> </block> @@ -119,7 +119,7 @@ <argument name="linelength" xsi:type="string">60</argument> <argument name="type" xsi:type="string">wrapline</argument> <argument name="index" xsi:type="string">last_url</argument> - <argument name="renderer" xsi:type="string">Magento\Customer\Block\Adminhtml\Online\Grid\Renderer\Url</argument> + <argument name="renderer" xsi:type="string">Magento\Log\Block\Adminhtml\Online\Grid\Renderer\Url</argument> </arguments> </block> </block> diff --git a/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml b/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml new file mode 100644 index 0000000000000000000000000000000000000000..451742bc1bf9c7d4a5ea69cd31822f5afb8ea990 --- /dev/null +++ b/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml @@ -0,0 +1,41 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/** + * Template for block \Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status + */ + +$lastLoginDateAdmin = $this->getLastLoginDate(); +$lastLoginDateStore = $this->getStoreLastLoginDate(); +?> +<tr> + <th><?php echo __('Last Logged In:') ?></th> + <td><?php echo $lastLoginDateAdmin ?> (<?php echo $this->getCurrentStatus() ?>)</td> +</tr> +<?php if ($lastLoginDateAdmin != $lastLoginDateStore): ?> +<tr> + <th><?php echo __('Last Logged In (%1):', $this->getStoreLastLoginDateTimezone()) ?></th> + <td><?php echo $lastLoginDateStore ?> (<?php echo $this->getCurrentStatus() ?>)</td> +</tr> +<?php endif; ?> diff --git a/app/code/Magento/Customer/view/adminhtml/templates/online.phtml b/app/code/Magento/Log/view/adminhtml/templates/online.phtml similarity index 100% rename from app/code/Magento/Customer/view/adminhtml/templates/online.phtml rename to app/code/Magento/Log/view/adminhtml/templates/online.phtml diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address.php b/app/code/Magento/Multishipping/Controller/Checkout/Address.php index 27729eb2ab34664034e1b8fc5e6eee0ff42e0850..b9a18c154f4a9762f757fc6c712d9f133fe0ec38 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address.php @@ -28,6 +28,17 @@ namespace Magento\Multishipping\Controller\Checkout; */ class Address extends \Magento\Framework\App\Action\Action { + /** + * {@inheritdoc} + */ + public function dispatch(\Magento\Framework\App\RequestInterface $request) + { + if (!$this->_getCheckout()->getCustomer()->getId()) { + return $this->_redirect('customer/account/login'); + } + return parent::dispatch($request); + } + /** * Retrieve multishipping checkout model * diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index c5a34e64e590dd78c9dd7fdd0e74740ba8c20304..f69ff209750a714e4590c7d3bd4dd2a5d6d6617c 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -58,7 +58,7 @@ class Multishipping extends \Magento\Framework\Object protected $_session; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -119,7 +119,7 @@ class Multishipping extends \Magento\Framework\Object * @param \Magento\Framework\Session\Generic $session * @param \Magento\Sales\Model\Quote\AddressFactory $addressFactory * @param \Magento\Sales\Model\Convert\Quote $quote - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification * @param \Magento\Multishipping\Helper\Data $helper * @param OrderSender $orderSender @@ -135,7 +135,7 @@ class Multishipping extends \Magento\Framework\Object \Magento\Framework\Session\Generic $session, \Magento\Sales\Model\Quote\AddressFactory $addressFactory, \Magento\Sales\Model\Convert\Quote $quote, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, \Magento\Multishipping\Helper\Data $helper, OrderSender $orderSender, diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index 2377b2adb3da7151f7ee1aaf2f0616f572b0e388..d7b017fc380de2959325fed2bc06e7d4b6b125f6 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-weee": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-weee": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php index 8dfd30fb797b6b9e68c326fd9b360a973a6678f6..bea838371cc891ba5e1fb3d6c752412e3095db32 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php @@ -46,7 +46,7 @@ class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select protected $_coreRegistry; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -59,7 +59,7 @@ class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select * @param \Magento\Backend\Block\Context $context * @param \Magento\Framework\DB\Helper $resourceHelper * @param \Magento\Store\Model\Resource\Website\CollectionFactory $websitesFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -67,7 +67,7 @@ class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select \Magento\Backend\Block\Context $context, \Magento\Framework\DB\Helper $resourceHelper, \Magento\Store\Model\Resource\Website\CollectionFactory $websitesFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/Newsletter/Controller/Manage.php b/app/code/Magento/Newsletter/Controller/Manage.php index 15e28665c013d2d0b5218a126741d8c17e7bc54b..383d55923fa42c30c6571a7ac241cae987007f48 100644 --- a/app/code/Magento/Newsletter/Controller/Manage.php +++ b/app/code/Magento/Newsletter/Controller/Manage.php @@ -43,7 +43,7 @@ class Manage extends \Magento\Framework\App\Action\Action protected $_formKeyValidator; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -71,7 +71,7 @@ class Manage extends \Magento\Framework\App\Action\Action * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder @@ -81,7 +81,7 @@ class Manage extends \Magento\Framework\App\Action\Action \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, diff --git a/app/code/Magento/Newsletter/Controller/Subscriber.php b/app/code/Magento/Newsletter/Controller/Subscriber.php index e8f68a670c97444a1315297e15223b18367a2887..9001261460777c6e0d57a9ca6a682ed1ce6bc4a0 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber.php @@ -28,7 +28,7 @@ namespace Magento\Newsletter\Controller; use Magento\Framework\App\Action\Context; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Customer\Model\Session; use Magento\Customer\Service\V1\CustomerAccountServiceInterface; use Magento\Newsletter\Model\SubscriberFactory; @@ -58,7 +58,7 @@ class Subscriber extends \Magento\Framework\App\Action\Action protected $_subscriberFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 95d4ae9a6efa3e03d3fd5329497a59de400eed68..317bec2b0d6ae0dc073510fa79a54ac583c2c8a7 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -133,7 +133,7 @@ class Queue extends \Magento\Email\Model\AbstractTemplate * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Newsletter\Model\Template\Filter $templateFilter * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime\DateTime $date @@ -148,7 +148,7 @@ class Queue extends \Magento\Email\Model\AbstractTemplate \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Core\Model\App\Emulation $appEmulation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Newsletter\Model\Template\Filter $templateFilter, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime\DateTime $date, diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index ed26646c3fa58c48e1fcfa5d7d5006c70140b5a2..80222fc5278c43841a724c65dfe4e4e3b74a5270 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -113,7 +113,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -140,7 +140,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel * @param \Magento\Newsletter\Helper\Data $newsletterData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation @@ -154,7 +154,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel \Magento\Newsletter\Helper\Data $newsletterData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, CustomerAccountServiceInterface $customerAccountService, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index 1ed8bfa930b5d4601c59127693722f08e4d945e0..c3668c56c4146e77dd523659fd6c2dab46639b0a 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -70,7 +70,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate /** * Store manager to emulate design * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -112,7 +112,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Newsletter\Model\Template\Filter $filter * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -125,7 +125,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Core\Model\App\Emulation $appEmulation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Newsletter\Model\Template\Filter $filter, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 3fa4085a1e19fe476148c4da8162398db3ab3985..01d876cb1f21fc3729995b260157ac8a77f685c2 100644 --- a/app/code/Magento/Newsletter/composer.json +++ b/app/code/Magento/Newsletter/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-email": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-email": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/etc/frontend/di.xml b/app/code/Magento/Newsletter/etc/frontend/di.xml index aeac870fe3165f9f522c62967f517da73d5f00f2..fc6e1f3bf2296e93e52e229cf02f6f7000e4539d 100644 --- a/app/code/Magento/Newsletter/etc/frontend/di.xml +++ b/app/code/Magento/Newsletter/etc/frontend/di.xml @@ -24,11 +24,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Newsletter\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 0e4dd8689f63c9d8dd80021704e57c77f85f5acd..9a025f1dbaa6a0d84a06cb2788f0dc3b102cc31a 100644 --- a/app/code/Magento/OfflinePayments/composer.json +++ b/app/code/Magento/OfflinePayments/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-payment": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-payment": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php b/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php index 19468bff577504b0f5c94c5f4f7193a7aa2cea08..4a8cea06b6e59a73cfca67018b584dfefb95bd00 100644 --- a/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php +++ b/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php @@ -35,7 +35,7 @@ class ExportTablerates extends \Magento\Backend\Controller\Adminhtml\System\Abst protected $_fileFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -44,14 +44,14 @@ class ExportTablerates extends \Magento\Backend\Controller\Adminhtml\System\Abst * @param \Magento\Backend\Model\Config\Structure $configStructure * @param ConfigSectionChecker $sectionChecker * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\Config\Structure $configStructure, ConfigSectionChecker $sectionChecker, \Magento\Framework\App\Response\Http\FileFactory $fileFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; $this->_fileFactory = $fileFactory; diff --git a/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php b/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php index 3fca91e99719c34c780ca5f265be7d0a53349485..0ec117b58df8d8f092da16f340fa0e9263bada28 100644 --- a/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php +++ b/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php @@ -35,16 +35,16 @@ class Freeshipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTota protected $_calculator; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\OfflineShipping\Model\SalesRule\Calculator $calculator */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\OfflineShipping\Model\SalesRule\Calculator $calculator ) { $this->setCode('discount'); diff --git a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php index d906e963b355af756e8141c81742eb4df751a6bf..57b8b45a52200f45bea78332c8d02ac3e1710b64 100644 --- a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php @@ -106,7 +106,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_logger; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -136,7 +136,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory @@ -146,7 +146,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb \Magento\Framework\App\Resource $resource, \Magento\Framework\Logger $logger, \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate, \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory, \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory, diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 6297d766a263333c171e4a8667b7471acbb4c027..03fa0cfd628ab606189cfb69e7c186b7ad3abfc8 100644 --- a/app/code/Magento/OfflineShipping/composer.json +++ b/app/code/Magento/OfflineShipping/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-sales-rule": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-sales-rule": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Ogone/Model/Api.php b/app/code/Magento/Ogone/Model/Api.php index b64d69376bddcf334c96f8df2867d3d202dfd7ce..91536ad42d4054d834e8c03ca85564fd8612c2de 100644 --- a/app/code/Magento/Ogone/Model/Api.php +++ b/app/code/Magento/Ogone/Model/Api.php @@ -462,7 +462,7 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod protected $_urlBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -476,7 +476,7 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\Stdlib\String $string @@ -488,7 +488,7 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\Stdlib\String $string, diff --git a/app/code/Magento/Ogone/composer.json b/app/code/Magento/Ogone/composer.json index 474001ab844edbb86f7f1f76e6553af72fffaeb6..c6baf06222845bfcd6c83d407f6e9f803bb3b3b1 100644 --- a/app/code/Magento/Ogone/composer.json +++ b/app/code/Magento/Ogone/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php b/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php index 3234af5463d3d55252ef39dd555397e8ed42367b..624b9e1e3d9b6c67cc5f91da7780c1bd70592e8c 100644 --- a/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php +++ b/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php @@ -110,7 +110,8 @@ class MessageBox if ($this->request->isPost() && $this->messageManager->hasMessages()) { $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() ->setDuration(self::COOKIE_PERIOD) - ->setPath('/'); + ->setPath('/') + ->setHttpOnly(false); $this->cookieManager->setPublicCookie(self::COOKIE_NAME, 1, $publicCookieMetadata); } return $response; diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index 18b296cd9577ac2808e31a349b5215c31cd7664a..0dda6829dd4f262091f94586c9d3616e577eef83 100644 --- a/app/code/Magento/PageCache/composer.json +++ b/app/code/Magento/PageCache/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/composer.json b/app/code/Magento/PayPalRecurringPayment/composer.json index acd9b59641091ebebc95850fbce4d500e7764848..4538e1236c589bcf6dc76902811e433639ad629e 100644 --- a/app/code/Magento/PayPalRecurringPayment/composer.json +++ b/app/code/Magento/PayPalRecurringPayment/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-paypal": "0.1.0-alpha94", - "magento/module-recurring-payment": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-paypal": "0.1.0-alpha95", + "magento/module-recurring-payment": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Payment/Model/Method/Free.php b/app/code/Magento/Payment/Model/Method/Free.php index 083d51d5398e42cd43f4fd2844406ea201490105..2322741f5964458538c16142420537f7d891d189 100644 --- a/app/code/Magento/Payment/Model/Method/Free.php +++ b/app/code/Magento/Payment/Model/Method/Free.php @@ -54,7 +54,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -65,7 +65,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -73,7 +73,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { parent::__construct($eventManager, $paymentData, $scopeConfig, $logAdapterFactory, $data); diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 7b2ed9f2472bb8396bb9fafea8852642da3ecd23..0edbbc14963a161c2eb6d5d7b68d8dff14ba0180 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-centinel": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-centinel": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/Model/Config.php b/app/code/Magento/Paypal/Model/Config.php index 20caf2cdf53342afa47ae496c8bd6491afb5b475..898a4d3ae985af6102868a6d401ca1b8f09071b0 100644 --- a/app/code/Magento/Paypal/Model/Config.php +++ b/app/code/Magento/Paypal/Model/Config.php @@ -620,7 +620,7 @@ class Config protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -637,7 +637,7 @@ class Config /** * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Payment\Model\Source\CctypeFactory $cctypeFactory * @param \Magento\Paypal\Model\CertFactory $certFactory * @param array $params @@ -645,7 +645,7 @@ class Config public function __construct( \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Payment\Model\Source\CctypeFactory $cctypeFactory, \Magento\Paypal\Model\CertFactory $certFactory, $params = array() diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index 392c2b8eb9213962f402b33b430c069f1d6b9943..aa5d35482ddbb4696927805c3d6ba68f2bab88e7 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -130,7 +130,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc protected $_pro; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -159,7 +159,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Paypal\Model\ProFactory $proFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Paypal\Model\CartFactory $cartFactory @@ -177,7 +177,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Paypal\Model\ProFactory $proFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Paypal\Model\CartFactory $cartFactory, diff --git a/app/code/Magento/Paypal/Model/Express.php b/app/code/Magento/Paypal/Model/Express.php index e4d2ecfe65c398c84c6b0e34369bb49494905b33..737217014bbc7265146ac2a75d3bbf59e524cf55 100644 --- a/app/code/Magento/Paypal/Model/Express.php +++ b/app/code/Magento/Paypal/Model/Express.php @@ -156,7 +156,7 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod protected $_authorizationCountKey = 'authorization_count'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -186,7 +186,7 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param ProFactory $proFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Paypal\Model\CartFactory $cartFactory * @param \Magento\Checkout\Model\Session $checkoutSession @@ -199,7 +199,7 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, ProFactory $proFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Checkout\Model\Session $checkoutSession, diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index e1c9bb83bbd1c92bcc7655c845c4099e441312f6..783d18c4bed4513b011fb15638243652dfc5c929 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -202,7 +202,7 @@ class Checkout protected $_paypalInfo; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -297,7 +297,7 @@ class Checkout * @param \Magento\Framework\App\Cache\Type\Config $configCacheType * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Paypal\Model\Info $paypalInfo - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $coreUrl * @param \Magento\Paypal\Model\CartFactory $cartFactory * @param \Magento\Framework\Logger\AdapterFactory $logFactory @@ -308,7 +308,7 @@ class Checkout * @param \Magento\Framework\Object\Copy $objectCopyService * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService - * @param \Magento\Customer\Service\V1\Data\AddressBuilderFactory $addressBuilder + * @param \Magento\Customer\Service\V1\Data\AddressBuilderFactory $addressBuilderFactory * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor @@ -326,7 +326,7 @@ class Checkout \Magento\Framework\App\Cache\Type\Config $configCacheType, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Paypal\Model\Info $paypalInfo, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $coreUrl, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Framework\Logger\AdapterFactory $logFactory, @@ -337,7 +337,7 @@ class Checkout \Magento\Framework\Object\Copy $objectCopyService, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, - \Magento\Customer\Service\V1\Data\AddressBuilderFactory $addressBuilder, + \Magento\Customer\Service\V1\Data\AddressBuilderFactory $addressBuilderFactory, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, \Magento\Framework\Encryption\EncryptorInterface $encryptor, @@ -363,7 +363,7 @@ class Checkout $this->_objectCopyService = $objectCopyService; $this->_checkoutSession = $checkoutSession; $this->_customerAccountService = $customerAccountService; - $this->_addressBuilderFactory = $addressBuilder; + $this->_addressBuilderFactory = $addressBuilderFactory; $this->_customerBuilder = $customerBuilder; $this->_customerDetailsBuilder = $customerDetailsBuilder; $this->_encryptor = $encryptor; @@ -549,7 +549,9 @@ class Checkout // suppress or export shipping address if ($this->_quote->getIsVirtual()) { - if ($this->_config->getConfigValue('requireBillingAddress') == PaypalConfig::REQUIRE_BILLING_ADDRESS_VIRTUAL) { + if ($this->_config->getConfigValue('requireBillingAddress') + == PaypalConfig::REQUIRE_BILLING_ADDRESS_VIRTUAL + ) { $this->_api->setRequireBillingAddress(1); } $this->_api->setSuppressShipping(true); @@ -1281,6 +1283,7 @@ class Checkout // @codingStandardsIgnoreEnd ); } else { + $this->getCustomerSession()->regenerateId(); $this->getCustomerSession()->loginById($customer->getId()); } return $this; diff --git a/app/code/Magento/Paypal/Model/Hostedpro.php b/app/code/Magento/Paypal/Model/Hostedpro.php index c887fde91d128163c9b4706f3ef10c8f9a657a91..2641e741456bc8ccf4a344272dcb601e11633794 100644 --- a/app/code/Magento/Paypal/Model/Hostedpro.php +++ b/app/code/Magento/Paypal/Model/Hostedpro.php @@ -96,7 +96,7 @@ class Hostedpro extends \Magento\Paypal\Model\Direct * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Paypal\Model\ProFactory $proFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Paypal\Model\CartFactory $cartFactory @@ -115,7 +115,7 @@ class Hostedpro extends \Magento\Paypal\Model\Direct \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Paypal\Model\ProFactory $proFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Paypal\Model\CartFactory $cartFactory, diff --git a/app/code/Magento/Paypal/Model/Method/Agreement.php b/app/code/Magento/Paypal/Model/Method/Agreement.php index cc2e0d474b06efe2e508f25d6949bf09478cab65..354dbbed8a6991edb971fee2d7e39c4e42a29cf3 100644 --- a/app/code/Magento/Paypal/Model/Method/Agreement.php +++ b/app/code/Magento/Paypal/Model/Method/Agreement.php @@ -118,7 +118,7 @@ class Agreement extends \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgr protected $_pro; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -138,7 +138,7 @@ class Agreement extends \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgr * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ProFactory $proFactory * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Paypal\Model\CartFactory $cartFactory @@ -152,7 +152,7 @@ class Agreement extends \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgr \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ProFactory $proFactory, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Paypal\Model\CartFactory $cartFactory, diff --git a/app/code/Magento/Paypal/Model/Observer.php b/app/code/Magento/Paypal/Model/Observer.php index 5a8782ba83130dfe5f1a784c377c8faf3430a608..b2021785f7bc04bf92c652407384dd47026602d3 100644 --- a/app/code/Magento/Paypal/Model/Observer.php +++ b/app/code/Magento/Paypal/Model/Observer.php @@ -196,7 +196,7 @@ class Observer $result = $this->_coreData->jsonDecode($controller->getResponse()->getBody('default')); if (empty($result['error'])) { - $this->_view->loadLayout('checkout_onepage_review'); + $this->_view->loadLayout('checkout_onepage_review', true, true, false); $html = $this->_view->getLayout()->getBlock('paypal.iframe')->toHtml(); $result['update_section'] = array('name' => 'paypaliframe', 'html' => $html); $result['redirect'] = false; diff --git a/app/code/Magento/Paypal/Model/PayflowExpress.php b/app/code/Magento/Paypal/Model/PayflowExpress.php index b98753af0689e0ab6693709038af9714fe3126bd..6c83283e259d0c0c2c3d15a06e85f6aab9a7f431 100644 --- a/app/code/Magento/Paypal/Model/PayflowExpress.php +++ b/app/code/Magento/Paypal/Model/PayflowExpress.php @@ -56,7 +56,7 @@ class PayflowExpress extends \Magento\Paypal\Model\Express * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param ProFactory $proFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param CartFactory $cartFactory * @param \Magento\Checkout\Model\Session $checkoutSession @@ -70,7 +70,7 @@ class PayflowExpress extends \Magento\Paypal\Model\Express \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, ProFactory $proFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, CartFactory $cartFactory, \Magento\Checkout\Model\Session $checkoutSession, diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index 370bb739c7be016e753896a99511f07e20bc2e8b..48605cadf2c5ae5ebe727bdfa67ee878e9785e45 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -160,7 +160,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory @@ -183,7 +183,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ConfigFactory $configFactory, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, diff --git a/app/code/Magento/Paypal/Model/Payflowpro.php b/app/code/Magento/Paypal/Model/Payflowpro.php index 9e4be498b697bac1691fc74aa829483a8ecac28d..a935047ad96469878deeb42f991676d0315a08b5 100644 --- a/app/code/Magento/Paypal/Model/Payflowpro.php +++ b/app/code/Magento/Paypal/Model/Payflowpro.php @@ -212,7 +212,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc ); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -240,7 +240,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory @@ -257,7 +257,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ConfigFactory $configFactory, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index 642ca200ae531c25b03c92473d9fa2e2a95c45fd..131ed0774d7145e5522bcf94cfade81663f5e06d 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -164,7 +164,7 @@ class Settlement extends \Magento\Framework\Model\AbstractModel protected $_tmpDirectory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -177,7 +177,7 @@ class Settlement extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Filesystem $filesystem - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -187,7 +187,7 @@ class Settlement extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Filesystem $filesystem, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Paypal/Model/Standard.php b/app/code/Magento/Paypal/Model/Standard.php index db3685289c1ce3508759f0d8b17fe9357e8398ae..dc2b4e6c588460c850675b178b0c4b68ff21ac57 100644 --- a/app/code/Magento/Paypal/Model/Standard.php +++ b/app/code/Magento/Paypal/Model/Standard.php @@ -76,7 +76,7 @@ class Standard extends \Magento\Payment\Model\Method\AbstractMethod protected $_urlBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -108,7 +108,7 @@ class Standard extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Framework\Session\Generic $paypalSession * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Paypal\Model\Api\StandardFactory $apiStandardFactory * @param \Magento\Paypal\Model\CartFactory $cartFactory @@ -125,7 +125,7 @@ class Standard extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Framework\Session\Generic $paypalSession, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Paypal\Model\Api\StandardFactory $apiStandardFactory, \Magento\Paypal\Model\CartFactory $cartFactory, diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php index 675ed83bb83d16e1bb26b64bca71b8f906e9a4cc..2720de07de88e9d54ea1345e429d990bc519490a 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php @@ -36,7 +36,7 @@ class MerchantCountry extends \Magento\Framework\App\Config\Value protected $_coreData; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -44,7 +44,7 @@ class MerchantCountry extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -54,7 +54,7 @@ class MerchantCountry extends \Magento\Framework\App\Config\Value \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\Data $coreData, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Paypal/composer.json b/app/code/Magento/Paypal/composer.json index 4d52c851549981f85648139f2cbbf90c3efb8cd0..d968f5165867ed51b59345e5da5cb6ffba9125df 100644 --- a/app/code/Magento/Paypal/composer.json +++ b/app/code/Magento/Paypal/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-centinel": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-centinel": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/etc/adminhtml/di.xml b/app/code/Magento/Paypal/etc/adminhtml/di.xml index 34037115d3b55e2cb5e1071b146d3a21d4e6efa7..91b258f4b0f6eb3c6073bc80742e99770d5a1334 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/di.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Paypal\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Paypal\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> <virtualType name="Magento\Paypal\Model\PayflowSession\Storage" type="Magento\Framework\Session\Storage"> @@ -43,14 +42,8 @@ <virtualType name="Magento\Paypal\Model\PayflowSession" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Paypal\Model\PayflowSession\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Backend\Model\Config\Structure"> <plugin name="paypal_system_configuration" type="Magento\Paypal\Model\Config\StructurePlugin"/> </type> diff --git a/app/code/Magento/Paypal/etc/frontend/di.xml b/app/code/Magento/Paypal/etc/frontend/di.xml index 7605fb374383c548cc7a72802ddc5332cf5bfe9c..689600ab6891e38093dbc4f65948df379bae5d75 100644 --- a/app/code/Magento/Paypal/etc/frontend/di.xml +++ b/app/code/Magento/Paypal/etc/frontend/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Paypal\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Paypal\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> <virtualType name="Magento\Paypal\Model\PayflowSession\Storage" type="Magento\Framework\Session\Storage"> @@ -43,14 +42,8 @@ <virtualType name="Magento\Paypal\Model\PayflowSession" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Paypal\Model\PayflowSession\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/code/Magento/Persistent/Helper/Data.php b/app/code/Magento/Persistent/Helper/Data.php index a54c9f3c7ee72fc055142eadd05548f7555034ce..f3679aa47597654d2b3aeb92456c0c24a358b2c7 100644 --- a/app/code/Magento/Persistent/Helper/Data.php +++ b/app/code/Magento/Persistent/Helper/Data.php @@ -63,7 +63,7 @@ class Data extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Module\Dir\Reader $modulesReader @@ -73,7 +73,7 @@ class Data extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\Module\Dir\Reader $modulesReader, diff --git a/app/code/Magento/Persistent/Helper/Session.php b/app/code/Magento/Persistent/Helper/Session.php index 0946f7fcd4cb0d0385ebfb1ef854b29ec9e4f7e7..30e2b2fde05dbd8cd52d221d736c4a19dcfb2485 100644 --- a/app/code/Magento/Persistent/Helper/Session.php +++ b/app/code/Magento/Persistent/Helper/Session.php @@ -66,7 +66,7 @@ class Session extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param Data $persistentData @@ -77,7 +77,7 @@ class Session extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Persistent\Helper\Data $persistentData, diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index c4dd6a31ae3d141686c1e809818894f14ce5f6d7..af7d6a17543aec9260429a068ed64555f8456865 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -84,7 +84,7 @@ class Session extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -122,7 +122,7 @@ class Session extends \Magento\Framework\Model\AbstractModel * @param \Magento\Persistent\Helper\Data $persistentData * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -137,7 +137,7 @@ class Session extends \Magento\Framework\Model\AbstractModel \Magento\Persistent\Helper\Data $persistentData, \Magento\Framework\Stdlib\CookieManager $cookieManager, \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Session\Config\ConfigInterface $sessionConfig, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -312,14 +312,8 @@ class Session extends \Magento\Framework\Model\AbstractModel */ public function setPersistentCookie($duration, $path) { - $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() - ->setDuration($duration) - ->setPath($path); - $this->_cookieManager->setPublicCookie( - self::COOKIE_NAME, - $this->getKey(), - $publicCookieMetadata - ); + $value = $this->getKey(); + $this->setCookie($value, $duration, $path); return $this; } @@ -337,14 +331,7 @@ class Session extends \Magento\Framework\Model\AbstractModel } $value = $this->_cookieManager->getCookie(self::COOKIE_NAME); if (null !== $value) { - $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() - ->setDuration($duration) - ->setPath($path); - $this->_cookieManager->setPublicCookie( - self::COOKIE_NAME, - $value, - $publicCookieMetadata - ); + $this->setCookie($value, $duration, $path); } return $this; } @@ -395,4 +382,25 @@ class Session extends \Magento\Framework\Model\AbstractModel $this->setUpdatedAt(gmdate('Y-m-d H:i:s')); return parent::save(); } + + /** + * Set persistent shopping cart cookie. + * + * @param string $value + * @param int $duration + * @param string $path + * @return void + */ + private function setCookie($value, $duration, $path) + { + $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() + ->setDuration($duration) + ->setPath($path) + ->setHttpOnly(true); + $this->_cookieManager->setPublicCookie( + self::COOKIE_NAME, + $value, + $publicCookieMetadata + ); + } } diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index ae67fe53027d8ed7390870b3217d3df83f16aac1..b9a46d4c5abfe18a25b4e028e1f8f66f2ea8acfd 100644 --- a/app/code/Magento/Persistent/composer.json +++ b/app/code/Magento/Persistent/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/ProductAlert/Controller/Add/Price.php b/app/code/Magento/ProductAlert/Controller/Add/Price.php index 184fa007cfbfd96eb3b08ebd3fb497416b731e01..d990228e15198196a9be85ea007cb2a2acebb018 100644 --- a/app/code/Magento/ProductAlert/Controller/Add/Price.php +++ b/app/code/Magento/ProductAlert/Controller/Add/Price.php @@ -29,19 +29,19 @@ use Magento\Framework\App\Action\Context; class Price extends \Magento\ProductAlert\Controller\Add { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param Context $context * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( Context $context, \Magento\Customer\Model\Session $customerSession, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; parent::__construct($context, $customerSession); @@ -102,7 +102,7 @@ class Price extends \Magento\ProductAlert\Controller\Add )->setPrice( $product->getFinalPrice() )->setWebsiteId( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() ); $model->save(); $this->messageManager->addSuccess(__('You saved the alert subscription.')); diff --git a/app/code/Magento/ProductAlert/Controller/Add/Stock.php b/app/code/Magento/ProductAlert/Controller/Add/Stock.php index ab2eaa59ce59303ac1d8db4f6f99fc888b70b1c1..b5a40826a089f9901007c0c8727ca87e96cf27af 100644 --- a/app/code/Magento/ProductAlert/Controller/Add/Stock.php +++ b/app/code/Magento/ProductAlert/Controller/Add/Stock.php @@ -53,7 +53,7 @@ class Stock extends \Magento\ProductAlert\Controller\Add )->setProductId( $product->getId() )->setWebsiteId( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() ); $model->save(); $this->messageManager->addSuccess(__('Alert subscription has been saved.')); diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php index 2db2e593e51ba398c8464040cbc03ae5e52225e7..39ce0731aa19915f2ddeb2cc44ecfc3a068f9d11 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php @@ -53,7 +53,7 @@ class Price extends \Magento\ProductAlert\Controller\Unsubscribe )->setProductId( $product->getId() )->setWebsiteId( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() )->loadByParam(); if ($model->getId()) { $model->delete(); diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/PriceAll.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/PriceAll.php index f0adb85609cfee77c2088c7a56eef2a978cf5c2d..2d7eb7196776741b324a61a397532f25001d504b 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/PriceAll.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/PriceAll.php @@ -36,7 +36,7 @@ class PriceAll extends \Magento\ProductAlert\Controller\Unsubscribe 'Magento\ProductAlert\Model\Price' )->deleteCustomer( $this->_customerSession->getCustomerId(), - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() ); $this->messageManager->addSuccess(__('You will no longer receive price alerts for this product.')); } catch (\Exception $e) { diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php index 7e2f59008a017dde63275d7282d4e9945180412f..1bdd233f249e34ee9b0efc0572e1c5695d0fef6d 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php @@ -54,7 +54,7 @@ class Stock extends \Magento\ProductAlert\Controller\Unsubscribe )->setProductId( $product->getId() )->setWebsiteId( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() )->loadByParam(); if ($model->getId()) { $model->delete(); diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/StockAll.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/StockAll.php index fd920a5fb5bc908e91020d37f7f69ac99d380673..9cf6be9a1a820c8fe022331dc373e3687dc13ff4 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/StockAll.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/StockAll.php @@ -36,7 +36,7 @@ class StockAll extends \Magento\ProductAlert\Controller\Unsubscribe 'Magento\ProductAlert\Model\Stock' )->deleteCustomer( $this->_customerSession->getCustomerId(), - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() ); $this->messageManager->addSuccess(__('You will no longer receive stock alerts.')); } catch (\Exception $e) { diff --git a/app/code/Magento/ProductAlert/Helper/Data.php b/app/code/Magento/ProductAlert/Helper/Data.php index c413eb9356cadf9ed1706372903ccfbf53a27950..d3a04208ddd0a3c9d76c8c9e2090da04e499f0cd 100644 --- a/app/code/Magento/ProductAlert/Helper/Data.php +++ b/app/code/Magento/ProductAlert/Helper/Data.php @@ -60,14 +60,14 @@ class Data extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig diff --git a/app/code/Magento/ProductAlert/Model/Email.php b/app/code/Magento/ProductAlert/Model/Email.php index d8016ac1d8ccf37449883052e097704ad3dd208c..4877cafbb6d9185974cfb8d13184a2f5fdc3e665 100644 --- a/app/code/Magento/ProductAlert/Model/Email.php +++ b/app/code/Magento/ProductAlert/Model/Email.php @@ -100,7 +100,7 @@ class Email extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -129,7 +129,7 @@ class Email extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\ProductAlert\Helper\Data $productAlertData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Helper\View $customerHelper * @param \Magento\Core\Model\App\Emulation $appEmulation @@ -143,7 +143,7 @@ class Email extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\ProductAlert\Helper\Data $productAlertData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Helper\View $customerHelper, \Magento\Core\Model\App\Emulation $appEmulation, diff --git a/app/code/Magento/ProductAlert/Model/Observer.php b/app/code/Magento/ProductAlert/Model/Observer.php index 361ade36842406a2a9e76d0bd0fd2e399749c388..0b3ced69f5bcdeebf0b1c9fff0361e71a975ae8a 100644 --- a/app/code/Magento/ProductAlert/Model/Observer.php +++ b/app/code/Magento/ProductAlert/Model/Observer.php @@ -86,7 +86,7 @@ class Observer protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -133,7 +133,7 @@ class Observer /** * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ProductAlert\Model\Resource\Price\CollectionFactory $priceColFactory * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -146,7 +146,7 @@ class Observer public function __construct( \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ProductAlert\Model\Resource\Price\CollectionFactory $priceColFactory, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, \Magento\Catalog\Model\ProductFactory $productFactory, diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 0e02704d83b4169310ae89af7939284716b1d71e..6649bbd012abf5f4639d804a1a48607819c087f2 100644 --- a/app/code/Magento/ProductAlert/composer.json +++ b/app/code/Magento/ProductAlert/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/Model/Observer.php b/app/code/Magento/RecurringPayment/Model/Observer.php index 345bdb277d9bda7fa18eae6a30784d7ad04b925a..0076a8d7200cf902cf5ba15463f0878b42d7dae4 100644 --- a/app/code/Magento/RecurringPayment/Model/Observer.php +++ b/app/code/Magento/RecurringPayment/Model/Observer.php @@ -38,7 +38,7 @@ class Observer /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,13 +56,13 @@ class Observer /** * @param \Magento\Framework\LocaleInterface $locale - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\RecurringPayment\Model\RecurringPaymentFactory $recurringPaymentFactory * @param \Magento\RecurringPayment\Block\Fields $fields */ public function __construct( \Magento\Framework\LocaleInterface $locale, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\RecurringPayment\Model\RecurringPaymentFactory $recurringPaymentFactory, \Magento\RecurringPayment\Block\Fields $fields ) { diff --git a/app/code/Magento/RecurringPayment/composer.json b/app/code/Magento/RecurringPayment/composer.json index f7e4affabff3cf87e05eea15082e8ff458f91a01..8f1a7652d6427438c3c1216a031fc4ef89326d00 100644 --- a/app/code/Magento/RecurringPayment/composer.json +++ b/app/code/Magento/RecurringPayment/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/Model/Config.php b/app/code/Magento/Reports/Model/Config.php index a24369dd0dc455d396430eac5e444b78786abfe9..3f6b17098bb6ffa8bb90a53057f0b8ff4ba05d69 100644 --- a/app/code/Magento/Reports/Model/Config.php +++ b/app/code/Magento/Reports/Model/Config.php @@ -34,18 +34,18 @@ class Config extends \Magento\Framework\Object protected $_moduleReader; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Module\Dir\Reader $moduleReader - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( \Magento\Framework\Module\Dir\Reader $moduleReader, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { parent::__construct($data); diff --git a/app/code/Magento/Reports/Model/Event/Observer.php b/app/code/Magento/Reports/Model/Event/Observer.php index ceb50ae3be89b83272af82462bbbcbdf274f20c4..b2c83d086a45b62f87cb75b04f3c3c3f3923b761 100644 --- a/app/code/Magento/Reports/Model/Event/Observer.php +++ b/app/code/Magento/Reports/Model/Event/Observer.php @@ -29,7 +29,7 @@ namespace Magento\Reports\Model\Event; class Observer { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -54,32 +54,32 @@ class Observer protected $_customerSession; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Reports\Model\EventFactory $event * @param \Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory * @param \Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Reports\Model\EventFactory $event, \Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory, \Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory, \Magento\Customer\Model\Session $customerSession, - \Magento\Log\Model\Visitor $logVisitor + \Magento\Customer\Model\Visitor $customerVisitor ) { $this->_storeManager = $storeManager; $this->_eventFactory = $event; $this->_productCompFactory = $productCompFactory; $this->_productIndxFactory = $productIndxFactory; $this->_customerSession = $customerSession; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; } /** @@ -99,7 +99,7 @@ class Observer if ($this->_customerSession->isLoggedIn()) { $subjectId = $this->_customerSession->getCustomerId(); } else { - $subjectId = $this->_logVisitor->getId(); + $subjectId = $this->_customerVisitor->getId(); $subtype = 1; } } @@ -134,7 +134,7 @@ class Observer return $this; } - $visitorId = $this->_logVisitor->getId(); + $visitorId = $this->_customerVisitor->getId(); $customerId = $this->_customerSession->getCustomerId(); $eventModel = $this->_eventFactory->create(); $eventModel->updateCustomerType($visitorId, $customerId); diff --git a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php index 972858dd1453c43e90b37b7e72197aaf6bb5febc..38937fcd7dad20b11c8804724d6321f3ad4d9806 100644 --- a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php +++ b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php @@ -36,14 +36,14 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel protected $_countCacheKey; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * @var \Magento\Customer\Model\Session @@ -68,8 +68,8 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Session\Generic $reportSession * @param \Magento\Catalog\Model\Product\Visibility $productVisibility @@ -81,8 +81,8 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Framework\StoreManagerInterface $storeManager, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Session\Generic $reportSession, \Magento\Catalog\Model\Product\Visibility $productVisibility, @@ -94,7 +94,7 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->_storeManager = $storeManager; $this->dateTime = $dateTime; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->_customerSession = $customerSession; $this->_reportSession = $reportSession; $this->_productVisibility = $productVisibility; @@ -137,7 +137,7 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel if ($this->hasData('visitor_id')) { return $this->getData('visitor_id'); } - return $this->_logVisitor->getId(); + return $this->_customerVisitor->getId(); } /** diff --git a/app/code/Magento/Reports/Model/Product/Index/Compared.php b/app/code/Magento/Reports/Model/Product/Index/Compared.php index 94f337d74c7167aec8d192d8a513ffda55151534..94c64f10e0cf63e71e67869858d99dbf75848ed8 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Compared.php +++ b/app/code/Magento/Reports/Model/Product/Index/Compared.php @@ -57,8 +57,8 @@ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Session\Generic $reportSession * @param \Magento\Catalog\Model\Product\Visibility $productVisibility @@ -71,8 +71,8 @@ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Framework\StoreManagerInterface $storeManager, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Session\Generic $reportSession, \Magento\Catalog\Model\Product\Visibility $productVisibility, @@ -86,7 +86,7 @@ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex $context, $registry, $storeManager, - $logVisitor, + $customerVisitor, $customerSession, $reportSession, $productVisibility, diff --git a/app/code/Magento/Reports/Model/Resource/Event.php b/app/code/Magento/Reports/Model/Resource/Event.php index abf1d6a31a1f6824805fa69c6ecc4cf81e4ee2b1..3fd772da56f897695f5143dcced40d456a7b2275 100644 --- a/app/code/Magento/Reports/Model/Resource/Event.php +++ b/app/code/Magento/Reports/Model/Resource/Event.php @@ -36,19 +36,19 @@ class Event extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($resource); $this->_scopeConfig = $scopeConfig; diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 357604ea000d4bd321df170afb61e85935b19b34..23134cd656ed67545a86fbe9e3e1d793f02d0d82 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -54,7 +54,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -80,7 +80,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\DB\Helper $coreResourceHelper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Sales\Model\Order\Config $orderConfig * @param \Magento\Sales\Model\Resource\Report\OrderFactory $reportOrderFactory @@ -96,7 +96,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\DB\Helper $coreResourceHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Sales\Model\Resource\Report\OrderFactory $reportOrderFactory, diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php index 58b96aede067028800e115407cd1f8a2af03c918..f7ab6b0a0d8c6bf64360eda49524f022c7ee1642 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php @@ -82,7 +82,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -108,7 +108,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php index fd67d640e7abd61786765f57946df9524d7be524..89942c3b4cf8c4e7e2ac3e1fd7e2192103ab2140 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php @@ -40,9 +40,9 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc protected $_customerId = null; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * @param \Magento\Core\Model\EntityFactory $entityFactory @@ -54,7 +54,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -63,7 +63,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param mixed $connection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -78,7 +78,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, @@ -87,7 +87,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, $connection = null ) { parent::__construct( @@ -111,7 +111,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc $dateTime, $connection ); - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; } /** @@ -184,7 +184,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc } elseif ($this->_customerId) { $condition['customer_id'] = $this->_customerId; } else { - $condition['visitor_id'] = $this->_logVisitor->getId(); + $condition['visitor_id'] = $this->_customerVisitor->getId(); } return $condition; diff --git a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php index 839db3bcb646852e9081af123528ba724135df49..072550c026ee45c3c33d650a938a36b7b70eb7c4 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php @@ -66,7 +66,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -94,7 +94,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php b/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php index ad038a18d60c6075603d9f4d49a3c0e794241d06..c9402640d5065e31518e0270a2332a66f36e1564 100644 --- a/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php @@ -44,7 +44,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Review\Helper\Data $reviewData * @param \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource @@ -56,7 +56,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Review\Helper\Data $reviewData, \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Resource\Customer $customerResource, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index e7ffc1b1d0afba633cc8f0978ec25710c7be09c6..4b5426fb21171895a48c7f7bc3aff786a9096647 100644 --- a/app/code/Magento/Reports/composer.json +++ b/app/code/Magento/Reports/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-log": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-review": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-downloadable": "0.1.0-alpha94", - "magento/module-sales-rule": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-log": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-review": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-downloadable": "0.1.0-alpha95", + "magento/module-sales-rule": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/etc/adminhtml/di.xml b/app/code/Magento/Reports/etc/adminhtml/di.xml index 42ebf99024b6c0915fd61e4e359d1ed70d86bf3e..17e2bd98dfab6981ea055f05698c0f0ab275c469 100644 --- a/app/code/Magento/Reports/etc/adminhtml/di.xml +++ b/app/code/Magento/Reports/etc/adminhtml/di.xml @@ -24,11 +24,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <virtualType name="Magento\Reports\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </virtualType> <type name="Magento\Reports\Model\Resource\Customer\Collection"> <arguments> <argument name="modelName" xsi:type="string">Magento\Customer\Model\Backend\Customer</argument> diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index ba3076e652bc4207edc7d0b308295491a3821a06..6c2d254e4602f3e2df9ba207cbed0078789ea13b 100644 --- a/app/code/Magento/RequireJs/composer.json +++ b/app/code/Magento/RequireJs/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/Block/Product/Compare/ListCompare/Plugin/Review.php b/app/code/Magento/Review/Block/Product/Compare/ListCompare/Plugin/Review.php index aa0a64ee94bfdacd13c9eee1ee43a7ddd40da537..33d0dd52936994413540323255b8b5c5b5ee00e5 100644 --- a/app/code/Magento/Review/Block/Product/Compare/ListCompare/Plugin/Review.php +++ b/app/code/Magento/Review/Block/Product/Compare/ListCompare/Plugin/Review.php @@ -36,16 +36,16 @@ class Review /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\ReviewFactory $reviewFactory */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\ReviewFactory $reviewFactory ) { $this->storeManager = $storeManager; diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php index 72eefddbba5970b39c83b369a4b137d01e9a2ab3..d9cd0f5c1a61f010502bff075a432ea24a32f976 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php @@ -34,8 +34,8 @@ class Post extends \Magento\Review\Controller\Adminhtml\Product $productId = $this->getRequest()->getParam('product_id', false); if ($data = $this->getRequest()->getPost()) { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManagerInterface */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManagerInterface */ + $storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); if ($storeManager->hasSingleStore()) { $data['stores'] = array( $storeManager->getStore(true)->getId() diff --git a/app/code/Magento/Review/Controller/Product.php b/app/code/Magento/Review/Controller/Product.php index cd735d1fe62caf8ebe89456ff6893e8a76fb131a..2821ef0ff38a05102f167d78982fdfd737c2f742 100644 --- a/app/code/Magento/Review/Controller/Product.php +++ b/app/code/Magento/Review/Controller/Product.php @@ -100,7 +100,7 @@ class Product extends \Magento\Framework\App\Action\Action /** * Core model store manager interface * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -122,7 +122,7 @@ class Product extends \Magento\Framework\App\Action\Action * @param \Magento\Review\Model\RatingFactory $ratingFactory * @param \Magento\Catalog\Model\Design $catalogDesign * @param \Magento\Framework\Session\Generic $reviewSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator */ public function __construct( @@ -136,7 +136,7 @@ class Product extends \Magento\Framework\App\Action\Action \Magento\Review\Model\RatingFactory $ratingFactory, \Magento\Catalog\Model\Design $catalogDesign, \Magento\Framework\Session\Generic $reviewSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Review/Model/Resource/Rating.php b/app/code/Magento/Review/Model/Resource/Rating.php index 3bf47064b02652e5347a91681e52bfdb040d8b47..8ea8e825c21d45c267ed4a417584eb9f950e5475 100644 --- a/app/code/Magento/Review/Model/Resource/Rating.php +++ b/app/code/Magento/Review/Model/Resource/Rating.php @@ -35,7 +35,7 @@ class Rating extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -55,14 +55,14 @@ class Rating extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Logger $logger * @param \Magento\Review\Helper\Data $ratingData - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\Resource\Review\Summary $reviewSummary */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Logger $logger, \Magento\Review\Helper\Data $ratingData, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\Resource\Review\Summary $reviewSummary ) { $this->_ratingData = $ratingData; diff --git a/app/code/Magento/Review/Model/Resource/Rating/Collection.php b/app/code/Magento/Review/Model/Resource/Rating/Collection.php index f33c6f2edf2a9ea9cef14795fbee011c3e51b923..7cbcf9ea511e050597ba086ac6b32e18535e507e 100644 --- a/app/code/Magento/Review/Model/Resource/Rating/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Rating/Collection.php @@ -31,7 +31,7 @@ namespace Magento\Review\Model\Resource\Rating; class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -51,7 +51,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource @@ -61,7 +61,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null diff --git a/app/code/Magento/Review/Model/Resource/Rating/Grid/Collection.php b/app/code/Magento/Review/Model/Resource/Rating/Grid/Collection.php index 396f58c2da0eca2674f60e8bf5b0033561f56eeb..5771a2667e17b43ef61ecf78f1997e451d397563 100644 --- a/app/code/Magento/Review/Model/Resource/Rating/Grid/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Rating/Grid/Collection.php @@ -42,7 +42,7 @@ class Collection extends \Magento\Review\Model\Resource\Rating\Collection * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param \Magento\Framework\Registry $coreRegistry * @param mixed $connection @@ -53,7 +53,7 @@ class Collection extends \Magento\Review\Model\Resource\Rating\Collection \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, \Magento\Framework\Registry $coreRegistry, $connection = null, diff --git a/app/code/Magento/Review/Model/Resource/Rating/Option/Vote/Collection.php b/app/code/Magento/Review/Model/Resource/Rating/Option/Vote/Collection.php index 4e47cc2def870dc4a48c2ab3dc8feb9fb22c9046..9842658ed82a5c59a22897b547fc4a7e83b9cdc3 100644 --- a/app/code/Magento/Review/Model/Resource/Rating/Option/Vote/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Rating/Option/Vote/Collection.php @@ -33,7 +33,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store list manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -47,7 +47,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource @@ -57,7 +57,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php index 5d047fe81a9c18cd1b96973a95fe13a45895f858..7fcd9cf238aed5155d3e9eaf6f6d9977378ec603 100644 --- a/app/code/Magento/Review/Model/Resource/Review.php +++ b/app/code/Magento/Review/Model/Resource/Review.php @@ -89,7 +89,7 @@ class Review extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Core model store manager interface * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -110,14 +110,14 @@ class Review extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime\DateTime $date - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\RatingFactory $ratingFactory * @param \Magento\Review\Model\Resource\Rating\Option $ratingOptions */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\RatingFactory $ratingFactory, Rating\Option $ratingOptions ) { diff --git a/app/code/Magento/Review/Model/Resource/Review/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Collection.php index e5b52ad4440595644e7254147ba66fb093e70a97..af2c157af02832f8cb89a5abbf287921af2ce1f5 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Collection.php @@ -88,7 +88,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Core model store manager interface * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -99,7 +99,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Review\Helper\Data $reviewData * @param \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -110,7 +110,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Review\Helper\Data $reviewData, \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php index 754029321e0ac6c9b902dce1a84dcf77772ad029..fd288835d291c1bc2d2de963f6a69ffc3ca1412f 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php @@ -84,7 +84,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -109,7 +109,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Review/Model/Review.php b/app/code/Magento/Review/Model/Review.php index b4e22d8efa4ebb1d32aa72189d769dba804c4669..e7c148df21d164e3fe4efec93dc4b9770493340d 100644 --- a/app/code/Magento/Review/Model/Review.php +++ b/app/code/Magento/Review/Model/Review.php @@ -115,7 +115,7 @@ class Review extends \Magento\Framework\Model\AbstractModel /** * Core model store manager interface * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -134,7 +134,7 @@ class Review extends \Magento\Framework\Model\AbstractModel * @param \Magento\Review\Model\Resource\Review\Summary\CollectionFactory $summaryFactory * @param \Magento\Review\Model\Review\SummaryFactory $summaryModFactory * @param \Magento\Review\Model\Review\Summary $reviewSummary - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlModel * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -148,7 +148,7 @@ class Review extends \Magento\Framework\Model\AbstractModel \Magento\Review\Model\Resource\Review\Summary\CollectionFactory $summaryFactory, \Magento\Review\Model\Review\SummaryFactory $summaryModFactory, \Magento\Review\Model\Review\Summary $reviewSummary, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlModel, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index 6572b19a11e78132ba4bc71796b927e2df29a88a..e5f0c67753d353a30a411614f310a7eecf6f81f5 100644 --- a/app/code/Magento/Review/composer.json +++ b/app/code/Magento/Review/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-newsletter": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-newsletter": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/etc/adminhtml/di.xml b/app/code/Magento/Review/etc/adminhtml/di.xml index 7260638f2afe11f12d7179c9a9bb2f7ebe7f235e..c229601f510de78de4cf923dce5fd467111ff1e3 100644 --- a/app/code/Magento/Review/etc/adminhtml/di.xml +++ b/app/code/Magento/Review/etc/adminhtml/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Review\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Review\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> <type name="Magento\Review\Block\Form"> diff --git a/app/code/Magento/Review/etc/frontend/di.xml b/app/code/Magento/Review/etc/frontend/di.xml index 7829e68592091779d97c8937375e4035637c50ac..b28d9f17f56a61c1755b939e9c7814292c01109f 100644 --- a/app/code/Magento/Review/etc/frontend/di.xml +++ b/app/code/Magento/Review/etc/frontend/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Review\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Review\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> <type name="Magento\Review\Block\Form"> diff --git a/app/code/Magento/Rss/Block/Catalog/Review.php b/app/code/Magento/Rss/Block/Catalog/Review.php index 714d9bc3ca9420bb69865f3d6e6e719402871943..0204ebbd3e51e8aac2ba2c026aa9052670947f07 100644 --- a/app/code/Magento/Rss/Block/Catalog/Review.php +++ b/app/code/Magento/Rss/Block/Catalog/Review.php @@ -44,7 +44,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock protected $_reviewFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -53,7 +53,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock * @param \Magento\Rss\Model\RssFactory $rssFactory * @param \Magento\Framework\Model\Resource\Iterator $resourceIterator * @param \Magento\Review\Model\ReviewFactory $reviewFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -61,7 +61,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock \Magento\Rss\Model\RssFactory $rssFactory, \Magento\Framework\Model\Resource\Iterator $resourceIterator, \Magento\Review\Model\ReviewFactory $reviewFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { $this->_rssFactory = $rssFactory; diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index 11a2d4c5b656f51d0285f9959e459a3b919d9d7a..23a776ea84a18d048c9ad8ad9d7b9b9e8c0cce56 100644 --- a/app/code/Magento/Rss/composer.json +++ b/app/code/Magento/Rss/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-sales-rule": "0.1.0-alpha94", - "magento/module-review": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-sales-rule": "0.1.0-alpha95", + "magento/module-review": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Rss/view/frontend/templates/list.phtml b/app/code/Magento/Rss/view/frontend/templates/list.phtml index 862af46b6f4c18357206ff96843753461ab2a82c..7ecf666c38aa33202a9f9fcf7e5eb692fca73056 100644 --- a/app/code/Magento/Rss/view/frontend/templates/list.phtml +++ b/app/code/Magento/Rss/view/frontend/templates/list.phtml @@ -54,7 +54,7 @@ <tbody> <?php foreach ($_categories as $_category): ?> <tr> - <td class="col feed"><?php echo $_category->getLabel() ?></td> + <td class="col feed"><?php echo $this->escapeHtml($_category->getLabel()) ?></td> <td class="col action"><a href="<?php echo $_category->getUrl() ?>" class="action get"><span><?php echo __('Get Feed'); ?></span></a></td> </tr> <?php endforeach; ?> diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index 615e8883ca1fc132fc6fb05476d54b4210eed2d1..ad76ec72f5298e9a4aa5f27b15dfd32b54ff2923 100644 --- a/app/code/Magento/Rule/composer.json +++ b/app/code/Magento/Rule/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php index 84f43672af8f7e7918b0bd75dfa4315db9215c7e..32987b6a3bcf7a4f8ee2c817c779fe6d2c000997 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php @@ -44,6 +44,7 @@ class Save extends \Magento\Sales\Controller\Adminhtml\Order\Create $this->_forward('denied'); return; } + $this->_getOrderCreateModel()->getQuote()->setCustomerId($this->_getSession()->getCustomerId()); $this->_processActionData('save'); $paymentData = $this->getRequest()->getPost('payment'); if ($paymentData) { diff --git a/app/code/Magento/Sales/Helper/Admin.php b/app/code/Magento/Sales/Helper/Admin.php index d6c46a3538dd7e3caf2df574eff9e443f25680d5..0b8975bdb46da27280a3635abd8c6c472797ec4b 100644 --- a/app/code/Magento/Sales/Helper/Admin.php +++ b/app/code/Magento/Sales/Helper/Admin.php @@ -31,18 +31,18 @@ class Admin extends \Magento\Framework\App\Helper\AbstractHelper protected $_salesConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Config $salesConfig */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Config $salesConfig ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Sales/Helper/Guest.php b/app/code/Magento/Sales/Helper/Guest.php index 36d410d9466367c7a0517caf4da9e9af31d8bed2..a5f3820c28bb8d2b3bcc9cd51d08ed3f5caba890 100644 --- a/app/code/Magento/Sales/Helper/Guest.php +++ b/app/code/Magento/Sales/Helper/Guest.php @@ -81,7 +81,7 @@ class Guest extends \Magento\Core\Helper\Data /** * @param App\Helper\Context $context * @param App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Registry $coreRegistry @@ -98,7 +98,7 @@ class Guest extends \Magento\Core\Helper\Data public function __construct( App\Helper\Context $context, App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\Registry $coreRegistry, @@ -186,10 +186,7 @@ class Guest extends \Magento\Core\Helper\Data if (!$errors) { $toCookie = base64_encode($order->getProtectCode() . ':' . $incrementId); - $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); - $metadata->setPath(self::COOKIE_PATH); - $metadata->setDuration(self::COOKIE_LIFETIME); - $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $toCookie, $metadata); + $this->setGuestViewCookie($toCookie); } } elseif ($fromCookie) { $cookieData = explode(':', base64_decode($fromCookie)); @@ -201,10 +198,7 @@ class Guest extends \Magento\Core\Helper\Data $order->loadByIncrementId($incrementId); if ($order->getProtectCode() == $protectCode) { // renew cookie - $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); - $metadata->setPath(self::COOKIE_PATH); - $metadata->setDuration(self::COOKIE_LIFETIME); - $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $fromCookie, $metadata); + $this->setGuestViewCookie($fromCookie); $errors = false; } } @@ -241,4 +235,19 @@ class Guest extends \Magento\Core\Helper\Data array('label' => __('Order Information'), 'title' => __('Order Information')) ); } + + /** + * Set guest-view cookie + * + * @param string $cookieValue + * @return void + */ + private function setGuestViewCookie($cookieValue) + { + $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setPath(self::COOKIE_PATH) + ->setDuration(self::COOKIE_LIFETIME) + ->setHttpOnly(true); + $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $cookieValue, $metadata); + } } diff --git a/app/code/Magento/Sales/Helper/Reorder.php b/app/code/Magento/Sales/Helper/Reorder.php index 59a6c10bd9009c67557992c2df93b89ce5ff18cc..82ae446cf4c5e3d198950a3b2c3aa04ccf042617 100644 --- a/app/code/Magento/Sales/Helper/Reorder.php +++ b/app/code/Magento/Sales/Helper/Reorder.php @@ -38,7 +38,7 @@ class Reorder extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Customer\Model\Session $customerSession @@ -47,7 +47,7 @@ class Reorder extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Customer\Model\Session $customerSession, diff --git a/app/code/Magento/Sales/Model/AbstractModel.php b/app/code/Magento/Sales/Model/AbstractModel.php index e22f2335ce4ded7244525c1bfa9df2d1a4f5830d..1bb1f251c5e4a94cbe014db0154c3167b18061b7 100644 --- a/app/code/Magento/Sales/Model/AbstractModel.php +++ b/app/code/Magento/Sales/Model/AbstractModel.php @@ -69,20 +69,6 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel */ abstract public function getStore(); - /** - * Processing object after save data - * Updates relevant grid table records. - * - * @return $this - */ - public function afterCommitCallback() - { - if (!$this->getForceUpdateGridRecords()) { - $this->_getResource()->updateGridRecords($this->getId()); - } - return parent::afterCommitCallback(); - } - /** * Get object created at date affected current active store timezone * @@ -106,4 +92,24 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel true ); } + + /** + * Returns _eventPrefix + * + * @return string + */ + public function getEventPrefix() + { + return $this->_eventPrefix; + } + + /** + * Returns _eventObject + * + * @return string + */ + public function getEventObject() + { + return $this->_eventObject; + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateConfigurable.php b/app/code/Magento/Sales/Model/EntityInterface.php similarity index 85% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateConfigurable.php rename to app/code/Magento/Sales/Model/EntityInterface.php index dc03c7c6ef3e4c7fba83507b7ad43ec2bf33ba73..f905c8fe6e8a29795dd242d32f3a0f2997e26248 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateConfigurable.php +++ b/app/code/Magento/Sales/Model/EntityInterface.php @@ -18,18 +18,19 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @spi * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Handler\Ui; +namespace Magento\Sales\Model; /** - * Class CreateConfigurable - * Create a configurable product - * + * Interface EntityInterface */ -class CreateConfigurable extends CreateProduct +interface EntityInterface { + /** + * @return string + */ + public function getIncrementId(); } diff --git a/app/code/Magento/Sales/Model/Increment.php b/app/code/Magento/Sales/Model/Increment.php new file mode 100644 index 0000000000000000000000000000000000000000..7be553c332b37870100c886d2213d27c4a60be39 --- /dev/null +++ b/app/code/Magento/Sales/Model/Increment.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model; + +use Magento\Sales\Model\Order; +use Magento\Eav\Model\Config as EavConfig; + +/** + * Class Increment + */ +class Increment +{ + /** + * @var \Magento\Eav\Model\Config + */ + protected $eavConfig; + + /** + * @var string + */ + protected $incrementValue; + + /** + * @param EavConfig $eavConfig + */ + public function __construct( + EavConfig $eavConfig + ) { + $this->eavConfig = $eavConfig; + } + + /** + * Returns current increment id + * + * @return string + */ + public function getCurrentValue() + { + return $this->incrementValue; + } + + /** + * Returns new value of increment id + * + * @param int $storeId + * @return string + * @throws \Exception + * @throws \Magento\Framework\Model\Exception + */ + public function getNextValue($storeId) + { + $this->incrementValue = + $this->eavConfig->getEntityType(Order::ENTITY)->fetchNewIncrementId($storeId); + return $this->incrementValue; + } +} diff --git a/app/code/Magento/Sales/Model/Observer.php b/app/code/Magento/Sales/Model/Observer.php deleted file mode 100644 index 72dc6bd2ac5c3e7004c84e3cdae297c538de6f77..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Model/Observer.php +++ /dev/null @@ -1,357 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Model; - -/** - * Sales observer - */ -class Observer -{ - /** - * Expire quotes additional fields to filter - * - * @var array - */ - protected $_expireQuotesFilterFields = array(); - - /** - * Catalog data - * - * @var \Magento\Catalog\Helper\Data - */ - protected $_catalogData = null; - - /** - * Customer address - * - * @var \Magento\Customer\Helper\Address - */ - protected $_customerAddressHelper; - - /** - * Customer data - * - * @var \Magento\Customer\Helper\Data - */ - protected $_customerData; - - /** - * Core event manager proxy - * - * @var \Magento\Framework\Event\ManagerInterface - */ - protected $_eventManager; - - /** - * @var \Magento\Store\Model\StoresConfig - */ - protected $_storesConfig; - - /** - * @var \Magento\Sales\Model\Resource\Quote\CollectionFactory - */ - protected $_quoteCollectionFactory; - - /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface - */ - protected $_localeDate; - - /** - * @var Resource\Report\OrderFactory - */ - protected $_orderFactory; - - /** - * @var \Magento\Sales\Model\Resource\Report\InvoicedFactory - */ - protected $_invoicedFactory; - - /** - * @var \Magento\Sales\Model\Resource\Report\RefundedFactory - */ - protected $_refundedFactory; - - /** - * @var \Magento\Sales\Model\Resource\Report\BestsellersFactory - */ - protected $_bestsellersFactory; - - /** - * @var \Magento\Framework\Locale\ResolverInterface - */ - protected $_localeResolver; - - /** - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Customer\Helper\Data $customerData - * @param \Magento\Customer\Helper\Address $customerAddressHelper - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Store\Model\StoresConfig $storesConfig - * @param \Magento\Sales\Model\Resource\Quote\CollectionFactory $quoteFactory - * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate - * @param Resource\Report\OrderFactory $orderFactory - * @param Resource\Report\InvoicedFactory $invoicedFactory - * @param Resource\Report\RefundedFactory $refundedFactory - * @param Resource\Report\BestsellersFactory $bestsellersFactory - * @param \Magento\Framework\Locale\ResolverInterface $localeResolver - */ - public function __construct( - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Customer\Helper\Data $customerData, - \Magento\Customer\Helper\Address $customerAddressHelper, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Store\Model\StoresConfig $storesConfig, - \Magento\Sales\Model\Resource\Quote\CollectionFactory $quoteFactory, - \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, - \Magento\Sales\Model\Resource\Report\OrderFactory $orderFactory, - \Magento\Sales\Model\Resource\Report\InvoicedFactory $invoicedFactory, - \Magento\Sales\Model\Resource\Report\RefundedFactory $refundedFactory, - \Magento\Sales\Model\Resource\Report\BestsellersFactory $bestsellersFactory, - \Magento\Framework\Locale\ResolverInterface $localeResolver - ) { - $this->_eventManager = $eventManager; - $this->_customerData = $customerData; - $this->_customerAddressHelper = $customerAddressHelper; - $this->_catalogData = $catalogData; - $this->_storesConfig = $storesConfig; - $this->_quoteCollectionFactory = $quoteFactory; - $this->_localeDate = $localeDate; - $this->_orderFactory = $orderFactory; - $this->_invoicedFactory = $invoicedFactory; - $this->_refundedFactory = $refundedFactory; - $this->_bestsellersFactory = $bestsellersFactory; - $this->_localeResolver = $localeResolver; - } - - /** - * Clean expired quotes (cron process) - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function cleanExpiredQuotes($schedule) - { - $this->_eventManager->dispatch('clear_expired_quotes_before', array('sales_observer' => $this)); - - $lifetimes = $this->_storesConfig->getStoresConfigByPath('checkout/cart/delete_quote_after'); - foreach ($lifetimes as $storeId => $lifetime) { - $lifetime *= 86400; - - /** @var $quotes \Magento\Sales\Model\Resource\Quote\Collection */ - $quotes = $this->_quoteCollectionFactory->create(); - - $quotes->addFieldToFilter('store_id', $storeId); - $quotes->addFieldToFilter('updated_at', array('to' => date("Y-m-d", time() - $lifetime))); - $quotes->addFieldToFilter('is_active', 0); - - foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) { - $quotes->addFieldToFilter($field, $condition); - } - - $quotes->walk('delete'); - } - return $this; - } - - /** - * Retrieve expire quotes additional fields to filter - * - * @return array - */ - public function getExpireQuotesAdditionalFilterFields() - { - return $this->_expireQuotesFilterFields; - } - - /** - * Set expire quotes additional fields to filter - * - * @param array $fields - * @return $this - */ - public function setExpireQuotesAdditionalFilterFields(array $fields) - { - $this->_expireQuotesFilterFields = $fields; - return $this; - } - - /** - * Refresh sales order report statistics for last day - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function aggregateSalesReportOrderData($schedule) - { - $this->_localeResolver->emulate(0); - $currentDate = $this->_localeDate->date(); - $date = $currentDate->subHour(25); - $this->_orderFactory->create()->aggregate($date); - $this->_localeResolver->revert(); - return $this; - } - - /** - * Refresh sales invoiced report statistics for last day - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function aggregateSalesReportInvoicedData($schedule) - { - $this->_localeResolver->emulate(0); - $currentDate = $this->_localeDate->date(); - $date = $currentDate->subHour(25); - $this->_invoicedFactory->create()->aggregate($date); - $this->_localeResolver->revert(); - return $this; - } - - /** - * Refresh sales refunded report statistics for last day - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function aggregateSalesReportRefundedData($schedule) - { - $this->_localeResolver->emulate(0); - $currentDate = $this->_localeDate->date(); - $date = $currentDate->subHour(25); - $this->_refundedFactory->create()->aggregate($date); - $this->_localeResolver->revert(); - return $this; - } - - /** - * Refresh bestsellers report statistics for last day - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function aggregateSalesReportBestsellersData($schedule) - { - $this->_localeResolver->emulate(0); - $currentDate = $this->_localeDate->date(); - $date = $currentDate->subHour(25); - $this->_bestsellersFactory->create()->aggregate($date); - $this->_localeResolver->revert(); - return $this; - } - - /** - * Set Quote information about MSRP price enabled - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function setQuoteCanApplyMsrp(\Magento\Framework\Event\Observer $observer) - { - /** @var $quote \Magento\Sales\Model\Quote */ - $quote = $observer->getEvent()->getQuote(); - - $canApplyMsrp = false; - if ($this->_catalogData->isMsrpEnabled()) { - foreach ($quote->getAllAddresses() as $address) { - if ($address->getCanApplyMsrp()) { - $canApplyMsrp = true; - break; - } - } - } - - $quote->setCanApplyMsrp($canApplyMsrp); - } - - /** - * Add VAT validation request date and identifier to order comments - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function addVatRequestParamsOrderComment(\Magento\Framework\Event\Observer $observer) - { - /** @var $orderInstance \Magento\Sales\Model\Order */ - $orderInstance = $observer->getOrder(); - /** @var $orderAddress \Magento\Sales\Model\Order\Address */ - $orderAddress = $this->_getVatRequiredSalesAddress($orderInstance); - if (!$orderAddress instanceof \Magento\Sales\Model\Order\Address) { - return; - } - - $vatRequestId = $orderAddress->getVatRequestId(); - $vatRequestDate = $orderAddress->getVatRequestDate(); - if (is_string($vatRequestId) && !empty($vatRequestId) && is_string($vatRequestDate) && !empty($vatRequestDate) - ) { - $orderHistoryComment = __( - 'VAT Request Identifier' - ) . ': ' . $vatRequestId . '<br />' . __( - 'VAT Request Date' - ) . ': ' . $vatRequestDate; - $orderInstance->addStatusHistoryComment($orderHistoryComment, false); - } - } - - /** - * Retrieve sales address (order or quote) on which tax calculation must be based - * - * @param \Magento\Sales\Model\Order $order - * @param \Magento\Store\Model\Store|string|int|null $store - * @return \Magento\Sales\Model\Order\Address|null - */ - protected function _getVatRequiredSalesAddress($order, $store = null) - { - $configAddressType = $this->_customerAddressHelper->getTaxCalculationAddressType($store); - $requiredAddress = null; - switch ($configAddressType) { - case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING: - $requiredAddress = $order->getShippingAddress(); - break; - default: - $requiredAddress = $order->getBillingAddress(); - break; - } - return $requiredAddress; - } - - /** - * Restore initial customer group ID in quote if needed on collect_totals_after event of quote address - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function restoreQuoteCustomerGroupId($observer) - { - $quoteAddress = $observer->getQuoteAddress(); - $configAddressType = $this->_customerAddressHelper->getTaxCalculationAddressType(); - // Restore initial customer group ID in quote only if VAT is calculated based on shipping address - if ($quoteAddress->hasPrevQuoteCustomerGroupId() && - $configAddressType == \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING - ) { - $quoteAddress->getQuote()->setCustomerGroupId($quoteAddress->getPrevQuoteCustomerGroupId()); - $quoteAddress->unsPrevQuoteCustomerGroupId(); - } - } -} diff --git a/app/code/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersData.php b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersData.php new file mode 100644 index 0000000000000000000000000000000000000000..0b0240cafac8465443ade663540e74971b603ffc --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersData.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +use Magento\Framework\Locale\ResolverInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; + +/** + * Class AggregateSalesReportBestsellersData + */ +class AggregateSalesReportBestsellersData +{ + /** + * @var ResolverInterface + */ + protected $localeResolver; + + /** + * @var TimezoneInterface + */ + protected $localeDate; + + /** + * @var \Magento\Sales\Model\Resource\Report\BestsellersFactory + */ + protected $bestsellersFactory; + + /** + * @param ResolverInterface $localeResolver + * @param TimezoneInterface $timezone + * @param \Magento\Sales\Model\Resource\Report\BestsellersFactory $bestsellersFactory + */ + public function __construct( + ResolverInterface $localeResolver, + TimezoneInterface $timezone, + \Magento\Sales\Model\Resource\Report\BestsellersFactory $bestsellersFactory + ) { + $this->localeResolver = $localeResolver; + $this->localeDate = $timezone; + $this->bestsellersFactory = $bestsellersFactory; + } + + /** + * Refresh bestsellers report statistics for last day + * + * @return void + */ + public function execute() + { + $this->localeResolver->emulate(0); + $currentDate = $this->localeDate->date(); + $date = $currentDate->subHour(25); + $this->bestsellersFactory->create()->aggregate($date); + $this->localeResolver->revert(); + } +} diff --git a/app/code/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedData.php b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedData.php new file mode 100644 index 0000000000000000000000000000000000000000..d02db477a41c5395819e2067fe55b7f2dea3fda1 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedData.php @@ -0,0 +1,74 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Class AggregateSalesReportInvoicedData + */ +class AggregateSalesReportInvoicedData +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface + */ + protected $localeResolver; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface + */ + protected $localeDate; + + /** + * @var \Magento\Sales\Model\Resource\Report\InvoicedFactory + */ + protected $invoicedFactory; + + /** + * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone + * @param \Magento\Sales\Model\Resource\Report\InvoicedFactory $invoicedFactory + */ + public function __construct( + \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, + \Magento\Sales\Model\Resource\Report\InvoicedFactory $invoicedFactory + ) { + $this->localeResolver = $localeResolver; + $this->localeDate = $timezone; + $this->invoicedFactory = $invoicedFactory; + } + + /** + * Refresh sales invoiced report statistics for last day + * + * @return void + */ + public function execute() + { + $this->localeResolver->emulate(0); + $currentDate = $this->localeDate->date(); + $date = $currentDate->subHour(25); + $this->invoicedFactory->create()->aggregate($date); + $this->localeResolver->revert(); + } +} diff --git a/app/code/Magento/Sales/Model/Observer/AggregateSalesReportOrderData.php b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportOrderData.php new file mode 100644 index 0000000000000000000000000000000000000000..9807d11e878f6bb57cd6a601f930ab7adc02db05 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportOrderData.php @@ -0,0 +1,74 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Class AggregateSalesReportOrderData + */ +class AggregateSalesReportOrderData +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface + */ + protected $localeResolver; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface + */ + protected $localeDate; + + /** + * @var \Magento\Sales\Model\Resource\Report\OrderFactory + */ + protected $orderFactory; + + /** + * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone + * @param \Magento\Sales\Model\Resource\Report\OrderFactory $orderFactory + */ + public function __construct( + \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, + \Magento\Sales\Model\Resource\Report\OrderFactory $orderFactory + ) { + $this->localeResolver = $localeResolver; + $this->localeDate = $timezone; + $this->orderFactory = $orderFactory; + } + + /** + * Refresh sales order report statistics for last day + * + * @return void + */ + public function execute() + { + $this->localeResolver->emulate(0); + $currentDate = $this->localeDate->date(); + $date = $currentDate->subHour(25); + $this->orderFactory->create()->aggregate($date); + $this->localeResolver->revert(); + } +} diff --git a/app/code/Magento/Sales/Model/Observer/AggregateSalesReportRefundedData.php b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportRefundedData.php new file mode 100644 index 0000000000000000000000000000000000000000..e6b9c3f236e02fab53bb1e2431689d723c2a32ec --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportRefundedData.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +use Magento\Framework\Locale\ResolverInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; + +/** + * Class AggregateSalesReportRefundedData + */ +class AggregateSalesReportRefundedData +{ + /** + * @var ResolverInterface + */ + protected $localeResolver; + + /** + * @var TimezoneInterface + */ + protected $localeDate; + + /** + * @var \Magento\Sales\Model\Resource\Report\RefundedFactory + */ + protected $refundedFactory; + + /** + * @param ResolverInterface $localeResolver + * @param TimezoneInterface $timezone + * @param \Magento\Sales\Model\Resource\Report\RefundedFactory $refundedFactory + */ + public function __construct( + ResolverInterface $localeResolver, + TimezoneInterface $timezone, + \Magento\Sales\Model\Resource\Report\RefundedFactory $refundedFactory + ) { + $this->localeResolver = $localeResolver; + $this->localeDate = $timezone; + $this->refundedFactory = $refundedFactory; + } + + /** + * Refresh sales refunded report statistics for last day + * + * @return void + */ + public function execute() + { + $this->localeResolver->emulate(0); + $currentDate = $this->localeDate->date(); + $date = $currentDate->subHour(25); + $this->refundedFactory->create()->aggregate($date); + $this->localeResolver->revert(); + } +} diff --git a/app/code/Magento/Sales/Model/Observer/Backend/CustomerQuote.php b/app/code/Magento/Sales/Model/Observer/Backend/CustomerQuote.php index 3c4a35be9086b58034431f01f664d8945ad538ae..f61e3f627b6fb496e280f3696c6595fb334ce476 100644 --- a/app/code/Magento/Sales/Model/Observer/Backend/CustomerQuote.php +++ b/app/code/Magento/Sales/Model/Observer/Backend/CustomerQuote.php @@ -33,7 +33,7 @@ class CustomerQuote protected $_config; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -43,12 +43,12 @@ class CustomerQuote protected $_quoteFactory; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Config\Share $config * @param \Magento\Sales\Model\QuoteFactory $quoteFactory */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Config\Share $config, \Magento\Sales\Model\QuoteFactory $quoteFactory ) { diff --git a/app/code/Magento/Sales/Model/Observer/CleanExpiredQuotes.php b/app/code/Magento/Sales/Model/Observer/CleanExpiredQuotes.php new file mode 100644 index 0000000000000000000000000000000000000000..14844ae8b2e5a841bea264d6dc8ec8a9bcfdb2e7 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/CleanExpiredQuotes.php @@ -0,0 +1,108 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +use Magento\Store\Model\StoresConfig; + +/** + * Class CleanExpiredQuotes + */ +class CleanExpiredQuotes +{ + const LIFETIME = 86400; + + /** + * @var StoresConfig + */ + protected $storesConfig; + + /** + * @var \Magento\Sales\Model\Resource\Quote\CollectionFactory + */ + protected $quoteCollectionFactory; + + /** + * @var array + */ + protected $expireQuotesFilterFields = array(); + + /** + * @param StoresConfig $storesConfig + * @param \Magento\Sales\Model\Resource\Quote\CollectionFactory $collectionFactory + */ + public function __construct( + StoresConfig $storesConfig, + \Magento\Sales\Model\Resource\Quote\CollectionFactory $collectionFactory + ) { + $this->storesConfig = $storesConfig; + $this->quoteCollectionFactory = $collectionFactory; + } + + /** + * Clean expired quotes (cron process) + * + * @return void + */ + public function execute() + { + $lifetimes = $this->storesConfig->getStoresConfigByPath('checkout/cart/delete_quote_after'); + foreach ($lifetimes as $storeId => $lifetime) { + $lifetime *= self::LIFETIME; + + /** @var $quotes \Magento\Sales\Model\Resource\Quote\Collection */ + $quotes = $this->quoteCollectionFactory->create(); + + $quotes->addFieldToFilter('store_id', $storeId); + $quotes->addFieldToFilter('updated_at', array('to' => date("Y-m-d", time() - $lifetime))); + $quotes->addFieldToFilter('is_active', 0); + + foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) { + $quotes->addFieldToFilter($field, $condition); + } + + $quotes->walk('delete'); + } + } + + /** + * Retrieve expire quotes additional fields to filter + * + * @return array + */ + public function getExpireQuotesAdditionalFilterFields() + { + return $this->expireQuotesFilterFields; + } + + /** + * Set expire quotes additional fields to filter + * + * @param array $fields + * @return void + */ + public function setExpireQuotesAdditionalFilterFields(array $fields) + { + $this->expireQuotesFilterFields = $fields; + } +} diff --git a/app/code/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderComment.php b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderComment.php new file mode 100644 index 0000000000000000000000000000000000000000..db6ddc6c402ec3cad09e4b936142b87a21431afc --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderComment.php @@ -0,0 +1,99 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer\Frontend\Quote; + +use Magento\Customer\Helper\Address as CustomerAddress; + +/** + * Class AddVatRequestParamsOrderComment + */ +class AddVatRequestParamsOrderComment +{ + /** + * Customer address + * + * @var CustomerAddress + */ + protected $customerAddressHelper; + + /** + * @param CustomerAddress $customerAddressHelper + */ + public function __construct(CustomerAddress $customerAddressHelper) + { + $this->customerAddressHelper = $customerAddressHelper; + } + + /** + * Add VAT validation request date and identifier to order comments + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + /** @var $orderInstance \Magento\Sales\Model\Order */ + $orderInstance = $observer->getOrder(); + /** @var $orderAddress \Magento\Sales\Model\Order\Address */ + $orderAddress = $this->_getVatRequiredSalesAddress($orderInstance); + if (!$orderAddress instanceof \Magento\Sales\Model\Order\Address) { + return; + } + + $vatRequestId = $orderAddress->getVatRequestId(); + $vatRequestDate = $orderAddress->getVatRequestDate(); + if (is_string($vatRequestId) + && !empty($vatRequestId) + && is_string($vatRequestDate) + && !empty($vatRequestDate) + ) { + $orderHistoryComment = __('VAT Request Identifier') + . ': ' . $vatRequestId . '<br />' + . __('VAT Request Date') . ': ' . $vatRequestDate; + $orderInstance->addStatusHistoryComment($orderHistoryComment, false); + } + } + + /** + * Retrieve sales address (order or quote) on which tax calculation must be based + * + * @param \Magento\Sales\Model\Order $order + * @param \Magento\Store\Model\Store|string|int|null $store + * @return \Magento\Sales\Model\Order\Address|null + */ + protected function _getVatRequiredSalesAddress($order, $store = null) + { + $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType($store); + $requiredAddress = null; + switch ($configAddressType) { + case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING: + $requiredAddress = $order->getShippingAddress(); + break; + default: + $requiredAddress = $order->getBillingAddress(); + break; + } + return $requiredAddress; + } +} diff --git a/app/code/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupId.php b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupId.php new file mode 100644 index 0000000000000000000000000000000000000000..09c15bc1a610c5d7df9bef8df1a9f2dffd428784 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupId.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer\Frontend\Quote; + +use Magento\Customer\Helper\Address as CustomerAddress; + +/** + * Class RestoreCustomerGroupId + */ +class RestoreCustomerGroupId +{ + /** + * Customer address + * + * @var CustomerAddress + */ + protected $customerAddressHelper; + + /** + * @param CustomerAddress $customerAddressHelper + */ + public function __construct(CustomerAddress $customerAddressHelper) + { + $this->customerAddressHelper = $customerAddressHelper; + } + + /** + * Restore initial customer group ID in quote if needed on collect_totals_after event of quote address + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + $quoteAddress = $observer->getQuoteAddress(); + $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType(); + // Restore initial customer group ID in quote only if VAT is calculated based on shipping address + if ($quoteAddress->hasPrevQuoteCustomerGroupId() && + $configAddressType == \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING + ) { + $quoteAddress->getQuote()->setCustomerGroupId($quoteAddress->getPrevQuoteCustomerGroupId()); + $quoteAddress->unsPrevQuoteCustomerGroupId(); + } + } +} diff --git a/app/code/Magento/Sales/Model/Observer/Frontend/Quote/SetCanApplyMsrp.php b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/SetCanApplyMsrp.php new file mode 100644 index 0000000000000000000000000000000000000000..de3834946903a48455090142ab72f08d2028096c --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/SetCanApplyMsrp.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer\Frontend\Quote; + +use Magento\Catalog\Helper\Data as CatalogData; + +/** + * Class SetCanApplyMsrp + */ +class SetCanApplyMsrp +{ + /** + * Catalog data + * + * @var CatalogData + */ + protected $catalogData; + + /** + * @param CatalogData $catalogData + */ + public function __construct(CatalogData $catalogData) + { + $this->catalogData = $catalogData; + } + + /** + * Set Quote information about MSRP price enabled + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + /** @var $quote \Magento\Sales\Model\Quote */ + $quote = $observer->getEvent()->getQuote(); + + $canApplyMsrp = false; + if ($this->catalogData->isMsrpEnabled()) { + foreach ($quote->getAllAddresses() as $address) { + if ($address->getCanApplyMsrp()) { + $canApplyMsrp = true; + break; + } + } + } + + $quote->setCanApplyMsrp($canApplyMsrp); + } +} diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index a275ec26e8b3e4fdd06eb0234a191b367114c922..6097c84f3a3c714b1c707fffb033485cb4b38783 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -227,7 +227,6 @@ use Magento\Sales\Model\Resource\Order\Status\History\Collection as HistoryColle * @method \Magento\Sales\Model\Order setWeight(float $value) * @method string getCustomerDob() * @method \Magento\Sales\Model\Order setCustomerDob(string $value) - * @method string getIncrementId() * @method \Magento\Sales\Model\Order setIncrementId(string $value) * @method string getAppliedRuleIds() * @method \Magento\Sales\Model\Order setAppliedRuleIds(string $value) @@ -310,8 +309,17 @@ use Magento\Sales\Model\Resource\Order\Status\History\Collection as HistoryColle * @method \Magento\Sales\Model\Order setShippingInclTax(float $value) * @method float getBaseShippingInclTax() * @method \Magento\Sales\Model\Order setBaseShippingInclTax(float $value) + * @method bool hasBillingAddressId() + * @method \Magento\Sales\Model\Order unsBillingAddressId() + * @method bool hasShippingAddressId() + * @method \Magento\Sales\Model\Order unsShippingAddressId() + * @method int getShippigAddressId() + * @method bool hasCustomerNoteNotify() + * @method bool hasForcedCanCreditmemo() + * @method bool getIsInProcess() + * @method \Magento\Customer\Model\Customer getCustomer() */ -class Order extends \Magento\Sales\Model\AbstractModel +class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterface { const ENTITY = 'order'; @@ -454,7 +462,7 @@ class Order extends \Magento\Sales\Model\AbstractModel protected $entityType = 'order'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -493,11 +501,6 @@ class Order extends \Magento\Sales\Model\AbstractModel */ protected $_currencyFactory; - /** - * @var \Magento\Eav\Model\Config - */ - protected $_eavConfig; - /** * @var \Magento\Sales\Model\Order\Status\HistoryFactory */ @@ -548,7 +551,7 @@ class Order extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Order\Config $orderConfig * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param Resource\Order\Item\CollectionFactory $orderItemCollectionFactory @@ -575,7 +578,7 @@ class Order extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Sales\Model\Resource\Order\Item\CollectionFactory $orderItemCollectionFactory, @@ -1176,11 +1179,17 @@ class Order extends \Magento\Sales\Model\AbstractModel * @param string|bool $status * @param string $comment * @param bool $isCustomerNotified + * @param bool $shouldProtectState * @return \Magento\Sales\Model\Order */ - public function setState($state, $status = false, $comment = '', $isCustomerNotified = null) - { - return $this->_setState($state, $status, $comment, $isCustomerNotified, true); + public function setState( + $state, + $status = false, + $comment = '', + $isCustomerNotified = null, + $shouldProtectState = true + ) { + return $this->_setState($state, $status, $comment, $isCustomerNotified, $shouldProtectState); } /** @@ -2127,135 +2136,6 @@ class Order extends \Magento\Sales\Model\AbstractModel return ''; } - /** - * Processing object before save data - * - * @return $this - */ - protected function _beforeSave() - { - parent::_beforeSave(); - $this->_checkState(); - if (!$this->getId()) { - $store = $this->getStore(); - $name = array($store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()); - $this->setStoreName(implode("\n", $name)); - } - - if (!$this->getIncrementId()) { - $incrementId = $this->_eavConfig->getEntityType('order')->fetchNewIncrementId($this->getStoreId()); - $this->setIncrementId($incrementId); - } - - /** - * Process items dependency for new order - */ - if (!$this->getId()) { - $itemsCount = 0; - foreach ($this->getAllItems() as $item) { - $parent = $item->getQuoteParentItemId(); - if ($parent && !$item->getParentItem()) { - $item->setParentItem($this->getItemByQuoteItemId($parent)); - } elseif (!$parent) { - $itemsCount++; - } - } - // Set items count - $this->setTotalItemCount($itemsCount); - } - /** TODO refactor getCustomer usage after MAGETWO-20182 and MAGETWO-20258 are done */ - $isNewCustomer = !$this->getCustomerId() || $this->getCustomerId() === true; - if ($isNewCustomer && $this->getCustomer()) { - $this->setCustomerId($this->getCustomer()->getId()); - } - - if ($this->hasBillingAddressId() && $this->getBillingAddressId() === null) { - $this->unsBillingAddressId(); - } - - if ($this->hasShippingAddressId() && $this->getShippingAddressId() === null) { - $this->unsShippingAddressId(); - } - - $this->setData('protect_code', substr(md5(uniqid(\Magento\Framework\Math\Random::getRandomNumber(), true) . ':' . microtime(true)), 5, 6)); - return $this; - } - - /** - * Check order state before saving - * - * @return $this - */ - protected function _checkState() - { - if (!$this->getId()) { - return $this; - } - - $userNotification = $this->hasCustomerNoteNotify() ? $this->getCustomerNoteNotify() : null; - - if (!$this->isCanceled() && !$this->canUnhold() && !$this->canInvoice() && !$this->canShip()) { - if (0 == $this->getBaseGrandTotal() || $this->canCreditmemo()) { - if ($this->getState() !== self::STATE_COMPLETE) { - $this->_setState(self::STATE_COMPLETE, true, '', $userNotification); - } - } elseif (floatval( - $this->getTotalRefunded() - ) || !$this->getTotalRefunded() && $this->hasForcedCanCreditmemo() - ) { - if ($this->getState() !== self::STATE_CLOSED) { - $this->_setState(self::STATE_CLOSED, true, '', $userNotification); - } - } - } - - if ($this->getState() == self::STATE_NEW && $this->getIsInProcess()) { - $this->setState(self::STATE_PROCESSING, true, '', $userNotification); - } - return $this; - } - - /** - * Save order related objects - * - * @return $this - */ - protected function _afterSave() - { - if (null !== $this->_addresses) { - $this->_addresses->save(); - $billingAddress = $this->getBillingAddress(); - $attributesForSave = array(); - if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) { - $this->setBillingAddressId($billingAddress->getId()); - $attributesForSave[] = 'billing_address_id'; - } - - $shippingAddress = $this->getShippingAddress(); - if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) { - $this->setShippingAddressId($shippingAddress->getId()); - $attributesForSave[] = 'shipping_address_id'; - } - - if (!empty($attributesForSave)) { - $this->_getResource()->saveAttribute($this, $attributesForSave); - } - } - if (null !== $this->_items) { - $this->_items->save(); - } - if (null !== $this->_payments) { - $this->_payments->save(); - } - if (null !== $this->_statusHistory) { - $this->_statusHistory->save(); - } - foreach ($this->getRelatedObjects() as $object) { - $object->save(); - } - return parent::_afterSave(); - } - /** * @return string */ @@ -2343,4 +2223,14 @@ class Order extends \Magento\Sales\Model\AbstractModel { return $this->getState() === self::STATE_CANCELED; } + + /** + * Returns increment id + * + * @return string + */ + public function getIncrementId() + { + return $this->getData('increment_id'); + } } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index 2a380d120e26660a06452705e214f20adc026ed7..5ac213c6df2e8f8f4985d58c5cdddf6d67d9ba41 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -24,6 +24,7 @@ namespace Magento\Sales\Model\Order; use Magento\Framework\Model\Exception; +use Magento\Sales\Model\EntityInterface; /** * Order creditmemo model @@ -101,7 +102,6 @@ use Magento\Framework\Model\Exception; * @method \Magento\Sales\Model\Order\Creditmemo setGlobalCurrencyCode(string $value) * @method string getTransactionId() * @method \Magento\Sales\Model\Order\Creditmemo setTransactionId(string $value) - * @method string getIncrementId() * @method \Magento\Sales\Model\Order\Creditmemo setIncrementId(string $value) * @method string getCreatedAt() * @method \Magento\Sales\Model\Order\Creditmemo setCreatedAt(string $value) @@ -120,7 +120,7 @@ use Magento\Framework\Model\Exception; * @method float getBaseShippingInclTax() * @method \Magento\Sales\Model\Order\Creditmemo setBaseShippingInclTax(float $value) */ -class Creditmemo extends \Magento\Sales\Model\AbstractModel +class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInterface { const STATE_OPEN = 1; @@ -197,7 +197,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel protected $_calculatorFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -220,7 +220,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory * @param \Magento\Framework\Math\CalculatorFactory $calculatorFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Creditmemo\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -236,7 +236,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory, \Magento\Framework\Math\CalculatorFactory $calculatorFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Creditmemo\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -865,6 +865,16 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel return $this->getResourceCollection()->getFiltered($filter); } + /** + * Returns increment id + * + * @return string + */ + public function getIncrementId() + { + return $this->getData('increment_id'); + } + /** * @return bool */ diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php index 8a93f427a326d2a6172187a196ae5d77bf47cccc..b466129b38f350b9241945959c2b7013ff19c33d 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php @@ -47,7 +47,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel protected $_creditmemo; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,7 +56,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -66,7 +66,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php index 882527fca6bfa88a76ec39eb5444dfbcba40e4a5..61e6b2dbb9721fbddf4646d88faef948627ca1ec 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php @@ -29,7 +29,7 @@ namespace Magento\Sales\Model\Order\Creditmemo\Total; class Shipping extends AbstractTotal { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -39,12 +39,12 @@ class Shipping extends AbstractTotal protected $_taxConfig; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Tax\Model\Config $taxConfig * @param array $data */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Tax\Model\Config $taxConfig, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/Container.php b/app/code/Magento/Sales/Model/Order/Email/Container/Container.php index af38cf08fa7915a3024943561269126aa3bc69af..1b81dfb3ee80ab25f15e965c2db69ab14c7b0fea 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/Container.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/Container.php @@ -23,7 +23,7 @@ */ namespace Magento\Sales\Model\Order\Email\Container; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Store\Model\Store; use Magento\Framework\App\Config\ScopeConfigInterface; diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index e84ae0574a9d7e46a5f304bfc975e3f9958b685a..a4e40e2c48d9661441f7e0ab0e2973c7d2be0259 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Order; +use Magento\Sales\Model\EntityInterface; + /** * @method \Magento\Sales\Model\Resource\Order\Invoice _getResource() * @method \Magento\Sales\Model\Resource\Order\Invoice getResource() @@ -90,7 +92,6 @@ namespace Magento\Sales\Model\Order; * @method \Magento\Sales\Model\Order\Invoice setBaseCurrencyCode(string $value) * @method string getGlobalCurrencyCode() * @method \Magento\Sales\Model\Order\Invoice setGlobalCurrencyCode(string $value) - * @method string getIncrementId() * @method \Magento\Sales\Model\Order\Invoice setIncrementId(string $value) * @method string getCreatedAt() * @method \Magento\Sales\Model\Order\Invoice setCreatedAt(string $value) @@ -109,7 +110,7 @@ namespace Magento\Sales\Model\Order; * @method float getBaseShippingInclTax() * @method \Magento\Sales\Model\Order\Invoice setBaseShippingInclTax(float $value) */ -class Invoice extends \Magento\Sales\Model\AbstractModel +class Invoice extends \Magento\Sales\Model\AbstractModel implements EntityInterface { /** * Invoice states @@ -196,11 +197,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel */ protected $_orderFactory; - /** - * @var \Magento\Sales\Model\Resource\OrderFactory - */ - protected $_orderResourceFactory; - /** * @var \Magento\Framework\Math\CalculatorFactory */ @@ -228,7 +224,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param Invoice\Config $invoiceConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory * @param \Magento\Framework\Math\CalculatorFactory $calculatorFactory * @param \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory * @param Invoice\CommentFactory $invoiceCommentFactory @@ -244,7 +239,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Sales\Model\Order\Invoice\Config $invoiceConfig, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory, \Magento\Framework\Math\CalculatorFactory $calculatorFactory, \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory, \Magento\Sales\Model\Order\Invoice\CommentFactory $invoiceCommentFactory, @@ -255,7 +249,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel ) { $this->_invoiceConfig = $invoiceConfig; $this->_orderFactory = $orderFactory; - $this->_orderResourceFactory = $orderResourceFactory; $this->_calculatorFactory = $calculatorFactory; $this->_invoiceItemCollectionFactory = $invoiceItemCollectionFactory; $this->_invoiceCommentFactory = $invoiceCommentFactory; @@ -346,16 +339,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel return $this->entityType; } - /** - * Retrieve the increment_id of the order - * - * @return string - */ - public function getOrderIncrementId() - { - return $this->_orderResourceFactory->create()->getIncrementId($this->getOrderId()); - } - /** * Retrieve billing address * @@ -884,4 +867,14 @@ class Invoice extends \Magento\Sales\Model\AbstractModel return parent::_afterSave(); } + + /** + * Returns increment id + * + * @return string + */ + public function getIncrementId() + { + return $this->getData('increment_id'); + } } diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php index f4089d92426296f5719c6d8d8e5ea40bc7d7c5ef..5dd2befe00caeaea2548a7bf821835db2b4a1746 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php @@ -47,7 +47,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel protected $_invoice; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,7 +56,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -66,7 +66,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index c8e54b3cb96d7ba437e44a8fc9949da533200b38..3421b7680f591e89d13252d9522030ec83886f29 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -200,7 +200,7 @@ class Payment extends \Magento\Payment\Model\Info protected $_transactionCollectionFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -212,7 +212,7 @@ class Payment extends \Magento\Payment\Model\Info * @param \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory * @param \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory * @param \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -225,7 +225,7 @@ class Payment extends \Magento\Payment\Model\Info \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory, \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory, \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php index 513db26f27515a9a2008812710210f1df4c94e6f..28430cc641c3722e76a512a88fe45edcaf914e09 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php @@ -29,7 +29,7 @@ namespace Magento\Sales\Model\Order\Pdf; class Creditmemo extends AbstractPdf { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -43,7 +43,7 @@ class Creditmemo extends AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data * @@ -60,7 +60,7 @@ class Creditmemo extends AbstractPdf \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php index 8f5b345ed2166e4dcf7956b51fb7b2bed0d118ea..2221b2510871838297ddac3023e9222ee678f4b4 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php @@ -29,7 +29,7 @@ namespace Magento\Sales\Model\Order\Pdf; class Invoice extends AbstractPdf { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -47,7 +47,7 @@ class Invoice extends AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data @@ -64,7 +64,7 @@ class Invoice extends AbstractPdf \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php index bba9ed6562122c9f74a8cb0e0251f83586495312..f6362aea335fe95ed8a568c6a72e2f4ad9f0911b 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php @@ -29,7 +29,7 @@ namespace Magento\Sales\Model\Order\Pdf; class Shipment extends AbstractPdf { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -48,7 +48,7 @@ class Shipment extends AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data * @@ -64,7 +64,7 @@ class Shipment extends AbstractPdf \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index b8e7584cf7ba9913098e95ed9c56cb596a4b62ca..55b33c667aa42d5fcf2cf93dfe832c883f454d12 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Order; +use Magento\Sales\Model\EntityInterface; + /** * Sales order shipment model * @@ -46,14 +48,13 @@ namespace Magento\Sales\Model\Order; * @method \Magento\Sales\Model\Order\Shipment setBillingAddressId(int $value) * @method int getShipmentStatus() * @method \Magento\Sales\Model\Order\Shipment setShipmentStatus(int $value) - * @method string getIncrementId() * @method \Magento\Sales\Model\Order\Shipment setIncrementId(string $value) * @method string getCreatedAt() * @method \Magento\Sales\Model\Order\Shipment setCreatedAt(string $value) * @method string getUpdatedAt() * @method \Magento\Sales\Model\Order\Shipment setUpdatedAt(string $value) */ -class Shipment extends \Magento\Sales\Model\AbstractModel +class Shipment extends \Magento\Sales\Model\AbstractModel implements EntityInterface { const STATUS_NEW = 1; @@ -577,4 +578,14 @@ class Shipment extends \Magento\Sales\Model\AbstractModel } return $label; } + + /** + * Returns increment id + * + * @return string + */ + public function getIncrementId() + { + return $this->getData('increment_id'); + } } diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php index e1b0647e0ab94239dcb725fb91c0ccef064cd844..761e27cc002a5f296877ebf75770595df60c8b54 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php @@ -47,7 +47,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel protected $_shipment; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,7 +56,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -66,7 +66,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Order/Shipment/Track.php index a67442483d3e5a1b076fb1cd60cc66eb1a7feecc..023881d2d6e8759e72692e9c7069ec5bdfc3919d 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Track.php @@ -70,7 +70,7 @@ class Track extends \Magento\Sales\Model\AbstractModel protected $_eventObject = 'track'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -84,7 +84,7 @@ class Track extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -95,7 +95,7 @@ class Track extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Sales/Model/Order/Status.php b/app/code/Magento/Sales/Model/Order/Status.php index a978baab62c5627e67d4ef886ef34c8ff04a2317..743c033c0886626c59da309dcf51c4325d3b4eb9 100644 --- a/app/code/Magento/Sales/Model/Order/Status.php +++ b/app/code/Magento/Sales/Model/Order/Status.php @@ -34,14 +34,14 @@ use Magento\Framework\Model\Exception; class Status extends \Magento\Framework\Model\AbstractModel { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -49,7 +49,7 @@ class Status extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Status/History.php b/app/code/Magento/Sales/Model/Order/Status/History.php index f4e3cfe140146901a4e08eada43611b189d846af..8f5d8ad3e84230c5970333eb1c13d12d62fec088 100644 --- a/app/code/Magento/Sales/Model/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Order/Status/History.php @@ -62,7 +62,7 @@ class History extends \Magento\Sales\Model\AbstractModel protected $_eventObject = 'status_history'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -71,7 +71,7 @@ class History extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -81,7 +81,7 @@ class History extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php index eaadb6a48530639a6122fc9974c5a88959e4aa4d..d20517b11e5057492d39c02ca0192b38edd8a29f 100644 --- a/app/code/Magento/Sales/Model/Quote.php +++ b/app/code/Magento/Sales/Model/Quote.php @@ -215,7 +215,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -320,7 +320,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param Quote\AddressFactory $quoteAddressFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory @@ -349,7 +349,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel \Magento\Sales\Helper\Data $salesData, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, diff --git a/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php b/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php index fe5578c945f0c375c1e909b5697cf0aa794734ba..14f1a9b598dff6e8dc8db523550bfb502ef3e3ea 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php +++ b/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php @@ -35,15 +35,15 @@ namespace Magento\Sales\Model\Quote\Address\RateResult; class Method extends AbstractResult { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, array $data = array()) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager, array $data = array()) { $this->_storeManager = $storeManager; parent::__construct($data); diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php index 9cf2d4ccf8aa84e72b2c60f21367882ff2e6e89a..1466c4647fa6c680a676643bd9e0382e09538617 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php @@ -83,7 +83,7 @@ class Collector extends \Magento\Sales\Model\Config\Ordered * @param \Magento\Framework\Logger $logger * @param \Magento\Sales\Model\Config $salesConfig * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Quote\Address\TotalFactory $totalFactory * @param mixed $sourceData * @param mixed $store @@ -93,7 +93,7 @@ class Collector extends \Magento\Sales\Model\Config\Ordered \Magento\Framework\Logger $logger, \Magento\Sales\Model\Config $salesConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Quote\Address\TotalFactory $totalFactory, $sourceData = null, $store = null diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Discount.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Discount.php index a194b17d1ae082022473d29f8f0205acd1f21002..eba67b299f9a0c34a04e41441b23c19d512c161c 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Discount.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/Discount.php @@ -33,17 +33,17 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal protected $_eventManager = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_eventManager = $eventManager; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Sales/Model/Quote/Item/Processor.php b/app/code/Magento/Sales/Model/Quote/Item/Processor.php index f64746d0f6339ac16be23d1a688165ac63fc06ef..90b935ef5e256ee793a9fca585fce2e71b3717d7 100644 --- a/app/code/Magento/Sales/Model/Quote/Item/Processor.php +++ b/app/code/Magento/Sales/Model/Quote/Item/Processor.php @@ -26,7 +26,7 @@ namespace Magento\Sales\Model\Quote\Item; use \Magento\Catalog\Model\Product; use \Magento\Sales\Model\Quote\ItemFactory; use \Magento\Sales\Model\Quote\Item; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Framework\App\State; use \Magento\Framework\Object; @@ -43,7 +43,7 @@ class Processor protected $quoteItemFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/Sales/Model/QuoteRepository.php b/app/code/Magento/Sales/Model/QuoteRepository.php index c7c185205217d03af7168aacfc98d9848c5803ec..eb05fbc9e8dae64571990a9ad1d15e77da68de44 100644 --- a/app/code/Magento/Sales/Model/QuoteRepository.php +++ b/app/code/Magento/Sales/Model/QuoteRepository.php @@ -33,17 +33,17 @@ class QuoteRepository protected $quoteFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param QuoteFactory $quoteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Sales\Model\QuoteFactory $quoteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteFactory = $quoteFactory; $this->storeManager = $storeManager; diff --git a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php new file mode 100644 index 0000000000000000000000000000000000000000..01da9011b074b98e18bc1bbdf9f7e86c9afe9742 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php @@ -0,0 +1,100 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource; + +use Magento\Framework\Model\Resource\Db\AbstractDb; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class AbstractGrid + */ +abstract class AbstractGrid extends AbstractDb implements GridInterface +{ + /** + * @var AdapterInterface + */ + protected $connection; + + /** + * @var string + */ + protected $gridTableName; + + /** + * @var string + */ + protected $orderTableName = 'sales_flat_order'; + + /** + * @var string + */ + protected $addressTableName = 'sales_flat_order_address'; + + /** + * @param AppResource $resource + */ + public function __construct(AppResource $resource) + { + parent::__construct($resource); + } + + /** + * Resource initialization + * + * @return void + */ + protected function _construct() + { + // + } + + /** + * Returns connection + * + * @return AdapterInterface + */ + protected function getConnection() + { + if (!$this->connection) { + $this->connection = $this->_resources->getConnection('write'); + } + return $this->connection; + } + + /** + * Purge grid row + * + * @param int|string $value + * @param null|string $field + * @return int + */ + public function purge($value, $field = null) + { + return $this->getConnection()->delete( + $this->getTable($this->gridTableName), + [($field ?: 'entity_id') . ' = ?' => $value] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/AbstractResource.php b/app/code/Magento/Sales/Model/Resource/AbstractResource.php index 379b55361c53bcd3a2532d7db5396380130af4f0..ffeb1db2bd436926d3926e9556d60cc6a853844d 100644 --- a/app/code/Magento/Sales/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Sales/Model/Resource/AbstractResource.php @@ -39,8 +39,10 @@ abstract class AbstractResource extends \Magento\Framework\Model\Resource\Db\Abs * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime */ - public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime) - { + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime + ) { $this->dateTime = $dateTime; parent::__construct($resource); } diff --git a/app/code/Magento/Sales/Model/Resource/Attribute.php b/app/code/Magento/Sales/Model/Resource/Attribute.php new file mode 100644 index 0000000000000000000000000000000000000000..6d0c719e4b1cb7a1b2f792a3eb94de106b8bf051 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Attribute.php @@ -0,0 +1,154 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource; + +use Magento\Framework\App\Resource as AppResource; +use Magento\Framework\Event\ManagerInterface as EventManager; +use Magento\Sales\Model\AbstractModel; +use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; + +class Attribute +{ + /** + * @var \Magento\Framework\App\Resource + */ + protected $resource; + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface + */ + protected $connection; + /** + * @var \Magento\Framework\Event\ManagerInterface + */ + protected $eventManager; + + /** + * @param AppResource $resource + * @param EventManager $eventManager + */ + public function __construct( + AppResource $resource, + EventManager $eventManager + ) { + $this->resource = $resource; + $this->eventManager = $eventManager; + } + + /** + * @return \Magento\Framework\DB\Adapter\AdapterInterface + */ + protected function getConnection() + { + if (!$this->connection) { + $this->connection = $this->resource->getConnection('write'); + } + return $this->connection; + } + + /** + * Before save object attribute + * + * @param AbstractModel $object + * @param string $attribute + * @return \Magento\Sales\Model\Resource\Attribute + */ + protected function _beforeSaveAttribute(AbstractModel $object, $attribute) + { + if ($object->getEventObject() && $object->getEventPrefix()) { + $this->eventManager->dispatch( + $object->getEventPrefix() . '_save_attribute_before', + [ + $object->getEventObject() => $this, + 'object' => $object, + 'attribute' => $attribute + ] + ); + } + return $this; + } + + /** + * Perform actions after object save + * + * @param AbstractModel $object + * @param string $attribute + * @return $this + * @throws \Exception + */ + public function saveAttribute(AbstractModel $object, $attribute) + { + if ($attribute instanceof AbstractAttribute) { + $attributes = $attribute->getAttributeCode(); + } elseif (is_string($attribute)) { + $attributes = [$attribute]; + } else { + $attributes = $attribute; + } + if (is_array($attributes) && !empty($attributes)) { + $this->getConnection()->beginTransaction(); + $data = array_intersect_key($object->getData(), array_flip($attributes)); + try { + $this->_beforeSaveAttribute($object, $attributes); + if ($object->getId() && !empty($data)) { + $this->getConnection()->update( + $object->getResource()->getMainTable(), + $data, + [$object->getResource()->getIdFieldName() . '= ?' => (int)$object->getId()] + ); + $object->addData($data); + } + $this->_afterSaveAttribute($object, $attributes); + $this->getConnection()->commit(); + } catch (\Exception $e) { + $this->getConnection()->rollBack(); + throw $e; + } + } + return $this; + } + + /** + * After save object attribute + * + * @param AbstractModel $object + * @param string $attribute + * @return \Magento\Sales\Model\Resource\Attribute + */ + protected function _afterSaveAttribute(AbstractModel $object, $attribute) + { + if ($object->getEventObject() && $object->getEventPrefix()) { + $this->eventManager->dispatch( + $object->getEventPrefix() . '_save_attribute_after', + [ + $object->getEventObject() => $this, + 'object' => $object, + 'attribute' => $attribute + ] + ); + } + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php b/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php index b3a6a756071bbd0104478d1e6bd35bdd6f692f7b..c9bd1f775270ab148466cc9d8707abfaa43e97fd 100644 --- a/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php +++ b/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php @@ -30,6 +30,36 @@ namespace Magento\Sales\Model\Resource\Collection; */ abstract class AbstractCollection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection { + /** + * @var \Zend_Db_Select + */ + protected $_countSelect; + + /** + * Set select count sql + * + * @param \Zend_Db_Select $countSelect + * @return $this + */ + public function setSelectCountSql(\Zend_Db_Select $countSelect) + { + $this->_countSelect = $countSelect; + return $this; + } + + /** + * get select count sql + * + * @return \Zend_Db_Select + */ + public function getSelectCountSql() + { + if (!$this->_countSelect instanceof \Zend_Db_Select) { + $this->setSelectCountSql(parent::getSelectCountSql()); + } + return $this->_countSelect; + } + /** * Check if $attribute is \Magento\Eav\Model\Entity\Attribute and convert to string field name * diff --git a/app/code/Magento/Sales/Model/Resource/Entity.php b/app/code/Magento/Sales/Model/Resource/Entity.php new file mode 100644 index 0000000000000000000000000000000000000000..c4109d065d97a3fc1e3633c39c558d09b4bc101d --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Entity.php @@ -0,0 +1,167 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource; + +use Magento\Sales\Model\EntityInterface; + +/** + * Flat sales resource abstract + */ +abstract class Entity extends AbstractResource +{ + /** + * Event prefix + * + * @var string + */ + protected $_eventPrefix = 'sales_order_resource'; + + /** + * Event object + * + * @var string + */ + protected $_eventObject = 'resource'; + + /** + * Use additional is object new check for this resource + * + * @var bool + */ + protected $_useIsObjectNew = true; + + /** + * @var \Magento\Eav\Model\Entity\TypeFactory + */ + protected $_eavEntityTypeFactory; + + /** + * @var \Magento\Sales\Model\Resource\Attribute + */ + protected $attribute; + + /** + * @var \Magento\Sales\Model\Increment + */ + protected $salesIncrement; + + /** + * @var \Magento\Sales\Model\Resource\GridInterface + */ + protected $gridAggregator; + + /** + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement + * @param GridInterface|null $gridAggregator + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null + ) { + $this->attribute = $attribute; + $this->salesIncrement = $salesIncrement; + $this->gridAggregator = $gridAggregator; + parent::__construct($resource, $dateTime); + } + + /** + * Perform actions after object save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @param string $attribute + * @return $this + * @throws \Exception + */ + public function saveAttribute(\Magento\Framework\Model\AbstractModel $object, $attribute) + { + $this->attribute->saveAttribute($object, $attribute); + return $this; + } + + /** + * Perform actions before object save + * + * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\Object $object + * @return $this + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + if ($object instanceof EntityInterface && $object->getIncrementId() == null) { + $object->setIncrementId($this->salesIncrement->getNextValue($object->getStoreId())); + } + parent::_beforeSave($object); + return $this; + } + + /** + * Save object data + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + public function save(\Magento\Framework\Model\AbstractModel $object) + { + if (!$object->getForceObjectSave()) { + parent::save($object); + } + + return $this; + } + + /** + * Perform actions after object save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) + { + if ($this->gridAggregator) { + $this->gridAggregator->refresh($object->getId()); + } + parent::_afterSave($object); + return $this; + } + + /** + * Perform actions after object delete + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _afterDelete(\Magento\Framework\Model\AbstractModel $object) + { + if ($this->gridAggregator) { + $this->gridAggregator->purge($object->getId()); + } + parent::_afterDelete($object); + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/GridInterface.php b/app/code/Magento/Sales/Model/Resource/GridInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..041eb887e2f03662f7faf8fa4ab5adbe64904482 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/GridInterface.php @@ -0,0 +1,45 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource; + +/** + * Interface GridInterface + */ +interface GridInterface +{ + /** + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null); + + /** + * @param int|string $value + * @param null|string $field + * @return int + */ + public function purge($value, $field = null); +} diff --git a/app/code/Magento/Sales/Model/Resource/GridPool.php b/app/code/Magento/Sales/Model/Resource/GridPool.php new file mode 100644 index 0000000000000000000000000000000000000000..bc9644bd8a144be77efd337396558bb1e01eb42c --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/GridPool.php @@ -0,0 +1,73 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource; + +use Magento\Sales\Model\Resource\GridInterface; +use Magento\Sales\Model\Resource\Order\Grid as OrderGrid; +use Magento\Sales\Model\Resource\Order\Invoice\Grid as InvoiceGrid; +use Magento\Sales\Model\Resource\Order\Shipment\Grid as ShipmentGrid; +use Magento\Sales\Model\Resource\Order\Creditmemo\Grid as CreditmemoGrid; + +class GridPool +{ + /** + * @var GridInterface[] + */ + protected $grids; + + /** + * @param OrderGrid $orderGrid + * @param InvoiceGrid $invoiceGrid + * @param ShipmentGrid $shipmentGrid + * @param CreditmemoGrid $creditmemoGrid + */ + public function __construct( + OrderGrid $orderGrid, + InvoiceGrid $invoiceGrid, + ShipmentGrid $shipmentGrid, + CreditmemoGrid $creditmemoGrid + ) { + $this->grids = [ + 'order_grid' => $orderGrid, + 'invoice_grid' => $invoiceGrid, + 'shipment_grid' => $shipmentGrid, + 'creditmemo_grid' => $creditmemoGrid + ]; + } + + /** + * Refresh grids list + * + * @param int $orderId + * @return $this + */ + public function refreshByOrderId($orderId) + { + foreach ($this->grids as $grid) { + $grid->refresh($orderId, 'sfo.entity_id'); + } + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order.php b/app/code/Magento/Sales/Model/Resource/Order.php index 05bd41ac2fc2627e4ecef247a4cf3e7cbd77fa78..0950d18db3270e4b0703de0d221e1754b4fbfcfd 100644 --- a/app/code/Magento/Sales/Model/Resource/Order.php +++ b/app/code/Magento/Sales/Model/Resource/Order.php @@ -23,12 +23,21 @@ */ namespace Magento\Sales\Model\Resource; +use Magento\Framework\Math\Random; +use Magento\Framework\App\Resource as AppResource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Increment as SalesIncrement; +use Magento\Sales\Model\Resource\Entity as SalesResource; +use Magento\Sales\Model\Resource\Order\Handler\State as StateHandler; +use Magento\Sales\Model\Resource\Order\Handler\Address as AddressHandler; +use Magento\Sales\Model\Resource\Order\Grid as OrderGrid; + /** * Flat sales order resource * * @author Magento Core Team <core@magentocommerce.com> */ -class Order extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Order extends SalesResource { /** * Event prefix @@ -45,25 +54,14 @@ class Order extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $_eventObject = 'resource'; /** - * Is grid - * - * @var bool - */ - protected $_grid = true; - - /** - * Use increment id - * - * @var bool + * @var StateHandler */ - protected $_useIncrementId = true; + protected $stateHandler; /** - * Entity code for increment id - * - * @var string + * @var AddressHandler */ - protected $_entityCodeForIncrementId = 'order'; + protected $addressHandler; /** * Model Initialization @@ -76,30 +74,26 @@ class Order extends \Magento\Sales\Model\Resource\Order\AbstractOrder } /** - * Init virtual grid records for entity - * - * @return $this + * @param AppResource $resource + * @param DateTime $dateTime + * @param Attribute $attribute + * @param SalesIncrement $salesIncrement + * @param AddressHandler $addressHandler + * @param StateHandler $stateHandler + * @param OrderGrid $gridAggregator */ - protected function _initVirtualGridColumns() - { - parent::_initVirtualGridColumns(); - $adapter = $this->getReadConnection(); - $ifnullFirst = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote('')); - $ifnullLast = $adapter->getIfNullSql('{{table}}.lastname', $adapter->quote('')); - $concatAddress = $adapter->getConcatSql(array($ifnullFirst, $adapter->quote(' '), $ifnullLast)); - $this->addVirtualGridColumn( - 'billing_name', - 'sales_flat_order_address', - array('billing_address_id' => 'entity_id'), - $concatAddress - )->addVirtualGridColumn( - 'shipping_name', - 'sales_flat_order_address', - array('shipping_address_id' => 'entity_id'), - $concatAddress - ); - - return $this; + public function __construct( + AppResource $resource, + DateTime $dateTime, + Attribute $attribute, + SalesIncrement $salesIncrement, + AddressHandler $addressHandler, + StateHandler $stateHandler, + OrderGrid $gridAggregator + ) { + $this->stateHandler = $stateHandler; + $this->addressHandler = $addressHandler; + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** @@ -133,21 +127,79 @@ class Order extends \Magento\Sales\Model\Resource\Order\AbstractOrder } /** - * Retrieve order_increment_id by order_id + * Process items dependency for new order, returns qty of affected items; * - * @param int $orderId - * @return string + * @param \Magento\Sales\Model\Order $object + * @return int */ - public function getIncrementId($orderId) + protected function calculateItems(\Magento\Sales\Model\Order $object) { - $adapter = $this->getReadConnection(); - $bind = array(':entity_id' => $orderId); - $select = $adapter->select()->from( - $this->getMainTable(), - array("increment_id") - )->where( - 'entity_id = :entity_id' + $itemsCount = 0; + if (!$object->getId()) { + foreach ($object->getAllItems() as $item) { + /** @var \Magento\Sales\Model\Order\Item $item */ + $parent = $item->getQuoteParentItemId(); + if ($parent && !$item->getParentItem()) { + $item->setParentItem($object->getItemByQuoteItemId($parent)); + } elseif (!$parent) { + $itemsCount++; + } + } + } + return $itemsCount; + } + + /** + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + /** @var \Magento\Sales\Model\Order $object */ + $this->addressHandler->removeEmptyAddresses($object); + $this->stateHandler->check($object); + if (!$object->getId()) { + /** @var \Magento\Store\Model\Store $store */ + $store = $object->getStore(); + $name = [ + $store->getWebsite()->getName(), + $store->getGroup()->getName(), + $store->getName() + ]; + $object->setStoreName(implode("\n", $name)); + } + $object->setTotalItemCount($this->calculateItems($object)); + $object->setData( + 'protect_code', + substr(md5(uniqid(Random::getRandomNumber(), true) . ':' . microtime(true)), 5, 6) ); - return $adapter->fetchOne($select, $bind); + $isNewCustomer = !$object->getCustomerId() || $object->getCustomerId() === true; + if ($isNewCustomer && $object->getCustomer()) { + $object->setCustomerId($object->getCustomer()->getId()); + } + return parent::_beforeSave($object); + } + + /** + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) + { + /** @var \Magento\Sales\Model\Order $object */ + $this->addressHandler->process($object); + if (null !== $object->getItemsCollection()) { + $object->getItemsCollection()->save(); + } + if (null !== $object->getPaymentsCollection()) { + $object->getPaymentsCollection()->save(); + } + if (null !== $object->getStatusHistoryCollection()) { + $object->getStatusHistoryCollection()->save(); + } + foreach ($object->getRelatedObjects() as $relatedObject) { + $relatedObject->save(); + } + return parent::_afterSave($object); } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php b/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php deleted file mode 100644 index 63acd2501c7a634be73486e6baf4883f8666e540..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php +++ /dev/null @@ -1,479 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Model\Resource\Order; - -/** - * Flat sales resource abstract - */ -abstract class AbstractOrder extends \Magento\Sales\Model\Resource\AbstractResource -{ - /** - * Is grid available - * - * @var bool - */ - protected $_grid = false; - - /** - * Use additional is object new check for this resource - * - * @var bool - */ - protected $_useIsObjectNew = true; - - /** - * Flag for using of increment id - * - * @var bool - */ - protected $_useIncrementId = false; - - /** - * Entity code for increment id (Eav entity code) - * - * @var string - */ - protected $_entityTypeForIncrementId = ''; - - /** - * Grid virtual columns - * - * @var array|null - */ - protected $_virtualGridColumns = null; - - /** - * Grid columns - * - * @var array|null - */ - protected $_gridColumns = null; - - /** - * Event prefix - * - * @var string - */ - protected $_eventPrefix = 'sales_resource'; - - /** - * Event object - * - * @var string - */ - protected $_eventObject = 'resource'; - - /** - * Core event manager proxy - * - * @var \Magento\Framework\Event\ManagerInterface - */ - protected $_eventManager = null; - - /** - * @var \Magento\Eav\Model\Entity\TypeFactory - */ - protected $_eavEntityTypeFactory; - - /** - * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory - */ - public function __construct( - \Magento\Framework\App\Resource $resource, - \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory - ) { - $this->_eventManager = $eventManager; - $this->_eavEntityTypeFactory = $eavEntityTypeFactory; - parent::__construct($resource, $dateTime); - } - - /** - * Add new virtual grid column - * - * @param string $alias - * @param string $table - * @param array $joinCondition - * @param string $column - * @return $this - * @throws \Magento\Framework\Model\Exception - */ - public function addVirtualGridColumn($alias, $table, $joinCondition, $column) - { - $table = $this->getTable($table); - - if (!in_array($alias, $this->getGridColumns())) { - throw new \Magento\Framework\Model\Exception( - __('Please specify a valid grid column alias name that exists in the grid table.') - ); - } - - $this->_virtualGridColumns[$alias] = array($table, $joinCondition, $column); - - return $this; - } - - /** - * Retrieve virtual grid columns - * - * @return array - */ - public function getVirtualGridColumns() - { - if ($this->_virtualGridColumns === null) { - $this->_initVirtualGridColumns(); - } - - return $this->_virtualGridColumns; - } - - /** - * Init virtual grid records for entity - * - * @return $this - */ - protected function _initVirtualGridColumns() - { - $this->_virtualGridColumns = array(); - if ($this->_eventPrefix && $this->_eventObject) { - $this->_eventManager->dispatch( - $this->_eventPrefix . '_init_virtual_grid_columns', - array($this->_eventObject => $this) - ); - } - return $this; - } - - /** - * Update records in grid table - * - * @param array|int $ids - * @return $this - */ - public function updateGridRecords($ids) - { - if ($this->_grid) { - if (!is_array($ids)) { - $ids = array($ids); - } - - if ($this->_eventPrefix && $this->_eventObject) { - $proxy = new \Magento\Framework\Object(); - $proxy->setIds($ids)->setData($this->_eventObject, $this); - - $this->_eventManager->dispatch($this->_eventPrefix . '_update_grid_records', array('proxy' => $proxy)); - $ids = $proxy->getIds(); - } - - if (empty($ids)) { - // If nothing to update - return $this; - } - $columnsToSelect = array(); - $table = $this->getGridTable(); - $select = $this->getUpdateGridRecordsSelect($ids, $columnsToSelect); - $this->_getWriteAdapter()->query($select->insertFromSelect($table, $columnsToSelect, true)); - } - - return $this; - } - - /** - * Retrieve update grid records select - * - * @param array $ids - * @param array &$flatColumnsToSelect - * @param array|null $gridColumns - * @return \Magento\Framework\DB\Select - */ - public function getUpdateGridRecordsSelect($ids, &$flatColumnsToSelect, $gridColumns = null) - { - $flatColumns = array_keys($this->_getReadAdapter()->describeTable($this->getMainTable())); - - if ($gridColumns === null) { - $gridColumns = $this->getGridColumns(); - } - - $flatColumnsToSelect = array_intersect($flatColumns, $gridColumns); - - $select = $this->_getWriteAdapter()->select()->from( - array('main_table' => $this->getMainTable()), - $flatColumnsToSelect - )->where( - 'main_table.' . $this->getIdFieldName() . ' IN(?)', - $ids - ); - - $this->joinVirtualGridColumnsToSelect('main_table', $select, $flatColumnsToSelect); - - return $select; - } - - /** - * Join virtual grid columns to select - * - * @param string $mainTableAlias - * @param \Zend_Db_Select $select - * @param array &$columnsToSelect - * @return $this - */ - public function joinVirtualGridColumnsToSelect($mainTableAlias, \Zend_Db_Select $select, &$columnsToSelect) - { - $adapter = $this->_getWriteAdapter(); - foreach ($this->getVirtualGridColumns() as $alias => $expression) { - list($table, $joinCondition, $column) = $expression; - $tableAlias = 'table_' . $alias; - - $joinConditionExpr = array(); - foreach ($joinCondition as $fkField => $pkField) { - $pkField = $adapter->quoteIdentifier($tableAlias . '.' . $pkField); - $fkField = $adapter->quoteIdentifier($mainTableAlias . '.' . $fkField); - $joinConditionExpr[] = $fkField . '=' . $pkField; - } - - $select->joinLeft( - array($tableAlias => $table), - implode(' AND ', $joinConditionExpr), - array($alias => str_replace('{{table}}', $tableAlias, $column)) - ); - - $columnsToSelect[] = $alias; - } - - return $this; - } - - /** - * Retrieve list of grid columns - * - * @return array - */ - public function getGridColumns() - { - if ($this->_gridColumns === null) { - if ($this->_grid) { - $this->_gridColumns = array_keys($this->_getReadAdapter()->describeTable($this->getGridTable())); - } else { - $this->_gridColumns = array(); - } - } - - return $this->_gridColumns; - } - - /** - * Retrieve grid table - * - * @return string - */ - public function getGridTable() - { - if ($this->_grid) { - return $this->getTable($this->_mainTable . '_grid'); - } - return false; - } - - /** - * Before save object attribute - * - * @param \Magento\Framework\Model\AbstractModel $object - * @param string $attribute - * @return $this - */ - protected function _beforeSaveAttribute(\Magento\Framework\Model\AbstractModel $object, $attribute) - { - if ($this->_eventObject && $this->_eventPrefix) { - $this->_eventManager->dispatch( - $this->_eventPrefix . '_save_attribute_before', - array($this->_eventObject => $this, 'object' => $object, 'attribute' => $attribute) - ); - } - return $this; - } - - /** - * After save object attribute - * - * @param \Magento\Framework\Model\AbstractModel $object - * @param string $attribute - * @return $this - */ - protected function _afterSaveAttribute(\Magento\Framework\Model\AbstractModel $object, $attribute) - { - if ($this->_eventObject && $this->_eventPrefix) { - $this->_eventManager->dispatch( - $this->_eventPrefix . '_save_attribute_after', - array($this->_eventObject => $this, 'object' => $object, 'attribute' => $attribute) - ); - } - return $this; - } - - /** - * Perform actions after object save - * - * @param \Magento\Framework\Model\AbstractModel $object - * @param string $attribute - * @return $this - * @throws \Exception - */ - public function saveAttribute(\Magento\Framework\Model\AbstractModel $object, $attribute) - { - if ($attribute instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute) { - $attribute = $attribute->getAttributeCode(); - } - - if (is_string($attribute)) { - $attribute = array($attribute); - } - - if (is_array($attribute) && !empty($attribute)) { - $this->beginTransaction(); - try { - $this->_beforeSaveAttribute($object, $attribute); - $data = new \Magento\Framework\Object(); - foreach ($attribute as $code) { - $data->setData($code, $object->getData($code)); - } - - $updateArray = $this->_prepareDataForTable($data, $this->getMainTable()); - $this->_postSaveFieldsUpdate($object, $updateArray); - if (!$object->getForceUpdateGridRecords() && count( - array_intersect($this->getGridColumns(), $attribute) - ) > 0 - ) { - $this->updateGridRecords($object->getId()); - } - $this->_afterSaveAttribute($object, $attribute); - $this->commit(); - } catch (\Exception $e) { - $this->rollBack(); - throw $e; - } - } - - return $this; - } - - /** - * Perform actions before object save - * - * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\Object $object - * @return $this - */ - protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) - { - if ($this->_useIncrementId && !$object->getIncrementId()) { - /* @var $entityType \Magento\Eav\Model\Entity\Type */ - $entityType = $this->_eavEntityTypeFactory->create()->loadByCode($this->_entityTypeForIncrementId); - $object->setIncrementId($entityType->fetchNewIncrementId($object->getStoreId())); - } - parent::_beforeSave($object); - return $this; - } - - /** - * Update field in table if model have been already saved - * - * @param \Magento\Framework\Model\AbstractModel $object - * @param array $data - * @return $this - */ - protected function _postSaveFieldsUpdate($object, $data) - { - if ($object->getId() && !empty($data)) { - $table = $this->getMainTable(); - $this->_getWriteAdapter()->update( - $table, - $data, - array($this->getIdFieldName() . '=?' => (int)$object->getId()) - ); - $object->addData($data); - } - - return $this; - } - - /** - * Set main resource table - * - * @param string $table - * @return $this - */ - public function setMainTable($table) - { - $this->_mainTable = $table; - return $this; - } - - /** - * Save object data - * - * @param \Magento\Framework\Model\AbstractModel $object - * @return $this - */ - public function save(\Magento\Framework\Model\AbstractModel $object) - { - if (!$object->getForceObjectSave()) { - parent::save($object); - } - - return $this; - } - - /** - * Update grid table on entity update - * - * @param string $field - * @param int $entityId - * @return $this - */ - public function updateOnRelatedRecordChanged($field, $entityId) - { - $adapter = $this->_getWriteAdapter(); - $column = array(); - $select = $adapter->select()->from( - array('main_table' => $this->getMainTable()), - $column - )->where( - 'main_table.' . $field . ' = ?', - $entityId - ); - $this->joinVirtualGridColumnsToSelect('main_table', $select, $column); - $fieldsToUpdate = $adapter->fetchRow($select); - if ($fieldsToUpdate) { - $adapter->update( - $this->getGridTable(), - $fieldsToUpdate, - $adapter->quoteInto($this->getGridTable() . '.' . $field . ' = ?', $entityId) - ); - } - return $this; - } -} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php index 7bb0070b82c8f430bff20ebcc5dde25696719af1..f71ab9835cb95caf58d28e5c74d6dfae5819135b 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php @@ -26,7 +26,7 @@ namespace Magento\Sales\Model\Resource\Order; /** * Flat sales order address resource */ -class Address extends AbstractOrder +class Address extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -36,34 +36,36 @@ class Address extends AbstractOrder protected $_eventPrefix = 'sales_order_address_resource'; /** - * @var \Magento\Sales\Model\Resource\Factory + * @var \Magento\Sales\Model\Order\Address\Validator */ - protected $_salesResourceFactory; + protected $_validator; /** - * @var \Magento\Sales\Model\Order\Address\Validator + * @var \Magento\Sales\Model\Resource\GridPool */ - protected $_validator; + protected $gridPool; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory - * @param \Magento\Sales\Model\Resource\Factory $salesResourceFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Address\Validator $validator + * @param \Magento\Sales\Model\Resource\GridPool $gridPool + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Resource\Factory $salesResourceFactory, - \Magento\Sales\Model\Order\Address\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Address\Validator $validator, + \Magento\Sales\Model\Resource\GridPool $gridPool, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->_validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); - $this->_salesResourceFactory = $salesResourceFactory; + $this->gridPool = $gridPool; + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } @@ -128,25 +130,9 @@ class Address extends AbstractOrder protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) { $resource = parent::_afterSave($object); - if ($object->hasDataChanges() && $object->getOrder()) { - $gridList = array( - 'Magento\Sales\Model\Resource\Order' => 'entity_id', - 'Magento\Sales\Model\Resource\Order\Invoice' => 'order_id', - 'Magento\Sales\Model\Resource\Order\Shipment' => 'order_id', - 'Magento\Sales\Model\Resource\Order\Creditmemo' => 'order_id' - ); - - // update grid table after grid update - foreach ($gridList as $gridResource => $field) { - $this->_salesResourceFactory->create( - $gridResource - )->updateOnRelatedRecordChanged( - $field, - $object->getParentId() - ); - } + if ($object->hasDataChanges() && $object->getOrderId()) { + $this->gridPool->refreshByOrderId($object->getOrderId()); } - return $resource; } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php b/app/code/Magento/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php index f1ce417d84369b4d29e6390f5a9635dc4839429d..c7f0e450a525c686ade16c1b273b2274f6dd9292 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php @@ -60,7 +60,8 @@ class Shipping extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke } if ($shippingAddressId) { $object->setShippingAddressId($shippingAddressId); - $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getAttributeCode()); + $this->getAttribute()->getEntity() + ->saveAttribute($object, $this->getAttribute()->getAttributeCode()); } } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php index 0fb9b047382e71bb77d64ffcfd663e02c690c9f3..8b77a19de463f30c4124af4aae5615edbcfad6ba 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php @@ -23,12 +23,17 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Framework\App\Resource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Resource\Entity as SalesResource; +use Magento\Sales\Model\Resource\Order\Creditmemo\Grid as CreditmemoGrid; + /** * Flat sales order creditmemo resource * * @author Magento Core Team <core@magentocommerce.com> */ -class Creditmemo extends AbstractOrder +class Creditmemo extends SalesResource { /** * Event prefix @@ -37,27 +42,6 @@ class Creditmemo extends AbstractOrder */ protected $_eventPrefix = 'sales_order_creditmemo_resource'; - /** - * Is grid available - * - * @var bool - */ - protected $_grid = true; - - /** - * Flag for using of increment id - * - * @var bool - */ - protected $_useIncrementId = true; - - /** - * Entity code for increment id (Eav entity code) - * - * @var string - */ - protected $_entityTypeForIncrementId = 'creditmemo'; - /** * Model initialization * @@ -67,37 +51,4 @@ class Creditmemo extends AbstractOrder { $this->_init('sales_flat_creditmemo', 'entity_id'); } - - /** - * Init virtual grid records for entity - * - * @return $this - */ - protected function _initVirtualGridColumns() - { - parent::_initVirtualGridColumns(); - $adapter = $this->getReadConnection(); - $checkedFirstname = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote('')); - $checkedLastname = $adapter->getIfNullSql('{{table}}.lastname', $adapter->quote('')); - $concatName = $adapter->getConcatSql(array($checkedFirstname, $adapter->quote(' '), $checkedLastname)); - - $this->addVirtualGridColumn( - 'billing_name', - 'sales_flat_order_address', - array('billing_address_id' => 'entity_id'), - $concatName - )->addVirtualGridColumn( - 'order_increment_id', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'increment_id' - )->addVirtualGridColumn( - 'order_created_at', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'created_at' - ); - - return $this; - } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php index 4ef922839f158c4c9b61554f25a3eb4629908ec5..c9db568fedf7477c1745a262978203f202ce5c79 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Creditmemo; * * @author Magento Core Team <core@magentocommerce.com> */ -class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Comment extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -45,23 +45,23 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $validator; /** - * Constructor - * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..25669e15b31dd6bdede284ae68482775fc63c0b0 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php @@ -0,0 +1,108 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Creditmemo; + +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName = 'sales_flat_creditmemo_grid'; + + /** + * @var string + */ + protected $creditmemoTableName = 'sales_flat_creditmemo'; + + /** + * Refresh grid row + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: 'sfc.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + [], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + return $this->getConnection()->select() + ->from(['sfc' => $this->getTable($this->creditmemoTableName)], []) + ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfc.order_id = sfo.entity_id', []) + ->joinLeft( + ['sba' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = sba.entity_id', + [] + ) + ->columns( + [ + 'entity_id' => 'sfc.entity_id', + 'store_id' => 'sfc.store_id', + 'store_to_order_rate' => 'sfc.store_to_order_rate', + 'base_to_order_rate' => 'sfc.base_to_order_rate', + 'grand_total' => 'sfc.grand_total', + 'store_to_base_rate' => 'sfc.store_to_base_rate', + 'base_to_global_rate' => 'sfc.base_to_global_rate', + 'base_grand_total' => 'sfc.base_grand_total', + 'order_id' => 'sfc.order_id', + 'creditmemo_status' => 'sfc.creditmemo_status', + 'state' => 'sfc.state', + 'invoice_id' => 'sfc.invoice_id', + 'store_currency_code' => 'sfc.store_currency_code', + 'order_currency_code' => 'sfc.order_currency_code', + 'base_currency_code' => 'sfc.base_currency_code', + 'global_currency_code' => 'sfc.global_currency_code', + 'increment_id' => 'sfc.increment_id', + 'order_increment_id' => 'sfo.increment_id', + 'created_at' => 'sfc.created_at', + 'order_created_at' => 'sfo.created_at', + 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))" + ] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php index f04b2892570fdfc8d9237c0d584e3448472b0e41..04cc496aa2e58d1c2b9a7dd1df610ad139952109 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Creditmemo; * * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Item extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..3d266fd5fcd8b177df86b6cfee499c87d46a1825 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Grid.php @@ -0,0 +1,102 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order; + +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName = 'sales_flat_order_grid'; + + /** + * Refresh grid row + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: 'sfo.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + [], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + return $this->getConnection()->select() + ->from(['sfo' => $this->getTable($this->orderTableName)], []) + ->joinLeft( + ['sba' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = sba.entity_id', + [] + ) + ->joinLeft( + ['ssa' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = ssa.entity_id', + [] + ) + ->columns( + [ + 'entity_id' => 'sfo.entity_id', + 'status' => 'sfo.status', + 'store_id' => 'sfo.store_id', + 'store_name' => 'sfo.store_name', + 'customer_id' => 'sfo.customer_id', + 'base_grand_total' => 'sfo.base_grand_total', + 'base_total_paid' => 'sfo.base_total_paid', + 'grand_total' => 'sfo.grand_total', + 'total_paid' => 'sfo.total_paid', + 'increment_id' => 'sfo.increment_id', + 'base_currency_code' => 'sfo.base_currency_code', + 'order_currency_code' => 'sfo.order_currency_code', + 'shipping_name' => "trim(concat(ifnull(ssa.firstname, ''), ' ' ,ifnull(ssa.lastname, '')))", + 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))", + 'created_at' => 'sfo.created_at', + 'updated_at' => 'sfo.updated_at' + ] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Handler/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Handler/Address.php new file mode 100644 index 0000000000000000000000000000000000000000..4cc006e771efc74d9923d5065049eed431dd47ea --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Handler/Address.php @@ -0,0 +1,95 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource\Order\Handler; + +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Resource\Attribute; + +/** + * Class Address + */ +class Address +{ + /** + * @var Attribute + */ + protected $attribute; + + /** + * @param Attribute $attribute + */ + public function __construct( + Attribute $attribute + ) { + $this->attribute = $attribute; + } + + /** + * Remove empty addresses from order + * + * @param Order $order + * @return $this + */ + public function removeEmptyAddresses(Order $order) + { + if ($order->hasBillingAddressId() && $order->getBillingAddressId() === null) { + $order->unsBillingAddressId(); + } + + if ($order->hasShippingAddressId() && $order->getShippingAddressId() === null) { + $order->unsShippingAddressId(); + } + return $this; + } + + /** + * Process addresses saving + * + * @param Order $order + * @return $this + * @throws \Exception + */ + public function process(Order $order) + { + if (null !== $order->getAddressesCollection()) { + $order->getAddressesCollection()->save(); + $billingAddress = $order->getBillingAddress(); + $attributesForSave = []; + if ($billingAddress && $order->getBillingAddressId() != $billingAddress->getId()) { + $order->setBillingAddressId($billingAddress->getId()); + $attributesForSave[] = 'billing_address_id'; + } + $shippingAddress = $order->getShippingAddress(); + if ($shippingAddress && $order->getShippigAddressId() != $shippingAddress->getId()) { + $order->setShippingAddressId($shippingAddress->getId()); + $attributesForSave[] = 'shipping_address_id'; + } + if (!empty($attributesForSave)) { + $this->attribute->saveAttribute($order, $attributesForSave); + } + } + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php b/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php new file mode 100644 index 0000000000000000000000000000000000000000..56b772fa83dc0d6d92122ff3bc2af286a6056408 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php @@ -0,0 +1,64 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource\Order\Handler; + +use Magento\Sales\Model\Order; + +/** + * Class State + */ +class State +{ + /** + * Check order status before save + * + * @param Order $order + * @return $this + */ + public function check(Order $order) + { + if (!$order->getId()) { + return $order; + } + $userNotification = $order->hasCustomerNoteNotify() ? $order->getCustomerNoteNotify() : null; + if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) { + if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) { + if ($order->getState() !== Order::STATE_COMPLETE) { + $order->setState(Order::STATE_COMPLETE, true, '', $userNotification, false); + } + } elseif (floatval($order->getTotalRefunded()) + || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo() + ) { + if ($order->getState() !== Order::STATE_CLOSED) { + $order->setState(Order::STATE_CLOSED, true, '', $userNotification, false); + } + } + } + if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) { + $order->setState(Order::STATE_PROCESSING, true, '', $userNotification); + } + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice.php index ce3e52fa6b9e948c0c927c4f1bf7bdd030bcba42..08e1918d8fb0ec4495ce9eb987cfd85c87dcfddf 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice.php @@ -23,12 +23,17 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Framework\App\Resource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Resource\Attribute; +use Magento\Sales\Model\Increment as SalesIncrement; +use Magento\Sales\Model\Resource\Entity as SalesResource; +use Magento\Sales\Model\Resource\Order\Invoice\Grid as InvoiceGrid; + /** * Flat sales order invoice resource - * - * @author Magento Core Team <core@magentocommerce.com> */ -class Invoice extends AbstractOrder +class Invoice extends SalesResource { /** * Event prefix @@ -37,27 +42,6 @@ class Invoice extends AbstractOrder */ protected $_eventPrefix = 'sales_order_invoice_resource'; - /** - * Is grid available - * - * @var bool - */ - protected $_grid = true; - - /** - * Flag for using of increment id - * - * @var bool - */ - protected $_useIncrementId = true; - - /** - * Entity code for increment id (Eav entity code) - * - * @var string - */ - protected $_entityTypeForIncrementId = 'invoice'; - /** * Model initialization * @@ -69,34 +53,19 @@ class Invoice extends AbstractOrder } /** - * Init virtual grid records for entity - * - * @return $this + * @param Resource $resource + * @param DateTime $dateTime + * @param Attribute $attribute + * @param SalesIncrement $salesIncrement + * @param InvoiceGrid $gridAggregator */ - protected function _initVirtualGridColumns() - { - parent::_initVirtualGridColumns(); - $adapter = $this->_getReadAdapter(); - $checkedFirstname = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote('')); - $checkedLastname = $adapter->getIfNullSql('{{table}}.lastname', $adapter->quote('')); - - $this->addVirtualGridColumn( - 'billing_name', - 'sales_flat_order_address', - array('billing_address_id' => 'entity_id'), - $adapter->getConcatSql(array($checkedFirstname, $adapter->quote(' '), $checkedLastname)) - )->addVirtualGridColumn( - 'order_increment_id', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'increment_id' - )->addVirtualGridColumn( - 'order_created_at', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'created_at' - ); - - return $this; + public function __construct( + Resource $resource, + DateTime $dateTime, + Attribute $attribute, + SalesIncrement $salesIncrement, + InvoiceGrid $gridAggregator + ) { + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php index 9dca32d432a76dc5cab352200b50270c9a7c4af1..6d3ce1e283e1cd971f30f5531efb250a887ec679 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Invoice; * * @author Magento Core Team <core@magentocommerce.com> */ -class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Comment extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -45,25 +45,28 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $validator; /** - * Constructor - * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } + + + /** * Model initialization * diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..1a68f9c05378e5c3d595c92949dce9994b62fc99 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php @@ -0,0 +1,102 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Invoice; + +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName = 'sales_flat_invoice_grid'; + + /** + * @var string + */ + protected $invoiceTableName = 'sales_flat_invoice'; + + /** + * Refresh grid row + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: 'sfi.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + [], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + return $this->getConnection()->select() + ->from(['sfi' => $this->getTable($this->invoiceTableName)], []) + ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfi.order_id = sfo.entity_id', []) + ->joinLeft( + ['sba' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = sba.entity_id', + [] + ) + ->columns( + [ + 'entity_id' => 'sfi.entity_id', + 'store_id' => 'sfi.store_id', + 'base_grand_total' => 'sfi.base_grand_total', + 'grand_total' => 'sfi.grand_total', + 'order_id' => 'sfi.order_id', + 'state' => 'sfi.state', + 'store_currency_code' => 'sfi.store_currency_code', + 'order_currency_code' => 'sfi.order_currency_code', + 'base_currency_code' => 'sfi.base_currency_code', + 'global_currency_code' => 'sfi.global_currency_code', + 'increment_id' => 'sfi.increment_id', + 'order_increment_id' => 'sfo.increment_id', + 'created_at' => 'sfi.created_at', + 'order_created_at' => 'sfo.created_at', + 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))" + ] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php index 2b363a7bd838d32640488828735799328388ad38..0ec5acbe69acb368a49effa28700110019370308 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Invoice; * * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Item extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Order/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Item.php index 300e61f8987c20f77966b2885351fe83870f78cb..34a8ffca5286c25901574071ea83298247b9d5a3 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Item.php @@ -23,12 +23,12 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Sales\Model\Resource\Entity as SalesResource; + /** * Flat sales order item resource - * - * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends AbstractOrder +class Item extends SalesResource { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Order/Payment.php b/app/code/Magento/Sales/Model/Resource/Order/Payment.php index b95ce67d42b744fe033165fcfb9ac2c9e6cdea7a..35a0bc2e401fd08a10703d9d182a3f9a356fa2db 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment.php @@ -23,17 +23,23 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Framework\App\Resource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Resource\Attribute; +use Magento\Sales\Model\Increment; +use Magento\Sales\Model\Resource\Entity as SalesResource; + /** * Flat sales order payment resource */ -class Payment extends AbstractOrder +class Payment extends SalesResource { /** * Serializeable field: additional_information * * @var array */ - protected $_serializableFields = array('additional_information' => array(null, array())); + protected $_serializableFields = ['additional_information' => [null, []]]; /** * Event prefix @@ -42,21 +48,6 @@ class Payment extends AbstractOrder */ protected $_eventPrefix = 'sales_order_payment_resource'; - /** - * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory - */ - public function __construct( - \Magento\Framework\App\Resource $resource, - \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory - ) { - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); - } - /** * Model initialization * diff --git a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php index 5a5210e273c77388c0c9acf3c6b3f638ef8297c9..b5555a97b7ebe85724c3ddb8cd00de1487479509 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Payment; * * @author Magento Core Team <core@magentocommerce.com> */ -class Transaction extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Transaction extends \Magento\Sales\Model\Resource\Entity { /** * Serializeable field: additional_information diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php index f7b982047a984f9186b89978ef20f111424b1f21..f260907b671468f244d9dfe73b2fce7abf9da862 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php @@ -23,12 +23,19 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Framework\App\Resource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Resource\Attribute; +use Magento\Sales\Model\Increment as SalesIncrement; +use Magento\Sales\Model\Resource\Entity as SalesResource; +use Magento\Sales\Model\Resource\Order\Shipment\Grid as ShipmentGrid; + /** * Flat sales order shipment resource * * @author Magento Core Team <core@magentocommerce.com> */ -class Shipment extends AbstractOrder +class Shipment extends SalesResource { /** * Event prefix @@ -37,33 +44,12 @@ class Shipment extends AbstractOrder */ protected $_eventPrefix = 'sales_order_shipment_resource'; - /** - * Is grid available - * - * @var bool - */ - protected $_grid = true; - - /** - * Use increment id - * - * @var bool - */ - protected $_useIncrementId = true; - - /** - * Entity type for increment id - * - * @var string - */ - protected $_entityTypeForIncrementId = 'shipment'; - /** * Fields that should be serialized before persistence * * @var array */ - protected $_serializableFields = array('packages' => array(array(), array())); + protected $_serializableFields = ['packages' => [[], []]]; /** * Model initialization @@ -74,37 +60,4 @@ class Shipment extends AbstractOrder { $this->_init('sales_flat_shipment', 'entity_id'); } - - /** - * Init virtual grid records for entity - * - * @return $this - */ - protected function _initVirtualGridColumns() - { - parent::_initVirtualGridColumns(); - $adapter = $this->getReadConnection(); - $checkedFirstname = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote('')); - $checkedLastname = $adapter->getIfNullSql('{{table}}.lastname', $adapter->quote('')); - $concatName = $adapter->getConcatSql(array($checkedFirstname, $adapter->quote(' '), $checkedLastname)); - - $this->addVirtualGridColumn( - 'shipping_name', - 'sales_flat_order_address', - array('shipping_address_id' => 'entity_id'), - $concatName - )->addVirtualGridColumn( - 'order_increment_id', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'increment_id' - )->addVirtualGridColumn( - 'order_created_at', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'created_at' - ); - - return $this; - } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php index 709d47bd2ec1eb6f5184c1a64a2f825e18dce791..fa21a5c0e3ebd32f5441961925616820c8a22361 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Shipment; * * @author Magento Core Team <core@magentocommerce.com> */ -class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Comment extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -45,23 +45,23 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $validator; /** - * Constructor - * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..45d951c67572049432dd4ce1ccc7864ae9b79824 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php @@ -0,0 +1,97 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Shipment; + +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName = 'sales_flat_shipment_grid'; + + /** + * @var string + */ + protected $shipmentTableName = 'sales_flat_shipment'; + + /** + * Refresh grid row + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: 'sfs.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + [], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + return $this->getConnection()->select() + ->from(['sfs' => $this->getTable($this->shipmentTableName)], []) + ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfs.order_id = sfo.entity_id', []) + ->joinLeft( + ['ssa' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = ssa.entity_id', + [] + ) + ->columns( + [ + 'entity_id' => 'sfs.entity_id', + 'store_id' => 'sfs.store_id', + 'total_qty' => 'sfs.total_qty', + 'order_id' => 'sfs.order_id', + 'shipment_status' => 'sfs.shipment_status', + 'increment_id' => 'sfs.increment_id', + 'order_increment_id' => 'sfo.increment_id', + 'created_at' => 'sfs.created_at', + 'order_created_at' => 'sfo.created_at', + 'shipping_name' => "trim(concat(ifnull(ssa.firstname, ''), ' ' ,ifnull(ssa.lastname, '')))", + ] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php index 778aa774d10a8a91883bbbcfd1ea9029c113f70b..c0a09763e7ee5db8c6d0530ac131d284e0471916 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Shipment; * * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Item extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php index 73718f9e165d59cda65353cdd3b41e7a0a1f238a..fecd4bf17309cc0b4bfeb91d81243482d814c6e4 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Shipment; * * @author Magento Core Team <core@magentocommerce.com> */ -class Track extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Track extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -45,23 +45,23 @@ class Track extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $validator; /** - * Constructor - * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Shipment\Track\Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Order\Shipment\Track\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Shipment\Track\Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php index ca4f1d4c1e98e2cf25ea3ba1562309de3e0479ae..2143955fb86f4aebfeb3b8ada2c158c364fbc26b 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php @@ -30,7 +30,7 @@ use Magento\Sales\Model\Order\Status\History\Validator; * * @author Magento Core Team <core@magentocommerce.com> */ -class History extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class History extends \Magento\Sales\Model\Resource\Entity { /** * @var Validator @@ -40,19 +40,21 @@ class History extends \Magento\Sales\Model\Resource\Order\AbstractOrder /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Sale/Collection.php b/app/code/Magento/Sales/Model/Resource/Sale/Collection.php index 936804861c8a2f5914de1d60c6463f41725e1ce4..f7bc0d345bb600668ec891ada04f680c33ebc7bc 100644 --- a/app/code/Magento/Sales/Model/Resource/Sale/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Sale/Collection.php @@ -24,7 +24,7 @@ namespace Magento\Sales\Model\Resource\Sale; use Magento\Core\Model\EntityFactory; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Logger; @@ -92,7 +92,7 @@ class Collection extends \Magento\Framework\Data\Collection\Db * @param ManagerInterface $eventManager * @param Order $resource * @param \Magento\Store\Model\Resource\Store\CollectionFactory $storeCollectionFactory - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( EntityFactory $entityFactory, diff --git a/app/code/Magento/Sales/Service/V1/Data/Transaction.php b/app/code/Magento/Sales/Service/V1/Data/Transaction.php index 60ded30a706cc1cfcd1db62a3e496c1742483ba6..8a5fd6564c89421e23a7b201e9e500c6975b29ac 100644 --- a/app/code/Magento/Sales/Service/V1/Data/Transaction.php +++ b/app/code/Magento/Sales/Service/V1/Data/Transaction.php @@ -63,7 +63,7 @@ class Transaction extends DataObject /** * Returns parent_id * - * @return int + * @return int|null */ public function getParentId() { diff --git a/app/code/Magento/Sales/Service/V1/Data/TransactionBuilder.php b/app/code/Magento/Sales/Service/V1/Data/TransactionBuilder.php index 36df5668593aa39b2353ec3495d20a983e3ed4fc..0e5d852db59212b39a2715a6b2fbed81d57d96b8 100644 --- a/app/code/Magento/Sales/Service/V1/Data/TransactionBuilder.php +++ b/app/code/Magento/Sales/Service/V1/Data/TransactionBuilder.php @@ -34,7 +34,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setTransactionId($transactionId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TRANSACTION_ID, $transactionId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TRANSACTION_ID, (int)$transactionId); } /** @@ -50,7 +50,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setOrderId($orderId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::ORDER_ID, $orderId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::ORDER_ID, (int)$orderId); } /** @@ -58,7 +58,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setPaymentId($paymentId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::PAYMENT_ID, $paymentId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::PAYMENT_ID, (int)$paymentId); } /** @@ -66,7 +66,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setTxnId($txnId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TXN_ID, $txnId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TXN_ID, (string)$txnId); } /** @@ -74,7 +74,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setParentTxnId($parentTxnId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::PARENT_TXN_ID, $parentTxnId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::PARENT_TXN_ID, (string)$parentTxnId); } /** @@ -82,7 +82,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setTxnType($txnType) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TXN_TYPE, $txnType); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TXN_TYPE, (string)$txnType); } /** @@ -90,7 +90,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setIsClosed($isClosed) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::IS_CLOSED, $isClosed); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::IS_CLOSED, (int)$isClosed); } /** @@ -106,7 +106,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setCreatedAt($createdAt) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::CREATED_AT, $createdAt); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::CREATED_AT, (string)$createdAt); } /** @@ -114,7 +114,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setMethod($method) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::METHOD, $method); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::METHOD, (string)$method); } /** @@ -122,7 +122,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setIncrementId($incrementId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::INCREMENT_ID, $incrementId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::INCREMENT_ID, (string)$incrementId); } /** diff --git a/app/code/Magento/Sales/Service/V1/Data/TransactionMapper.php b/app/code/Magento/Sales/Service/V1/Data/TransactionMapper.php index c27d9beb0dec369bc62346552dc061d24c49ed97..95722e2d33641a23fef06bba58b015447cd305c6 100644 --- a/app/code/Magento/Sales/Service/V1/Data/TransactionMapper.php +++ b/app/code/Magento/Sales/Service/V1/Data/TransactionMapper.php @@ -119,8 +119,17 @@ class TransactionMapper { /** @var TransactionBuilder $transactionBuilder */ $transactionBuilder = $this->transactionBuilderFactory->create(); - $transactionBuilder->populateWithArray($transactionModel->getData()); + $transactionBuilder->setTransactionId($transactionModel->getTransactionId()); + $transactionBuilder->setParentId($transactionModel->getParentId()); + $transactionBuilder->setOrderId($transactionModel->getOrderId()); + $transactionBuilder->setTxnId($transactionModel->getTxnId()); + $transactionBuilder->setPaymentId($transactionModel->getPaymentId()); + $transactionBuilder->setParentTxnId($transactionModel->getParentTxnId()); + $transactionBuilder->setTxnType($transactionModel->getTxnType()); + $transactionBuilder->setIsClosed($transactionModel->getIsClosed()); $transactionBuilder->setAdditionalInformation($this->getAdditionalInfo($transactionModel)); + $transactionBuilder->setCreatedAt($transactionModel->getCreatedAt()); + $transactionBuilder->setMethod($transactionModel->getMethod()); $transactionBuilder->setIncrementId($this->getIncrementId($transactionModel)); $transactionBuilder->setChildTransactions($lazy ? [] : $this->getChildTransactions($transactionModel)); return $transactionBuilder->create(); diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index cd6ab8aa6b8028c96355e07ccd7f5e9a423cc180..e2eb6a964c7b242a9f6a3d7ebdd12c9e0b55f2a5 100644 --- a/app/code/Magento/Sales/composer.json +++ b/app/code/Magento/Sales/composer.json @@ -3,30 +3,30 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-sales-rule": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/module-reports": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-email": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-sales-rule": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/module-reports": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-email": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/etc/crontab.xml b/app/code/Magento/Sales/etc/crontab.xml index 0f116b9b32fc2810a51ac887453c51afa6fd57d5..6b5eebdec40096bfcf03b8d1f82c80ab0dfc160d 100644 --- a/app/code/Magento/Sales/etc/crontab.xml +++ b/app/code/Magento/Sales/etc/crontab.xml @@ -25,22 +25,22 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Cron/etc/crontab.xsd"> <group id="default"> - <job name="sales_clean_quotes" instance="Magento\Sales\Model\Observer" method="cleanExpiredQuotes"> + <job name="sales_clean_quotes" instance="Magento\Sales\Model\Observer\CleanExpiredQuotes" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_order_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportOrderData"> + <job name="aggregate_sales_report_order_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportOrderData" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_shipment_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportShipmentData"> + <job name="aggregate_sales_report_shipment_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportShipmentData" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_invoiced_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportInvoicedData"> + <job name="aggregate_sales_report_invoiced_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportInvoicedData" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_refunded_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportRefundedData"> + <job name="aggregate_sales_report_refunded_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportRefundedData" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_bestsellers_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportBestsellersData"> + <job name="aggregate_sales_report_bestsellers_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportBestsellersData" method="execute"> <schedule>0 0 * * *</schedule> </job> </group> diff --git a/app/code/Magento/Sales/etc/events.xml b/app/code/Magento/Sales/etc/events.xml index 9910d259433192cc71075626cd8fc80552acd88d..5962f90b1ba330a3c5888377b388fe23d9566d8e 100644 --- a/app/code/Magento/Sales/etc/events.xml +++ b/app/code/Magento/Sales/etc/events.xml @@ -25,6 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> <event name="sales_order_place_after"> - <observer name="sales_vat_request_params_order_comment" instance="Magento\Sales\Model\Observer" method="addVatRequestParamsOrderComment" /> + <observer name="sales_vat_request_params_order_comment" instance="Magento\Sales\Model\Observer\Frontend\Quote\AddVatRequestParamsOrderComment" method="execute" /> </event> </config> diff --git a/app/code/Magento/Sales/etc/frontend/events.xml b/app/code/Magento/Sales/etc/frontend/events.xml index d57edc0533e807b74f3a4c2e44e7aae223dbfa9c..643294e1f54b5a43d640565932be3b49b3269d0a 100644 --- a/app/code/Magento/Sales/etc/frontend/events.xml +++ b/app/code/Magento/Sales/etc/frontend/events.xml @@ -28,9 +28,9 @@ <observer name="sales_customer_validate_vat_number" instance="Magento\Sales\Model\Observer\Frontend\Quote\Address\CollectTotals" method="dispatch" /> </event> <event name="sales_quote_address_collect_totals_after"> - <observer name="sales_customer_validate_vat_number" instance="Magento\Sales\Model\Observer" method="restoreQuoteCustomerGroupId" /> + <observer name="sales_customer_validate_vat_number" instance="Magento\Sales\Model\Observer\Frontend\Quote\RestoreCustomerGroupId" method="execute" /> </event> <event name="sales_quote_collect_totals_after"> - <observer name="catalog_msrp" instance="Magento\Sales\Model\Observer" method="setQuoteCanApplyMsrp" /> + <observer name="catalog_msrp" instance="Magento\Sales\Model\Observer\Frontend\Quote\SetCanApplyMsrp" method="execute" /> </event> </config> diff --git a/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php b/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php index f7455805aff6bc77ad552362043003762a989447..057ac7db65ff996d7f6d8b81eaa2c369323b5487 100644 --- a/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php +++ b/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php @@ -23,7 +23,7 @@ */ namespace Magento\SalesRule\Model\Plugin; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Customer\Model\Session; use Magento\SalesRule\Model\Resource\Rule; diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php index 8eb80f3d277fc776559f13c7597bab16e698d809..46a462a0a0ae51ae732b0bb9d16a63829993aeb5 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Discount.php +++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php @@ -43,18 +43,18 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal protected $_eventManager = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\SalesRule\Model\Validator $validator */ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\SalesRule\Model\Validator $validator ) { $this->_eventManager = $eventManager; @@ -93,8 +93,9 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal $address->setDiscountDescription(array()); $items = $this->_calculator->sortItemsByPriority($items); + /** @var \Magento\Sales\Model\Quote\Item $item */ foreach ($items as $item) { - if ($item->getNoDiscount()) { + if ($item->getNoDiscount() || !$this->_calculator->canApplyDiscount($item)) { $item->setDiscountAmount(0); $item->setBaseDiscountAmount(0); continue; diff --git a/app/code/Magento/SalesRule/Model/Rule.php b/app/code/Magento/SalesRule/Model/Rule.php index 3d0e3869d1ec4e299b738620300037447401a0b5..ce1733a10c72184528f439defe7ff12012699873 100644 --- a/app/code/Magento/SalesRule/Model/Rule.php +++ b/app/code/Magento/SalesRule/Model/Rule.php @@ -193,7 +193,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel protected $_couponCollection; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -207,7 +207,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\SalesRule\Model\Rule\Condition\CombineFactory $condCombineFactory * @param \Magento\SalesRule\Model\Rule\Condition\Product\CombineFactory $condProdCombineF * @param \Magento\SalesRule\Model\Resource\Coupon\Collection $couponCollection - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -222,7 +222,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel \Magento\SalesRule\Model\Rule\Condition\CombineFactory $condCombineFactory, \Magento\SalesRule\Model\Rule\Condition\Product\CombineFactory $condProdCombineF, \Magento\SalesRule\Model\Resource\Coupon\Collection $couponCollection, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/SalesRule/Model/Validator.php b/app/code/Magento/SalesRule/Model/Validator.php index dbd098b213be5f0d4e10010d489cb1fa48b48fe4..58192b28fdc1bcd78dff0f26a2df73ff628546b2 100644 --- a/app/code/Magento/SalesRule/Model/Validator.php +++ b/app/code/Magento/SalesRule/Model/Validator.php @@ -32,11 +32,11 @@ use Magento\Sales\Model\Quote\Address; * Allows dispatching before and after events for each controller action * * @method mixed getCouponCode() - * @method \Magento\SalesRule\Model\Validator setCouponCode($code) + * @method Validator setCouponCode($code) * @method mixed getWebsiteId() - * @method \Magento\SalesRule\Model\Validator setWebsiteId($id) + * @method Validator setWebsiteId($id) * @method mixed getCustomerGroupId() - * @method \Magento\SalesRule\Model\Validator setCustomerGroupId($id) + * @method Validator setCustomerGroupId($id) */ class Validator extends \Magento\Framework\Model\AbstractModel { @@ -91,6 +91,16 @@ class Validator extends \Magento\Framework\Model\AbstractModel */ protected $rulesApplier; + /** + * @var Validator\Pool + */ + protected $validators; + + /** + * @var \Magento\Framework\Message\ManagerInterface + */ + protected $messageManager; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -98,6 +108,8 @@ class Validator extends \Magento\Framework\Model\AbstractModel * @param \Magento\Catalog\Helper\Data $catalogData * @param Utility $utility * @param RulesApplier $rulesApplier + * @param Validator\Pool $validators + * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -109,6 +121,8 @@ class Validator extends \Magento\Framework\Model\AbstractModel \Magento\Catalog\Helper\Data $catalogData, \Magento\SalesRule\Model\Utility $utility, \Magento\SalesRule\Model\RulesApplier $rulesApplier, + \Magento\SalesRule\Model\Validator\Pool $validators, + \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -117,6 +131,8 @@ class Validator extends \Magento\Framework\Model\AbstractModel $this->_catalogData = $catalogData; $this->validatorUtility = $utility; $this->rulesApplier = $rulesApplier; + $this->validators = $validators; + $this->messageManager = $messageManager; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -338,6 +354,7 @@ class Validator extends \Magento\Framework\Model\AbstractModel return $this; } + /** @var \Magento\SalesRule\Model\Rule $rule */ foreach ($this->_getRules() as $rule) { if (\Magento\SalesRule\Model\Rule::CART_FIXED_ACTION == $rule->getSimpleAction() && $this->validatorUtility->canProcessRule($rule, $address) @@ -354,6 +371,9 @@ class Validator extends \Magento\Framework\Model\AbstractModel if (!$rule->getActions()->validate($item)) { continue; } + if (!$this->canApplyDiscount($item)) { + continue; + } $qty = $this->validatorUtility->getItemQty($item, $rule); $ruleTotalItemsPrice += $this->getItemPrice($item) * $qty; $ruleTotalBaseItemsPrice += $this->getItemBasePrice($item) * $qty; @@ -493,4 +513,23 @@ class Validator extends \Magento\Framework\Model\AbstractModel return $this; } + + /** + * Check if we can apply discount to current QuoteItem + * + * @param AbstractItem $item + * @return bool + */ + public function canApplyDiscount(AbstractItem $item) + { + $result = true; + /** @var \Zend_Validate_Interface $validator */ + foreach ($this->validators->getValidators('discount') as $validator) { + $result = $validator->isValid($item); + if (!$result) { + break; + } + } + return $result; + } } diff --git a/app/code/Magento/Install/Controller/Index/Index.php b/app/code/Magento/SalesRule/Model/Validator/Pool.php similarity index 62% rename from app/code/Magento/Install/Controller/Index/Index.php rename to app/code/Magento/SalesRule/Model/Validator/Pool.php index abcb641404528259863c27a38f7deb6fc8656134..57fb29de7cb975c5c50b2689f4ab064893bc006a 100644 --- a/app/code/Magento/Install/Controller/Index/Index.php +++ b/app/code/Magento/SalesRule/Model/Validator/Pool.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,29 +21,35 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Index; -class Index extends \Magento\Framework\App\Action\Action +namespace Magento\SalesRule\Model\Validator; + +/** + * Class Pool collects custom validators for items before SalesRules are applied + */ +class Pool { /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\Config\Scope $configScope + * @var array */ - public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\Config\Scope $configScope - ) { - parent::__construct($context); - $configScope->setCurrentScope('install'); + protected $validators = []; + + /** + * @param array $validators + */ + public function __construct(array $validators = []) + { + $this->validators = $validators; } /** - * Index action + * Get Validators defined in di * - * @return void + * @param string $type + * @return array */ - public function execute() + public function getValidators($type) { - $this->_redirect('install/wizard/begin'); + return isset($this->validators[$type]) ? $this->validators[$type] : []; } } diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index d83d7f5bfbdda1919592fac3ddc62febc1174d60..1617a87e5c922036e8e76f464a0a2878166c7318 100644 --- a/app/code/Magento/SalesRule/composer.json +++ b/app/code/Magento/SalesRule/composer.json @@ -3,26 +3,26 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-rule": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-reports": "0.1.0-alpha94", - "magento/module-catalog-rule": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-rule": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-reports": "0.1.0-alpha95", + "magento/module-catalog-rule": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.php b/app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.php new file mode 100644 index 0000000000000000000000000000000000000000..216db8bba4f427e1a2ca2a4c1eca2ec643e69c15 --- /dev/null +++ b/app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.php @@ -0,0 +1,56 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sendfriend\Block\Plugin\Catalog\Product; + +class View +{ + /** + * @var \Magento\Sendfriend\Model\Sendfriend + */ + protected $_sendfriend; + + /** + * @param \Magento\Sendfriend\Model\Sendfriend $sendfriend + */ + public function __construct( + \Magento\Sendfriend\Model\Sendfriend $sendfriend + ) { + $this->_sendfriend = $sendfriend; + } + + /** + * @param \Magento\Catalog\Block\Product\View $subject + * @param bool $result + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterCanEmailToFriend(\Magento\Catalog\Block\Product\View $subject, $result) + { + if (!$result) { + $result = $this->_sendfriend->canEmailToFriend(); + } + return $result; + } +} diff --git a/app/code/Magento/Sendfriend/Model/Sendfriend.php b/app/code/Magento/Sendfriend/Model/Sendfriend.php index 42eb89a6d69c44cdb9905183662ff7d2cf287e91..66476755feb7f3ba7e7cff8183ea759070c6b117 100644 --- a/app/code/Magento/Sendfriend/Model/Sendfriend.php +++ b/app/code/Magento/Sendfriend/Model/Sendfriend.php @@ -101,7 +101,7 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel protected $_transportBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -128,7 +128,7 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Catalog\Helper\Image $catalogImage * @param \Magento\Sendfriend\Helper\Data $sendfriendData @@ -143,7 +143,7 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Catalog\Helper\Image $catalogImage, \Magento\Sendfriend\Helper\Data $sendfriendData, @@ -506,7 +506,7 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel if ($increment) { $newTimes[] = $time; $newValue = implode(',', $newTimes); - $this->cookieManager->setPublicCookie($cookieName, $newValue); + $this->cookieManager->setSensitiveCookie($cookieName, $newValue); $this->_lastCookieValue[$cookieName] = $newValue; } diff --git a/app/code/Magento/Backend/Model/Config/Source/Checktype.php b/app/code/Magento/Sendfriend/Model/Source/Checktype.php similarity index 96% rename from app/code/Magento/Backend/Model/Config/Source/Checktype.php rename to app/code/Magento/Sendfriend/Model/Source/Checktype.php index 6a516932f467fcf9c6b883a1035a28ea77c52c20..3aa159a0ca64a5f99e2723ebd60dc33be573d7d7 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Checktype.php +++ b/app/code/Magento/Sendfriend/Model/Source/Checktype.php @@ -28,7 +28,7 @@ * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Backend\Model\Config\Source; +namespace Magento\Sendfriend\Model\Source; class Checktype implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index 8f33effe471a6398869d11cbb07fb44d90407359..8d37dfba3c1b2340a2e150778bbb34d39dc187a1 100644 --- a/app/code/Magento/Sendfriend/composer.json +++ b/app/code/Magento/Sendfriend/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sendfriend/etc/adminhtml/system.xml b/app/code/Magento/Sendfriend/etc/adminhtml/system.xml index 3ab63941560c15cc8107d80ba08634c0b5a13776..539edc6b2f97eb914fe8224a63ab54389e3ba86b 100644 --- a/app/code/Magento/Sendfriend/etc/adminhtml/system.xml +++ b/app/code/Magento/Sendfriend/etc/adminhtml/system.xml @@ -53,7 +53,7 @@ </field> <field id="check_by" translate="label" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Limit Sending By</label> - <source_model>Magento\Backend\Model\Config\Source\Checktype</source_model> + <source_model>Magento\Sendfriend\Model\Source\Checktype</source_model> </field> </group> </section> diff --git a/app/code/Magento/Newsletter/etc/adminhtml/di.xml b/app/code/Magento/Sendfriend/etc/frontend/di.xml similarity index 86% rename from app/code/Magento/Newsletter/etc/adminhtml/di.xml rename to app/code/Magento/Sendfriend/etc/frontend/di.xml index 55fed61209db6a38b9c7dc88578703b91c7b4a06..53efa95b7d16dac63f8d79baf1e7f62cf6f1bd89 100644 --- a/app/code/Magento/Newsletter/etc/adminhtml/di.xml +++ b/app/code/Magento/Sendfriend/etc/frontend/di.xml @@ -24,9 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Newsletter\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> + <type name="Magento\Catalog\Block\Product\View"> + <plugin name="catalogProductViewCanEmailToFriend" type="Magento\Sendfriend\Block\Plugin\Catalog\Product\View" /> </type> </config> diff --git a/app/code/Magento/Shipping/Helper/Data.php b/app/code/Magento/Shipping/Helper/Data.php index b9124397a4eaa159550c6fd9e2e0cc9fe55e6049..ad842a465a201ea41968098ed19403a546fb123a 100644 --- a/app/code/Magento/Shipping/Helper/Data.php +++ b/app/code/Magento/Shipping/Helper/Data.php @@ -51,7 +51,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -59,13 +59,13 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_coreData = $coreData; $this->_scopeConfig = $scopeConfig; diff --git a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php index 3f3d5902a336da4abb88ce1ef1fb77ea20f605ad..19ff4bf44a4304734ebdce11220cbb658ecd152e 100644 --- a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php +++ b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php @@ -35,7 +35,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf protected $_carrierHelper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,7 +60,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Shipping\Helper\Carrier $carrierHelper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data @@ -78,7 +78,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, Carrier $carrierHelper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array() diff --git a/app/code/Magento/Shipping/Model/Order/Track.php b/app/code/Magento/Shipping/Model/Order/Track.php index a9021255388068d7e902cfca85b5868d79a6b452..f754599ba1dbc0544bedb34a795a3ee7364386d6 100644 --- a/app/code/Magento/Shipping/Model/Order/Track.php +++ b/app/code/Magento/Shipping/Model/Order/Track.php @@ -59,7 +59,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -73,7 +73,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, \Magento\Shipping\Model\CarrierFactory $carrierFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Shipping/Model/Rate/Result.php b/app/code/Magento/Shipping/Model/Rate/Result.php index 032eb1d6253d6e20e7bc22d0fac8443653d9afbc..e90993ec3ecc957d833e24bb0de012f0be6fbc98 100644 --- a/app/code/Magento/Shipping/Model/Rate/Result.php +++ b/app/code/Magento/Shipping/Model/Rate/Result.php @@ -40,14 +40,14 @@ class Result protected $_error = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Shipping/Model/Shipping.php b/app/code/Magento/Shipping/Model/Shipping.php index 1ce2afa6532749c189a559a187ee1868c0dc9b28..01912ab482cee39baa5a998c8388eddc0cd1b251 100644 --- a/app/code/Magento/Shipping/Model/Shipping.php +++ b/app/code/Magento/Shipping/Model/Shipping.php @@ -57,7 +57,7 @@ class Shipping implements RateCollectorInterface protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -99,7 +99,7 @@ class Shipping implements RateCollectorInterface /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Shipping\Model\Config $shippingConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory * @param \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory @@ -110,7 +110,7 @@ class Shipping implements RateCollectorInterface public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\Config $shippingConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Shipping\Model\CarrierFactory $carrierFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory, diff --git a/app/code/Magento/Shipping/Model/Shipping/Labels.php b/app/code/Magento/Shipping/Model/Shipping/Labels.php index d9f8d6780f9d9b4c3026ad5ca2402dceb9e30340..d816363b40e8a9f582cd5c4108ca543bad02dc6a 100644 --- a/app/code/Magento/Shipping/Model/Shipping/Labels.php +++ b/app/code/Magento/Shipping/Model/Shipping/Labels.php @@ -43,7 +43,7 @@ class Labels extends \Magento\Shipping\Model\Shipping /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Shipping\Model\Config $shippingConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory * @param \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory @@ -56,7 +56,7 @@ class Labels extends \Magento\Shipping\Model\Shipping public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\Config $shippingConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Shipping\Model\CarrierFactory $carrierFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory, diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 2336c2664a51e41b82dd972ef2c6feb22ccfa649..24b19f4e421fb73efdfc3c72a1a6c280cc5a16e9 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-contact": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-contact": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index 73b2ec3593f54066e137808f7d2f8eca22d6c881..91f95cd27c7d8244b4713f6325b0307863e03025 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -73,7 +73,7 @@ class Observer protected $_transportBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -85,14 +85,14 @@ class Observer /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Resource\Sitemap\CollectionFactory $collectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sitemap\Model\Resource\Sitemap\CollectionFactory $collectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation ) { diff --git a/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php b/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php index 64c5bc7969982396a6408e00bdcf6ab5cde2f90c..b081b5ec32a822d61e423592d39fac8823250f0a 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php +++ b/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php @@ -45,7 +45,7 @@ class Category extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_attributesCache = array(); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,12 +56,12 @@ class Category extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Category $categoryResource */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Category $categoryResource ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php b/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php index beafdb1bde801050f546fd7cb61cd83e147fc27e..4efb8c625e17e7d551b9e96c5f50d0a8d0c162cd 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php +++ b/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php @@ -68,7 +68,7 @@ class Product extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_productResource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -101,7 +101,7 @@ class Product extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param \Magento\Framework\App\Resource $resource * @param \Magento\Sitemap\Helper\Data $sitemapData * @param \Magento\Catalog\Model\Resource\Product $productResource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaAttribute @@ -112,7 +112,7 @@ class Product extends \Magento\Framework\Model\Resource\Db\AbstractDb \Magento\Framework\App\Resource $resource, \Magento\Sitemap\Helper\Data $sitemapData, \Magento\Catalog\Model\Resource\Product $productResource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus, \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaAttribute, diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php index 4d0a65f7445e086c49a8a706f27fca5094daef0b..49850bc6a97301b8a90e33f6a4c44763bfd2a312 100644 --- a/app/code/Magento/Sitemap/Model/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Sitemap.php @@ -143,7 +143,7 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel protected $_dateModel; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -167,7 +167,7 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel * @param \Magento\Sitemap\Model\Resource\Catalog\ProductFactory $productFactory * @param \Magento\Sitemap\Model\Resource\Cms\PageFactory $cmsFactory * @param \Magento\Framework\Stdlib\DateTime\DateTime $modelDate - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -184,7 +184,7 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel \Magento\Sitemap\Model\Resource\Catalog\ProductFactory $productFactory, \Magento\Sitemap\Model\Resource\Cms\PageFactory $cmsFactory, \Magento\Framework\Stdlib\DateTime\DateTime $modelDate, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 8234013185d32f0e8889d894fed802f508ac1419..4e6ebf4ade31b9f3d873166334ac7e447ff67f46 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/App/Action/Plugin/Context.php b/app/code/Magento/Store/App/Action/Plugin/Context.php index 89e343a1209894bb9c738a00d37a8ae08ca58357..3cc42e4b15b6150d2a0462b2580cd5b2b9c818e9 100644 --- a/app/code/Magento/Store/App/Action/Plugin/Context.php +++ b/app/code/Magento/Store/App/Action/Plugin/Context.php @@ -45,34 +45,26 @@ class Context protected $httpRequest; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; - /** - * @var \Magento\Framework\Stdlib\CookieManager - */ - protected $cookieManager; - /** * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\App\Request\Http $httpRequest - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\App\Request\Http $httpRequest, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Stdlib\CookieManager $cookieManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->session = $session; $this->httpContext = $httpContext; $this->httpRequest = $httpRequest; $this->storeManager = $storeManager; - $this->cookieManager = $cookieManager; } /** @@ -86,17 +78,18 @@ class Context \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { + $defaultStore = $this->storeManager->getWebsite()->getDefaultStore(); $this->httpContext->setValue( \Magento\Core\Helper\Data::CONTEXT_CURRENCY, $this->session->getCurrencyCode(), - $this->storeManager->getWebsite()->getDefaultStore()->getDefaultCurrency()->getCode() + $defaultStore->getDefaultCurrency()->getCode() ); $this->httpContext->setValue( \Magento\Core\Helper\Data::CONTEXT_STORE, $this->httpRequest->getParam( '___store', - $this->cookieManager->getCookie(\Magento\Store\Model\Store::COOKIE_NAME) + $defaultStore->getStoreCodeFromCookie() ), $this->storeManager->getWebsite()->getDefaultStore()->getCode() ); diff --git a/app/code/Magento/Store/App/Action/Plugin/StoreCheck.php b/app/code/Magento/Store/App/Action/Plugin/StoreCheck.php index 79690ba3dd47093bcaa0bc654ab7bf705a39d674..ea2ce943fc86766d937f1cf0e1f93d11e8df4e7d 100644 --- a/app/code/Magento/Store/App/Action/Plugin/StoreCheck.php +++ b/app/code/Magento/Store/App/Action/Plugin/StoreCheck.php @@ -27,25 +27,17 @@ namespace Magento\Store\App\Action\Plugin; class StoreCheck { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\State $appState + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\App\State $appState + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; - $this->_appState = $appState; } /** @@ -55,19 +47,17 @@ class StoreCheck * * @return \Magento\Framework\App\ResponseInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ public function aroundDispatch( \Magento\Framework\App\Action\Action $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { - if ($this->_appState->isInstalled()) { - if (!$this->_storeManager->getStore()->getIsActive()) { - throw new \Magento\Store\Model\Exception( - 'Current store is not active.' - ); - } + if (!$this->_storeManager->getStore()->getIsActive()) { + throw new \Magento\Framework\App\InitException( + 'Current store is not active.' + ); } return $proceed($request); } diff --git a/app/code/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandler.php b/app/code/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandler.php deleted file mode 100644 index 43a54d6090b04482bb1fc0c5380e38ff903283b2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandler.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php -/** - * Dispatch exception handler - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Store\App\FrontController\Plugin; - -use Magento\Store\Model\StoreManager; -use Magento\Framework\App\Filesystem; - -class DispatchExceptionHandler -{ - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $_storeManager; - - /** - * Filesystem instance - * - * @var \Magento\Framework\App\Filesystem - */ - protected $filesystem; - - /** - * @param StoreManager $storeManager - * @param Filesystem $filesystem - */ - public function __construct(StoreManager $storeManager, Filesystem $filesystem) - { - $this->_storeManager = $storeManager; - $this->filesystem = $filesystem; - } - - /** - * Handle dispatch exceptions - * - * @param \Magento\Framework\App\FrontController $subject - * @param callable $proceed - * @param \Magento\Framework\App\RequestInterface $request - * - * @return mixed - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function aroundDispatch( - \Magento\Framework\App\FrontController $subject, - \Closure $proceed, - \Magento\Framework\App\RequestInterface $request - ) { - try { - return $proceed($request); - } catch (\Magento\Framework\Session\Exception $e) { - header('Location: ' . $this->_storeManager->getStore()->getBaseUrl()); - exit; - } catch (\Magento\Store\Model\Exception $e) { - require $this->filesystem->getPath(Filesystem::PUB_DIR) . '/errors/404.php'; - exit; - } - } -} diff --git a/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php b/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php index 686ff0bb53c0eb72fa87cac391b887ea2d973402..3a90f4f5053c0c6680b55b23dd79fa5c5b8368dc 100644 --- a/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php +++ b/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php @@ -41,31 +41,23 @@ class RequestPreprocessor protected $_url; /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\State $appState + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $url * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\ResponseFactory $responseFactory */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\App\State $appState, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $url, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\ResponseFactory $responseFactory ) { $this->_storeManager = $storeManager; - $this->_appState = $appState; $this->_url = $url; $this->_scopeConfig = $scopeConfig; $this->_responseFactory = $responseFactory; @@ -87,7 +79,7 @@ class RequestPreprocessor \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { - if ($this->_appState->isInstalled() && !$request->isPost() && $this->_isBaseUrlCheckEnabled()) { + if (!$request->isPost() && $this->_isBaseUrlCheckEnabled()) { $baseUrl = $this->_storeManager->getStore()->getBaseUrl( \Magento\Framework\UrlInterface::URL_TYPE_WEB, $this->_storeManager->getStore()->isCurrentlySecure() diff --git a/app/code/Magento/Store/App/Request/PathInfoProcessor.php b/app/code/Magento/Store/App/Request/PathInfoProcessor.php index fbcbcfa49b4c18c634b9b40247560698dc7e9023..0dfe74cca29f1f5c246ac5d2f956d78522dfbc65 100644 --- a/app/code/Magento/Store/App/Request/PathInfoProcessor.php +++ b/app/code/Magento/Store/App/Request/PathInfoProcessor.php @@ -26,14 +26,14 @@ namespace Magento\Store\App\Request; class PathInfoProcessor implements \Magento\Framework\App\Request\PathInfoProcessorInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Store/App/Response/Redirect.php b/app/code/Magento/Store/App/Response/Redirect.php index 615e1862bfbae8d42d2114d61ac206323ccca933..8f6f8555cc834aa86a85b8ed37129ad1c8ae7667 100644 --- a/app/code/Magento/Store/App/Response/Redirect.php +++ b/app/code/Magento/Store/App/Response/Redirect.php @@ -33,7 +33,7 @@ class Redirect implements \Magento\Framework\App\Response\RedirectInterface protected $_request; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -64,7 +64,7 @@ class Redirect implements \Magento\Framework\App\Response\RedirectInterface /** * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Encryption\UrlCoder $urlCoder * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Framework\Session\SidResolverInterface $sidResolver @@ -73,7 +73,7 @@ class Redirect implements \Magento\Framework\App\Response\RedirectInterface */ public function __construct( \Magento\Framework\App\RequestInterface $request, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Encryption\UrlCoder $urlCoder, \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Framework\Session\SidResolverInterface $sidResolver, diff --git a/app/code/Magento/Store/Helper/Cookie.php b/app/code/Magento/Store/Helper/Cookie.php index a0f6336af409def7e0504d2dd7c40ddd3d84bb09..66ca1750b35dba41df1e9eda415931f779ad8d42 100644 --- a/app/code/Magento/Store/Helper/Cookie.php +++ b/app/code/Magento/Store/Helper/Cookie.php @@ -60,7 +60,7 @@ class Cookie extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param array $data * @@ -68,7 +68,7 @@ class Cookie extends \Magento\Framework\App\Helper\AbstractHelper */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, array $data = array() ) { diff --git a/app/code/Magento/Store/Model/Config/Reader/Store.php b/app/code/Magento/Store/Model/Config/Reader/Store.php index f1a8289c879a8de412dee1d8d450b98092caa767..a00f4092cbb530bb5eb689eb1da798dbc8094339 100644 --- a/app/code/Magento/Store/Model/Config/Reader/Store.php +++ b/app/code/Magento/Store/Model/Config/Reader/Store.php @@ -58,7 +58,7 @@ class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface protected $_appState; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -69,7 +69,7 @@ class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface * @param \Magento\Store\Model\Resource\Config\Collection\ScopedFactory $collectionFactory * @param \Magento\Store\Model\StoreFactory $storeFactory * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Config\Initial $initialConfig, @@ -78,7 +78,7 @@ class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface \Magento\Store\Model\Resource\Config\Collection\ScopedFactory $collectionFactory, \Magento\Store\Model\StoreFactory $storeFactory, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_initialConfig = $initialConfig; $this->_scopePool = $scopePool; diff --git a/app/code/Magento/Store/Model/Group.php b/app/code/Magento/Store/Model/Group.php index bcb3b8ff476591cad51a109875c377acfbcff531..9972fec515f6e5eb3df72cdc605b759d57e4eebc 100644 --- a/app/code/Magento/Store/Model/Group.php +++ b/app/code/Magento/Store/Model/Group.php @@ -109,7 +109,7 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F protected $_store; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -118,7 +118,7 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\Resource\Config\Data $configDataResource * @param \Magento\Store\Model\Store $store - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -128,7 +128,7 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F \Magento\Framework\Registry $registry, \Magento\Core\Model\Resource\Config\Data $configDataResource, \Magento\Store\Model\Store $store, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Store/Model/Resolver/Store.php b/app/code/Magento/Store/Model/Resolver/Store.php index 971ee31ea707763f6a9a988a9f34086f2dd08999..83532eafcc0c0babca8ed2ef08cdfc5ca5d73977 100644 --- a/app/code/Magento/Store/Model/Resolver/Store.php +++ b/app/code/Magento/Store/Model/Resolver/Store.php @@ -26,26 +26,27 @@ namespace Magento\Store\Model\Resolver; class Store implements \Magento\Framework\App\ScopeResolverInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } /** * {@inheritdoc} + * @throws \Magento\Framework\App\InitException */ public function getScope($scopeId = null) { $scope = $this->_storeManager->getStore($scopeId); if (!$scope instanceof \Magento\Framework\App\ScopeInterface) { - throw new \Magento\Store\Model\Exception('Invalid scope object'); + throw new \Magento\Framework\App\InitException('Invalid scope object'); } return $scope; diff --git a/app/code/Magento/Store/Model/Resolver/Website.php b/app/code/Magento/Store/Model/Resolver/Website.php index 5ffd7d9122f00f0c505885b69dc69f4dd390fa4c..b1c9332c7e16abbf35b4b1552a27031dd2861012 100644 --- a/app/code/Magento/Store/Model/Resolver/Website.php +++ b/app/code/Magento/Store/Model/Resolver/Website.php @@ -17,7 +17,7 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -26,27 +26,28 @@ namespace Magento\Store\Model\Resolver; class Website implements \Magento\Framework\App\ScopeResolverInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; } /** * {@inheritdoc} + * @throws \Magento\Framework\App\InitException */ public function getScope($scopeId = null) { $scope = $this->_storeManager->getWebsite($scopeId); if (!($scope instanceof \Magento\Framework\App\ScopeInterface)) { - throw new \Magento\Store\Model\Exception('Invalid scope object'); + throw new \Magento\Framework\App\InitException('Invalid scope object'); } return $scope; diff --git a/app/code/Magento/Store/Model/Storage/Db.php b/app/code/Magento/Store/Model/Storage/Db.php index 1b4088b6fa31392fcc7d8b137cfa1657b00afca5..111554471a323c277fffa67b998521d0a4c0a2d1 100644 --- a/app/code/Magento/Store/Model/Storage/Db.php +++ b/app/code/Magento/Store/Model/Storage/Db.php @@ -32,7 +32,7 @@ use Magento\Store\Model\StoreFactory; use Magento\Store\Model\Website; use Magento\Store\Model\WebsiteFactory as WebsiteFactory; -class Db implements \Magento\Store\Model\StoreManagerInterface +class Db implements \Magento\Framework\StoreManagerInterface { /** * Flag that shows that system has only one store view @@ -287,7 +287,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface * * @param null|string|bool|int|Store $storeId * @return Store - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ public function getStore($storeId = null) { @@ -315,7 +315,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface } if (!$store->getCode()) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\App\InitException( 'Store Manager has been initialized not properly' ); } @@ -354,7 +354,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface * * @param null|bool|int|string|Website $websiteId * @return Website - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ public function getWebsite($websiteId = null) { @@ -371,7 +371,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface // load method will load website by code if given ID is not a numeric value $website->load($websiteId); if (!$website->hasWebsiteId()) { - throw new \Magento\Store\Model\Exception('Invalid website id/code requested.'); + throw new \Magento\Framework\App\InitException('Invalid website id/code requested.'); } $this->_websites[$website->getWebsiteId()] = $website; $this->_websites[$website->getCode()] = $website; @@ -409,7 +409,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface * * @param null|Group|string $groupId * @return Group - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ public function getGroup($groupId = null) { @@ -423,7 +423,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface if (is_numeric($groupId)) { $group->load($groupId); if (!$group->hasGroupId()) { - throw new \Magento\Store\Model\Exception('Invalid store group id requested.'); + throw new \Magento\Framework\App\InitException('Invalid store group id requested.'); } } $this->_groups[$group->getGroupId()] = $group; diff --git a/app/code/Magento/Store/Model/Storage/DefaultStorage.php b/app/code/Magento/Store/Model/Storage/DefaultStorage.php index 339b28e7be8becb9c6f7eeb2a09dd489bd99bbc3..6bf05327ca6594d12fa04aba82c2d9995a7df5d5 100644 --- a/app/code/Magento/Store/Model/Storage/DefaultStorage.php +++ b/app/code/Magento/Store/Model/Storage/DefaultStorage.php @@ -25,7 +25,7 @@ */ namespace Magento\Store\Model\Storage; -class DefaultStorage implements \Magento\Store\Model\StoreManagerInterface +class DefaultStorage implements \Magento\Framework\StoreManagerInterface { /** * Application store object @@ -97,10 +97,7 @@ class DefaultStorage implements \Magento\Store\Model\StoreManagerInterface } /** - * Retrieve application store object - * - * @param null|string|bool|int|\Magento\Store\Model\Store $storeId - * @return \Magento\Store\Model\Store + * {@inheritdoc} */ public function getStore($storeId = null) { @@ -155,11 +152,7 @@ class DefaultStorage implements \Magento\Store\Model\StoreManagerInterface } /** - * Retrieve application store group object - * - * @param null|\Magento\Store\Model\Group|string $groupId - * @return \Magento\Store\Model\Group - * @throws \Magento\Framework\Model\Exception + * {@inheritdoc} */ public function getGroup($groupId = null) { diff --git a/app/code/Magento/Store/Model/StorageFactory.php b/app/code/Magento/Store/Model/StorageFactory.php index 711d0e8f7d415abde1c726ffa5e6489d4187b92a..35e6b1331d78a47efa6f40dc3ec44e5ddd9829e9 100644 --- a/app/code/Magento/Store/Model/StorageFactory.php +++ b/app/code/Magento/Store/Model/StorageFactory.php @@ -25,7 +25,7 @@ namespace Magento\Store\Model; use Magento\Framework\Profiler; use Magento\Store\Model\Store; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class StorageFactory { @@ -49,7 +49,7 @@ class StorageFactory protected $_installedStorageClassName; /** - * @var \Magento\Store\Model\StoreManagerInterface[] + * @var \Magento\Framework\StoreManagerInterface[] */ protected $_cache = array(); @@ -78,11 +78,6 @@ class StorageFactory */ protected $_writerModel; - /** - * @var \Magento\Framework\Stdlib\CookieManager - */ - protected $_cookieManager; - /** * @var \Magento\Framework\App\Http\Context */ @@ -93,21 +88,15 @@ class StorageFactory */ protected $request; - /** - * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory - */ - protected $cookieMetadataFactory; /** * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Session\SidResolverInterface $sidResolver * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param string $defaultStorageClassName * @param string $installedStorageClassName * @param string $writerModel @@ -121,8 +110,6 @@ class StorageFactory \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - \Magento\Framework\Stdlib\CookieManager $cookieManager, $defaultStorageClassName = 'Magento\Store\Model\Storage\DefaultStorage', $installedStorageClassName = 'Magento\Store\Model\Storage\Db', $writerModel = '' @@ -136,8 +123,6 @@ class StorageFactory $this->_sidResolver = $sidResolver; $this->_writerModel = $writerModel; $this->_httpContext = $httpContext; - $this->cookieMetadataFactory = $cookieMetadataFactory; - $this->_cookieManager = $cookieManager; $this->_scopeConfig = $scopeConfig; $this->request = $request; } @@ -146,7 +131,7 @@ class StorageFactory * Get storage instance * * @param array $arguments - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface * @throws \InvalidArgumentException */ public function get(array $arguments = array()) @@ -155,12 +140,12 @@ class StorageFactory $this->_appState->isInstalled() ? $this->_installedStorageClassName : $this->_defaultStorageClassName; if (false == isset($this->_cache[$className])) { - /** @var $storage \Magento\Store\Model\StoreManagerInterface */ + /** @var $storage \Magento\Framework\StoreManagerInterface */ $storage = $this->_objectManager->create($className, $arguments); - if (false === ($storage instanceof \Magento\Store\Model\StoreManagerInterface)) { + if (false === ($storage instanceof \Magento\Framework\StoreManagerInterface)) { throw new \InvalidArgumentException( - $className . ' doesn\'t implement \Magento\Store\Model\StoreManagerInterface' + $className . ' doesn\'t implement \Magento\Framework\StoreManagerInterface' ); } $this->_cache[$className] = $storage; @@ -212,12 +197,12 @@ class StorageFactory /** * Initialize currently ran store * - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param array $arguments * @return void - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ - protected function _reinitStores(\Magento\Store\Model\StoreManagerInterface $storage, $arguments) + protected function _reinitStores(\Magento\Framework\StoreManagerInterface $storage, $arguments) { Profiler::start('init_stores'); $storage->reinitStores(); @@ -240,8 +225,8 @@ class StorageFactory $storage->setCurrentStore($this->_getStoreByWebsite($storage, $scopeCode)); break; default: - throw new \Magento\Store\Model\Exception( - 'Store Manager has been initialized not properly' + throw new \Magento\Framework\App\InitException( + 'Store Manager has not been initialized properly' ); } @@ -253,11 +238,11 @@ class StorageFactory } /** - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeCode * @return null|string */ - protected function _getStoreByGroup(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode) + protected function _getStoreByGroup(\Magento\Framework\StoreManagerInterface $storage, $scopeCode) { $groups = $storage->getGroups(true); $stores = $storage->getStores(true); @@ -271,11 +256,11 @@ class StorageFactory } /** - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeCode * @return null|string */ - protected function _getStoreByWebsite(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode) + protected function _getStoreByWebsite(\Magento\Framework\StoreManagerInterface $storage, $scopeCode) { $websites = $storage->getWebsites(true, true); if (!isset($websites[$scopeCode])) { @@ -288,24 +273,24 @@ class StorageFactory } /** - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeType * @return void */ - protected function _checkCookieStore(\Magento\Store\Model\StoreManagerInterface $storage, $scopeType) + protected function _checkCookieStore(\Magento\Framework\StoreManagerInterface $storage, $scopeType) { - $storeCode = $this->_cookieManager->getCookie(Store::COOKIE_NAME); - if (isset($storeCode)) { + $storeCode = $storage->getStore()->getStoreCodeFromCookie(); + if (null != $storeCode) { $this->setCurrentStore($storage, $storeCode, $scopeType); } } /** - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeType * @return void */ - protected function _checkRequestStore(\Magento\Store\Model\StoreManagerInterface $storage, $scopeType) + protected function _checkRequestStore(\Magento\Framework\StoreManagerInterface $storage, $scopeType) { $storeCode = $this->request->getParam('___store'); if (empty($storeCode)) { @@ -316,17 +301,16 @@ class StorageFactory return; } - if ($storage->getStore()->getCode() == $storeCode) { + $storageStore = $storage->getStore(); + if ($storageStore->getCode() == $storeCode) { $store = $storage->getStore($storeCode); if ($store->getWebsite()->getDefaultStore()->getId() == $store->getId()) { - $this->_cookieManager->deleteCookie(Store::COOKIE_NAME); + $store->deleteCookie(); } else { - $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() - ->setDurationOneYear(); - $this->_cookieManager->setPublicCookie(Store::COOKIE_NAME, $storage->getStore()->getCode(), $publicCookieMetadata); + $storageStore->setCookie(); $this->_httpContext->setValue( Store::ENTITY, - $storage->getStore()->getCode(), + $storageStore->getCode(), \Magento\Store\Model\Store::DEFAULT_CODE ); } @@ -341,7 +325,7 @@ class StorageFactory * @param string $scopeCode * @return bool|Store */ - protected function getActiveStoreByCode(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode) + protected function getActiveStoreByCode(\Magento\Framework\StoreManagerInterface $storage, $scopeCode) { $stores = $storage->getStores(true, true); if ($scopeCode && isset($stores[$scopeCode]) @@ -356,12 +340,12 @@ class StorageFactory /** * Set current store * - * @param StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeCode * @param string $scopeType * @return bool */ - protected function setCurrentStore(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode, $scopeType) + protected function setCurrentStore(\Magento\Framework\StoreManagerInterface $storage, $scopeCode, $scopeType) { $store = $this->getActiveStoreByCode($storage, $scopeCode); if (!$store) { diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index dc85ed2177bb16bab329de25961a57290d01eeea..8bba65ab3f4ec9ee8053aebcf60a210c7efcf2f5 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -25,6 +25,7 @@ namespace Magento\Store\Model; use Magento\Directory\Model\Currency\Filter; use Magento\Framework\Model\AbstractModel; +use Magento\Framework\StoreManagerInterface; /** * Store model @@ -118,11 +119,6 @@ class Store extends AbstractModel implements */ const COOKIE_NAME = 'store'; - /** - * Cookie currency key - */ - const COOKIE_CURRENCY = 'currency'; - /** * Script name, which returns all the images */ @@ -354,7 +350,7 @@ class Store extends AbstractModel implements \Magento\Core\Model\Resource\Config\Data $configDataResource, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\App\Config\ReinitableConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Session\SidResolverInterface $sidResolver, \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\Stdlib\CookieManager $cookieManager, @@ -429,9 +425,8 @@ class Store extends AbstractModel implements protected function _getSession() { if (!$this->_session->isSessionExists()) { - $this->_session->start( - 'store_' . $this->getCode() - ); + $this->_session->setName('store_' . $this->getCode()); + $this->_session->start(); } return $this->_session; } @@ -497,7 +492,7 @@ class Store extends AbstractModel implements protected function _getConfig($path) { $data = $this->_config->getValue($path, ScopeInterface::SCOPE_STORE, $this->getCode()); - if (!$data && !$this->_appState->isInstalled()) { + if (!$data) { $data = $this->_config->getValue($path, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT); } return $data === false ? null : $data; @@ -629,10 +624,7 @@ class Store extends AbstractModel implements */ protected function _updatePathUseRewrites($url) { - if ($this->getForceDisableRewrites() || !$this->_getConfig( - self::XML_PATH_USE_REWRITES - ) || !$this->_appState->isInstalled() - ) { + if ($this->getForceDisableRewrites() || !$this->_getConfig(self::XML_PATH_USE_REWRITES)) { if ($this->_isCustomEntryPoint()) { $indexFileName = 'index.php'; } else { @@ -699,7 +691,6 @@ class Store extends AbstractModel implements { return !($this->hasDisableStoreInUrl() && $this->getDisableStoreInUrl()) && - $this->_appState->isInstalled() && $this->_getConfig(self::XML_PATH_STORE_IN_URL); } @@ -757,26 +748,21 @@ class Store extends AbstractModel implements return true; } - if ($this->_appState->isInstalled()) { - $secureBaseUrl = $this->_config->getValue( - self::XML_PATH_SECURE_BASE_URL, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); - - if (!$secureBaseUrl) { - return false; - } + $secureBaseUrl = $this->_config->getValue( + self::XML_PATH_SECURE_BASE_URL, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); - $uri = \Zend_Uri::factory($secureBaseUrl); - $port = $uri->getPort(); - $isSecure = $uri->getScheme() == 'https' && isset( - $_SERVER['SERVER_PORT'] - ) && $port == $_SERVER['SERVER_PORT']; - return $isSecure; - } else { - $isSecure = isset($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT']; - return $isSecure; + if (!$secureBaseUrl) { + return false; } + + $uri = \Zend_Uri::factory($secureBaseUrl); + $port = $uri->getPort(); + $isSecure = $uri->getScheme() == 'https' && isset( + $_SERVER['SERVER_PORT'] + ) && $port == $_SERVER['SERVER_PORT']; + return $isSecure; } /************************************************************************************* @@ -853,16 +839,7 @@ class Store extends AbstractModel implements $code = strtoupper($code); if (in_array($code, $this->getAvailableCurrencyCodes())) { $this->_getSession()->setCurrencyCode($code); - $path = $this->_getSession()->getCookiePath(); - - $sensitiveCookieMetadata = $this->_cookieMetadataFactory->createSensitiveCookieMetadata() - ->setPath($path); - - if ($code == $this->getDefaultCurrency()->getCurrencyCode()) { - $this->_cookieManager->deleteCookie(self::COOKIE_CURRENCY, $sensitiveCookieMetadata); - } else { - $this->_cookieManager->setSensitiveCookie(self::COOKIE_CURRENCY, $code, $sensitiveCookieMetadata); - } + $this->_httpContext->setValue( \Magento\Core\Helper\Data::CONTEXT_CURRENCY, $code, @@ -1314,4 +1291,43 @@ class Store extends AbstractModel implements { return array(self::CACHE_TAG . '_' . $this->getId()); } + + /** + * Set store cookie with this store's code for a year. + * + * @return $this + */ + public function setCookie() + { + $cookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() + ->setHttpOnly(true) + ->setDurationOneYear(); + $this->_cookieManager->setPublicCookie( + self::COOKIE_NAME, + $this->getCode(), + $cookieMetadata + ); + return $this; + } + + /** + * Get store code from store cookie. + * + * @return null|string + */ + public function getStoreCodeFromCookie() + { + return $this->_cookieManager->getCookie(self::COOKIE_NAME); + } + + /** + * Delete store cookie. + * + * @return $this + */ + public function deleteCookie() + { + $this->_cookieManager->deleteCookie(self::COOKIE_NAME); + return $this; + } } diff --git a/app/code/Magento/Store/Model/StoreManager.php b/app/code/Magento/Store/Model/StoreManager.php index e44c6e042482cf789f4dc7ccbba2bb5a07f2f022..6ab4d20352c212cb0216aba6c611398601b98367 100644 --- a/app/code/Magento/Store/Model/StoreManager.php +++ b/app/code/Magento/Store/Model/StoreManager.php @@ -23,7 +23,7 @@ */ namespace Magento\Store\Model; -class StoreManager implements \Magento\Store\Model\StoreManagerInterface +class StoreManager implements \Magento\Framework\StoreManagerInterface { /** * Application run code @@ -120,7 +120,7 @@ class StoreManager implements \Magento\Store\Model\StoreManagerInterface /** * Get storage instance * - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface */ protected function _getStorage() { @@ -178,11 +178,7 @@ class StoreManager implements \Magento\Store\Model\StoreManagerInterface } /** - * Retrieve application store object - * - * @param null|string|bool|int|Store $storeId - * @return Store - * @throws \Magento\Store\Model\Exception + * {@inheritdoc} */ public function getStore($storeId = null) { @@ -246,11 +242,7 @@ class StoreManager implements \Magento\Store\Model\StoreManagerInterface } /** - * Retrieve application store group object - * - * @param null|\Magento\Store\Model\Group|string $groupId - * @return \Magento\Store\Model\Group - * @throws \Magento\Framework\Model\Exception + * {@inheritdoc} */ public function getGroup($groupId = null) { diff --git a/app/code/Magento/Store/Model/StoresConfig.php b/app/code/Magento/Store/Model/StoresConfig.php index b718bae2c0c68bbd6a049568211de4dede1e4314..57936d4cceffd5f5ea56aecf81cbd6d05968a4e3 100644 --- a/app/code/Magento/Store/Model/StoresConfig.php +++ b/app/code/Magento/Store/Model/StoresConfig.php @@ -25,12 +25,12 @@ namespace Magento\Store\Model; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class StoresConfig { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -40,11 +40,11 @@ class StoresConfig protected $_config; /** - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ public function __construct( - StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Store/Model/System/Store.php b/app/code/Magento/Store/Model/System/Store.php index 87d5b37b4af47a1bdfa1ff24df5882b2254b8b37..65b9b66dff90c4bba9872db65c72d9b29eee1431 100644 --- a/app/code/Magento/Store/Model/System/Store.php +++ b/app/code/Magento/Store/Model/System/Store.php @@ -58,7 +58,7 @@ class Store extends \Magento\Framework\Object private $_isAdminScopeAllowed = true; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -66,9 +66,9 @@ class Store extends \Magento\Framework\Object * Init model * Load Website, Group and Store collections * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; return $this->reload(); diff --git a/app/code/Magento/Store/Model/Website.php b/app/code/Magento/Store/Model/Website.php index 319b8e9fd9942fece1adb9684ce5ff8358d3998e..79ff21b2547c0bb59a9c0feb11c38144164070fe 100644 --- a/app/code/Magento/Store/Model/Website.php +++ b/app/code/Magento/Store/Model/Website.php @@ -23,6 +23,8 @@ */ namespace Magento\Store\Model; +use Magento\Framework\StoreManagerInterface; + /** * Core Website model * @@ -186,7 +188,7 @@ class Website extends \Magento\Framework\Model\AbstractModel implements * @param \Magento\Store\Model\StoreFactory $storeFactory * @param \Magento\Store\Model\GroupFactory $storeGroupFactory * @param \Magento\Store\Model\WebsiteFactory $websiteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -200,7 +202,7 @@ class Website extends \Magento\Framework\Model\AbstractModel implements \Magento\Store\Model\StoreFactory $storeFactory, \Magento\Store\Model\GroupFactory $storeGroupFactory, \Magento\Store\Model\WebsiteFactory $websiteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index a91e414b43dc16d99a5480d57709fbc16e1e6c0e..193b79e5e6b6103bc4de36d16a9f4c1144857a17 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-core": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index ca80cd75581eb21d6feea42959266d5fe0c837db..97cd42b2070d5a1cf861d45066ad5b482213330b 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -39,17 +39,17 @@ <type name="Magento\Store\Model\Config\Reader\Store"> <arguments> <argument name="scopePool" xsi:type="object">Magento\Framework\App\Config\ScopePool\Proxy</argument> - <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument> + <argument name="storeManager" xsi:type="object">Magento\Framework\StoreManagerInterface\Proxy</argument> </arguments> </type> <type name="Magento\Store\Model\Resolver\Store"> <arguments> - <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument> + <argument name="storeManager" xsi:type="object">Magento\Framework\StoreManagerInterface\Proxy</argument> </arguments> </type> <type name="Magento\Store\Model\Resolver\Website"> <arguments> - <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument> + <argument name="storeManager" xsi:type="object">Magento\Framework\StoreManagerInterface\Proxy</argument> </arguments> </type> <type name="Magento\Store\Model\Config\Reader\ReaderPool"> @@ -69,9 +69,6 @@ <type name="Magento\Framework\App\Action\Action"> <plugin name="storeCheck" type="Magento\Store\App\Action\Plugin\StoreCheck" sortOrder="10"/> </type> - <type name="Magento\Framework\App\FrontController"> - <plugin name="dispatchExceptionHandler" type="Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler" sortOrder="30"/> - </type> <type name="Magento\Store\Model\Resource\Website\Collection"> <arguments> <argument name="fetchStrategy" xsi:type="object">Magento\Store\Model\Resource\Website\Collection\FetchStrategy</argument> diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php index a9345cbfe80ee5706fe315ce07914ddb66d6f9de..6e75bcbe97209ac84983052bcc0cdc4e34e19578 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php +++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php @@ -31,11 +31,6 @@ namespace Magento\Tax\Controller\Adminhtml; */ class Rate extends \Magento\Backend\App\Action { - /** - * @var \Magento\Framework\App\Response\Http\FileFactory - */ - protected $_fileFactory; - /** * @var \Magento\Framework\Registry */ @@ -63,7 +58,6 @@ class Rate extends \Magento\Backend\App\Action /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Tax\Service\V1\TaxRateServiceInterface $taxRateService * @param \Magento\Tax\Service\V1\Data\TaxRateBuilder $taxRateBuilder @@ -72,14 +66,12 @@ class Rate extends \Magento\Backend\App\Action */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\App\Response\Http\FileFactory $fileFactory, \Magento\Framework\Registry $coreRegistry, \Magento\Tax\Service\V1\TaxRateServiceInterface $taxRateService, \Magento\Tax\Service\V1\Data\TaxRateBuilder $taxRateBuilder, \Magento\Tax\Service\V1\Data\ZipRangeBuilder $zipRangeBuilder, \Magento\Tax\Service\V1\Data\TaxRateTitleBuilder $taxRateTitleBuilder ) { - $this->_fileFactory = $fileFactory; $this->_coreRegistry = $coreRegistry; $this->_taxRateService = $taxRateService; $this->_taxRateBuilder = $taxRateBuilder; @@ -132,28 +124,7 @@ class Rate extends \Magento\Backend\App\Action */ protected function _isAllowed() { - switch ($this->getRequest()->getActionName()) { - case 'importExport': - return $this->_authorization->isAllowed('Magento_Tax::import_export'); - break; - - case 'index': - return $this->_authorization->isAllowed('Magento_Tax::manage_tax'); - break; - - case 'importPost': - case 'exportPost': - return $this->_authorization->isAllowed( - 'Magento_Tax::manage_tax' - ) || $this->_authorization->isAllowed( - 'Magento_Tax::import_export' - ); - break; - - default: - return $this->_authorization->isAllowed('Magento_Tax::manage_tax'); - break; - } + return $this->_authorization->isAllowed('Magento_Tax::manage_tax'); } /** diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php index 11067bcc77d6fa7da9b7f22f43efa4f3c83a0b11..dfa139f1b814d5d8bdfffed705e7a4766539aaa6 100644 --- a/app/code/Magento/Tax/Helper/Data.php +++ b/app/code/Magento/Tax/Helper/Data.php @@ -86,7 +86,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -172,7 +172,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Config $taxConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory * @param \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $taxItemFactory @@ -193,7 +193,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Framework\Registry $coreRegistry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, Config $taxConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $taxItemFactory, diff --git a/app/code/Magento/Tax/Model/Calculation.php b/app/code/Magento/Tax/Model/Calculation.php index 52e592ec26f74072539edd2c89d9138236151605..1f60094b60970ba37364995ca008db4fac54f880 100644 --- a/app/code/Magento/Tax/Model/Calculation.php +++ b/app/code/Magento/Tax/Model/Calculation.php @@ -128,7 +128,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -174,7 +174,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Config $taxConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Tax\Model\Resource\TaxClass\CollectionFactory $classesFactory @@ -192,7 +192,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, Config $taxConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Tax\Model\Resource\TaxClass\CollectionFactory $classesFactory, diff --git a/app/code/Magento/Tax/Model/Resource/Calculation.php b/app/code/Magento/Tax/Model/Resource/Calculation.php index 73ea7a4fc0ab8cfff4ff2d0a11976df187faa41c..3dc1a5b623f8047e8db00f7e97d43ee5a386c845 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation.php @@ -57,19 +57,19 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_taxData; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Tax\Helper\Data $taxData, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_taxData = $taxData; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php index 4392e219147952095e7375023b62c12771b2ece6..d16a823b840e1ab2703bccfd65625d21b7ed92b5 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php @@ -36,7 +36,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac const TAX_RULES_CHUNK_SIZE = 1000; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -45,7 +45,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -54,7 +54,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Tax/Model/System/Message/Notifications.php b/app/code/Magento/Tax/Model/System/Message/Notifications.php index 97df9ccd5f838161b29393c02a21dc0218f348ef..9eb167aa28940fc6b40858d4738fbea7e53c9eb9 100644 --- a/app/code/Magento/Tax/Model/System/Message/Notifications.php +++ b/app/code/Magento/Tax/Model/System/Message/Notifications.php @@ -31,7 +31,7 @@ class Notifications implements \Magento\Framework\Notification\MessageInterface /** * Store manager object * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -62,12 +62,12 @@ class Notifications implements \Magento\Framework\Notification\MessageInterface protected $storesWithInvalidDiscountSettings; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Tax\Model\Config $taxConfig */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Tax\Model\Config $taxConfig ) { diff --git a/app/code/Magento/Tax/Service/V1/TaxCalculationService.php b/app/code/Magento/Tax/Service/V1/TaxCalculationService.php index 6ba8e66711a52bdbb97f3bf616f8b8287f4fe6bf..53f7101944c4d72f272e2126b207b5d4008f0e78 100644 --- a/app/code/Magento/Tax/Service/V1/TaxCalculationService.php +++ b/app/code/Magento/Tax/Service/V1/TaxCalculationService.php @@ -25,7 +25,7 @@ namespace Magento\Tax\Service\V1; use Magento\Customer\Service\V1\CustomerAccountServiceInterface; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Tax\Model\Calculation; use Magento\Tax\Model\Resource\Sales\Order\Tax; use Magento\Tax\Service\V1\Data\QuoteDetails; @@ -82,7 +82,7 @@ class TaxCalculationService implements TaxCalculationServiceInterface protected $taxDetailsItemBuilder; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index 569b13672ea212c11c1695259e89443d3f2655bb..30d2337fc427c492abd412d80223282a49f1ed6b 100644 --- a/app/code/Magento/Tax/composer.json +++ b/app/code/Magento/Tax/composer.json @@ -3,24 +3,24 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-reports": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-configurable-product": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-reports": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-configurable-product": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Tax/etc/acl.xml b/app/code/Magento/Tax/etc/acl.xml index 73edcc94e7150aa0b80edf6348f57e9b353be908..5031185f50847fcaeb6b513d71b656db268c4d36 100644 --- a/app/code/Magento/Tax/etc/acl.xml +++ b/app/code/Magento/Tax/etc/acl.xml @@ -35,12 +35,6 @@ </resource> </resource> </resource> - - <resource id="Magento_Adminhtml::system"> - <resource id="Magento_Adminhtml::convert"> - <resource id="Magento_Tax::import_export" title="Import/Export Tax Rates" sortOrder="30" /> - </resource> - </resource> </resource> </resources> </acl> diff --git a/app/code/Magento/Tax/etc/adminhtml/menu.xml b/app/code/Magento/Tax/etc/adminhtml/menu.xml index 08dd11a9e5d88f8eab432e3e29981ae9f477e9ed..2abe5fa2d0a4c9321bd653c06d06d237b2ec5121 100644 --- a/app/code/Magento/Tax/etc/adminhtml/menu.xml +++ b/app/code/Magento/Tax/etc/adminhtml/menu.xml @@ -28,6 +28,5 @@ <add id="Magento_Tax::sales_tax" title="Taxes" module="Magento_Tax" sortOrder="20" parent="Magento_Backend::stores" resource="Magento_Tax::manage_tax"/> <add id="Magento_Tax::sales_tax_rules" title="Tax Rules" module="Magento_Tax" sortOrder="10" parent="Magento_Tax::sales_tax" action="tax/rule" resource="Magento_Tax::manage_tax"/> <add id="Magento_Tax::sales_tax_rates" title="Tax Zones and Rates" module="Magento_Tax" sortOrder="20" parent="Magento_Tax::sales_tax" action="tax/rate" resource="Magento_Tax::manage_tax"/> - <add id="Magento_Tax::system_convert_tax" title="Import/Export Tax Rates" sortOrder="30" module="Magento_Tax" parent="Magento_Backend::system_convert" action="tax/rate/importExport" resource="Magento_Tax::import_export"/> </menu> </config> diff --git a/app/code/Magento/Tax/view/adminhtml/layout/tax_rate_block.xml b/app/code/Magento/Tax/view/adminhtml/layout/tax_rate_block.xml index a727e22c4a6e2f8245a39b97793076d1790fa75a..ba39177eb2db9353cfeda23b8764d0062d91a37f 100644 --- a/app/code/Magento/Tax/view/adminhtml/layout/tax_rate_block.xml +++ b/app/code/Magento/Tax/view/adminhtml/layout/tax_rate_block.xml @@ -33,20 +33,6 @@ <argument name="default_dir" xsi:type="string">ASC</argument> <argument name="save_parameters_in_session" xsi:type="string">1</argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\Export" name="adminhtml.tax.rate.grid.export" as="grid.export"> - <arguments> - <argument name="exportTypes" xsi:type="array"> - <item name="csv" xsi:type="array"> - <item name="urlPath" xsi:type="string">tax/*/exportCsv</item> - <item name="label" xsi:type="string" translate="true">CSV</item> - </item> - <item name="excel" xsi:type="array"> - <item name="urlPath" xsi:type="string">tax/*/exportXml</item> - <item name="label" xsi:type="string" translate="true">Excel XML</item> - </item> - </argument> - </arguments> - </block> <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" name="adminhtml.catalog.product.set.grid.columnSet" as="grid.columnSet"> <arguments> <argument name="id" xsi:type="string">tax_rate_grid</argument> @@ -57,43 +43,40 @@ </item> </argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="code"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.code" as="code"> <arguments> <argument name="header" xsi:type="string" translate="true">Tax Identifier</argument> - <argument name="header_export" xsi:type="string" translate="true">Code</argument> <argument name="filter_index" xsi:type="string">code</argument> <argument name="index" xsi:type="string">code</argument> <argument name="column_css_class" xsi:type="string">col-name</argument> <argument name="header_css_class" xsi:type="string">col-name</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="tax_country_id"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.tax_country_id" as="tax_country_id"> <arguments> <argument name="header" xsi:type="string" translate="true">Country</argument> <argument name="type" xsi:type="string">country</argument> <argument name="filter_index" xsi:type="string">tax_country_id</argument> <argument name="index" xsi:type="string">tax_country_id</argument> - <argument name="renderer" xsi:type="string">Magento\Tax\Block\Adminhtml\Rate\Grid\Renderer\Country</argument> <argument name="sortable" xsi:type="string">0</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="region_name"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.region_name" as="region_name"> <arguments> <argument name="header" xsi:type="string" translate="true">State/Region</argument> - <argument name="header_export" xsi:type="string" translate="true">State</argument> <argument name="filter_index" xsi:type="string">region_name</argument> <argument name="index" xsi:type="string">region_name</argument> <argument name="default" xsi:type="string">*</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="tax_postcode"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.tax_postcode" as="tax_postcode"> <arguments> <argument name="header" xsi:type="string" translate="true">Zip/Post Code</argument> <argument name="index" xsi:type="string">tax_postcode</argument> <argument name="default" xsi:type="string">*</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="rate"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.rate" as="rate"> <arguments> <argument name="header" xsi:type="string" translate="true">Rate</argument> <argument name="index" xsi:type="string">rate</argument> diff --git a/app/code/Magento/Tax/view/adminhtml/layout/tax_rule_edit.xml b/app/code/Magento/Tax/view/adminhtml/layout/tax_rule_edit.xml index 59185d8a3696a941a5a8ba3a61f2a7beaa557694..e4a91ea35ca79707557aa6ff63d83db0ac391989 100644 --- a/app/code/Magento/Tax/view/adminhtml/layout/tax_rule_edit.xml +++ b/app/code/Magento/Tax/view/adminhtml/layout/tax_rule_edit.xml @@ -45,6 +45,5 @@ <block class="Magento\Tax\Block\Adminhtml\Rule\Edit"/> <block class="Magento\Tax\Block\Adminhtml\Rule\Edit\Form" name="tax-rule-edit" template="rule/edit.phtml"/> <block class="Magento\Tax\Block\Adminhtml\Rate\Form" name="tax-rate-form" template="rule/rate/form.phtml"/> - <block class="Magento\Tax\Block\Adminhtml\Rate\ImportExport" name="tax-rate-importExport" template="importExport.phtml"/> </referenceContainer> </page> diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Country.php b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/Grid/Renderer/Country.php similarity index 95% rename from app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Country.php rename to app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/Grid/Renderer/Country.php index 2bedbed3a897f9203fc978a9bf469ef71cff153b..2a76d3387601a12b8f5c40cc835ffdccfc03a45b 100644 --- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Country.php +++ b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/Grid/Renderer/Country.php @@ -27,7 +27,7 @@ * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Tax\Block\Adminhtml\Rate\Grid\Renderer; +namespace Magento\TaxImportExport\Block\Adminhtml\Rate\Grid\Renderer; class Country extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Country { diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExport.php similarity index 96% rename from app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php rename to app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExport.php index 44020abf4b83550f7487b585ca6e87ec32e205f3..59168cd2401beff067c661d2e622046ad3319212 100644 --- a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php +++ b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExport.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Tax\Block\Adminhtml\Rate; +namespace Magento\TaxImportExport\Block\Adminhtml\Rate; class ImportExport extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExportHeader.php b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportHeader.php similarity index 91% rename from app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExportHeader.php rename to app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportHeader.php index e8ccf8ade1a2c41817ac7dfd53ce3a97b8b17cf9..bbf5b3cb7cf4387ba6058502b999fe84c8781c78 100644 --- a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExportHeader.php +++ b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportHeader.php @@ -24,10 +24,8 @@ /** * Adminhtml import/export header block - * - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Tax\Block\Adminhtml\Rate; +namespace Magento\TaxImportExport\Block\Adminhtml\Rate; class ImportExportHeader extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate.php new file mode 100644 index 0000000000000000000000000000000000000000..cf27043f97e96f90dca8b6028392a832cd360bbb --- /dev/null +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\TaxImportExport\Controller\Adminhtml; + +/** + * Adminhtml tax rate controller + */ +class Rate extends \Magento\Backend\App\Action +{ + /** + * @var \Magento\Framework\App\Response\Http\FileFactory + */ + protected $fileFactory; + + /** + * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magento\Framework\App\Response\Http\FileFactory $fileFactory + ) { + $this->fileFactory = $fileFactory; + parent::__construct($context); + } + + /** + * @return bool + */ + protected function _isAllowed() + { + switch ($this->getRequest()->getActionName()) { + case 'importExport': + return $this->_authorization->isAllowed('Magento_TaxImportExport::import_export'); + case 'importPost': + case 'exportPost': + return $this->_authorization->isAllowed( + 'Magento_Tax::manage_tax' + ) || $this->_authorization->isAllowed( + 'Magento_TaxImportExport::import_export' + ); + default: + return $this->_authorization->isAllowed('Magento_Tax::manage_tax'); + } + } +} diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportCsv.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportCsv.php similarity index 88% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportCsv.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportCsv.php index 2edb90151f59965000506a862648f56939c00b46..83fb86752544bbe3635f5e8cda1e63354481a81a 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportCsv.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportCsv.php @@ -22,11 +22,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; use \Magento\Framework\App\ResponseInterface; -class ExportCsv extends \Magento\Tax\Controller\Adminhtml\Rate +class ExportCsv extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * Export rates grid to CSV format @@ -37,7 +37,7 @@ class ExportCsv extends \Magento\Tax\Controller\Adminhtml\Rate { $this->_view->loadLayout(false); $content = $this->_view->getLayout()->getChildBlock('adminhtml.tax.rate.grid', 'grid.export'); - return $this->_fileFactory->create( + return $this->fileFactory->create( 'rates.csv', $content->getCsvFile(), \Magento\Framework\App\Filesystem::VAR_DIR diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportPost.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php similarity index 93% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportPost.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php index 2c0c0363383936d75924cf48381b0e0d673a61dd..5f6481da900334e5c528eae8de79122b70bcd690 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportPost.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php @@ -22,11 +22,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; use \Magento\Framework\App\ResponseInterface; -class ExportPost extends \Magento\Tax\Controller\Adminhtml\Rate +class ExportPost extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * export action from import/export tax @@ -100,6 +100,6 @@ class ExportPost extends \Magento\Tax\Controller\Adminhtml\Rate $content .= $rate->toString($template) . "\n"; } $this->_view->loadLayout(); - return $this->_fileFactory->create('tax_rates.csv', $content, \Magento\Framework\App\Filesystem::VAR_DIR); + return $this->fileFactory->create('tax_rates.csv', $content, \Magento\Framework\App\Filesystem::VAR_DIR); } } diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportXml.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportXml.php similarity index 88% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportXml.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportXml.php index ca829de220a63a81dce170668ff85958f9b17042..19a3a4f7b9a3ad746a7f99b37f4243fb2331e87e 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportXml.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportXml.php @@ -22,11 +22,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; use \Magento\Framework\App\ResponseInterface; -class ExportXml extends \Magento\Tax\Controller\Adminhtml\Rate +class ExportXml extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * Export rates grid to XML format @@ -37,7 +37,7 @@ class ExportXml extends \Magento\Tax\Controller\Adminhtml\Rate { $this->_view->loadLayout(false); $content = $this->_view->getLayout()->getChildBlock('adminhtml.tax.rate.grid', 'grid.export'); - return $this->_fileFactory->create( + return $this->fileFactory->create( 'rates.xml', $content->getExcelFile(), \Magento\Framework\App\Filesystem::VAR_DIR diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportExport.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php similarity index 75% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportExport.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php index 4165a32467d8a936dbd13dc40dae1b168eb16bf6..fb4085731873bb99e3c61548a811d1f68bd27d75 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportExport.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php @@ -22,9 +22,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; -class ImportExport extends \Magento\Tax\Controller\Adminhtml\Rate +class ImportExport extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * Import and export Page @@ -39,11 +39,11 @@ class ImportExport extends \Magento\Tax\Controller\Adminhtml\Rate $this->_view->loadLayout(); $this->_setActiveMenu( - 'Magento_Tax::system_convert_tax' + 'Magento_TaxImportExport::system_convert_tax' )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Tax\Block\Adminhtml\Rate\ImportExportHeader') + $this->_view->getLayout()->createBlock('Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExportHeader') )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Tax\Block\Adminhtml\Rate\ImportExport') + $this->_view->getLayout()->createBlock('Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport') ); $this->_view->renderLayout(); } diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportPost.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportPost.php similarity index 86% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportPost.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportPost.php index 659d90992a7e52f377c4e7d3b25510b4d708a63d..eae0b262f12d49f995129a319b25c7b95120c321 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportPost.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportPost.php @@ -22,9 +22,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; -class ImportPost extends \Magento\Tax\Controller\Adminhtml\Rate +class ImportPost extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * import action from import/export tax @@ -35,8 +35,8 @@ class ImportPost extends \Magento\Tax\Controller\Adminhtml\Rate { if ($this->getRequest()->isPost() && !empty($_FILES['import_rates_file']['tmp_name'])) { try { - /** @var $importHandler \Magento\Tax\Model\Rate\CsvImportHandler */ - $importHandler = $this->_objectManager->create('Magento\Tax\Model\Rate\CsvImportHandler'); + /** @var $importHandler \Magento\TaxImportExport\Model\Rate\CsvImportHandler */ + $importHandler = $this->_objectManager->create('Magento\TaxImportExport\Model\Rate\CsvImportHandler'); $importHandler->importFromCsvFile($this->getRequest()->getFiles('import_rates_file')); $this->messageManager->addSuccess(__('The tax rate has been imported.')); diff --git a/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php b/app/code/Magento/TaxImportExport/Model/Rate/CsvImportHandler.php similarity index 99% rename from app/code/Magento/Tax/Model/Rate/CsvImportHandler.php rename to app/code/Magento/TaxImportExport/Model/Rate/CsvImportHandler.php index a2b63a019e519a2f4af00c7344f69ff652dcce29..7ca97c0ac847b91d5dc98ea2844c0a9ef988030b 100644 --- a/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php +++ b/app/code/Magento/TaxImportExport/Model/Rate/CsvImportHandler.php @@ -21,12 +21,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\TaxImportExport\Model\Rate; /** * Tax Rate CSV Import Handler */ -namespace Magento\Tax\Model\Rate; - class CsvImportHandler { /** diff --git a/app/code/Magento/TaxImportExport/composer.json b/app/code/Magento/TaxImportExport/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..3beada316bd4eb845f7ca5f5b708ec141e46db73 --- /dev/null +++ b/app/code/Magento/TaxImportExport/composer.json @@ -0,0 +1,23 @@ +{ + "name": "magento/module-tax-import-export", + "description": "N/A", + "require": { + "php": "~5.4.11|~5.5.0", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/magento-composer-installer": "*" + }, + "type": "magento2-module", + "version": "0.1.0-alpha95", + "extra": { + "map": [ + [ + "*", + "Magento/TaxImportExport" + ] + ] + } +} diff --git a/app/code/Magento/TaxImportExport/etc/acl.xml b/app/code/Magento/TaxImportExport/etc/acl.xml new file mode 100644 index 0000000000000000000000000000000000000000..1df0c1e0d5345bb50bab8a62ab60e2cdc77698a7 --- /dev/null +++ b/app/code/Magento/TaxImportExport/etc/acl.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> + <acl> + <resources> + <resource id="Magento_Adminhtml::admin"> + <resource id="Magento_Adminhtml::system"> + <resource id="Magento_Adminhtml::convert"> + <resource id="Magento_TaxImportExport::import_export" title="Import/Export Tax Rates" sortOrder="30" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/Magento/Checkout/etc/adminhtml/di.xml b/app/code/Magento/TaxImportExport/etc/adminhtml/menu.xml similarity index 74% rename from app/code/Magento/Checkout/etc/adminhtml/di.xml rename to app/code/Magento/TaxImportExport/etc/adminhtml/menu.xml index 56b53502170837754f5ad84cec2685239c528ef7..d2e1c2b1a6d94fa8ec3298bc90409065e214f620 100644 --- a/app/code/Magento/Checkout/etc/adminhtml/di.xml +++ b/app/code/Magento/TaxImportExport/etc/adminhtml/menu.xml @@ -23,10 +23,9 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Checkout\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd"> + <menu> + <add id="Magento_TaxImportExport::system_convert_tax" title="Import/Export Tax Rates" sortOrder="30" module="Magento_TaxImportExport" parent="Magento_Backend::system_convert" action="tax/rate/importExport" resource="Magento_TaxImportExport::import_export"/> + </menu> </config> + diff --git a/app/code/Magento/Install/etc/install/routes.xml b/app/code/Magento/TaxImportExport/etc/adminhtml/routes.xml similarity index 89% rename from app/code/Magento/Install/etc/install/routes.xml rename to app/code/Magento/TaxImportExport/etc/adminhtml/routes.xml index 4baf339c284dd6eeed4945aaed02f4205342aa7d..bab5c4dfcc15ab100c50a6ea50a41a498a58708e 100644 --- a/app/code/Magento/Install/etc/install/routes.xml +++ b/app/code/Magento/TaxImportExport/etc/adminhtml/routes.xml @@ -24,9 +24,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd"> - <router id="install"> - <route id="install" frontName="install"> - <module name="Magento_Install" /> + <router id="admin"> + <route id="tax"> + <module name="Magento_TaxImportExport" /> </route> </router> -</config> \ No newline at end of file +</config> diff --git a/app/code/Magento/TaxImportExport/etc/module.xml b/app/code/Magento/TaxImportExport/etc/module.xml new file mode 100644 index 0000000000000000000000000000000000000000..d9cffcf0454cce8a75caa79600c77f7da84b30fe --- /dev/null +++ b/app/code/Magento/TaxImportExport/etc/module.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> + <module name="Magento_TaxImportExport" schema_version="1.0.0.0" active="true"> + <sequence> + <module name="Magento_Tax"/> + </sequence> + <depends> + <module name="Magento_Backend"/> + <module name="Magento_Directory"/> + <module name="Magento_Store"/> + <module name="Magento_Tax"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rate_block.xml b/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rate_block.xml new file mode 100644 index 0000000000000000000000000000000000000000..144e1741e33771205f56c7864f5f819a2d36d872 --- /dev/null +++ b/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rate_block.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="adminhtml.tax.rate.grid"> + <block class="Magento\Backend\Block\Widget\Grid\Export" name="adminhtml.tax.rate.grid.export" as="grid.export"> + <arguments> + <argument name="exportTypes" xsi:type="array"> + <item name="csv" xsi:type="array"> + <item name="urlPath" xsi:type="string">tax/*/exportCsv</item> + <item name="label" xsi:type="string" translate="true">CSV</item> + </item> + <item name="excel" xsi:type="array"> + <item name="urlPath" xsi:type="string">tax/*/exportXml</item> + <item name="label" xsi:type="string" translate="true">Excel XML</item> + </item> + </argument> + </arguments> + </block> + </referenceBlock> + <referenceBlock name="adminhtml.catalog.product.set.grid.column.tax_country_id"> + <arguments> + <argument name="renderer" xsi:type="string">Magento\TaxImportExport\Block\Adminhtml\Rate\Grid\Renderer\Country</argument> + </arguments> + </referenceBlock> + <referenceBlock name="adminhtml.catalog.product.set.grid.column.code"> + <arguments> + <argument name="header_export" xsi:type="string" translate="true">Code</argument> + </arguments> + </referenceBlock> + <referenceBlock name="adminhtml.catalog.product.set.grid.column.region_name"> + <arguments> + <argument name="header_export" xsi:type="string" translate="true">State</argument> + </arguments> + </referenceBlock> +</page> diff --git a/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rule_edit.xml b/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rule_edit.xml new file mode 100644 index 0000000000000000000000000000000000000000..3e9c44aba1ad1ac1a221082962613ed0c6ed28e7 --- /dev/null +++ b/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rule_edit.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="content"> + <block class="Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport" name="tax-rate-importExport" template="importExport.phtml"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Tax/view/adminhtml/templates/importExport.phtml b/app/code/Magento/TaxImportExport/view/adminhtml/templates/importExport.phtml similarity index 100% rename from app/code/Magento/Tax/view/adminhtml/templates/importExport.phtml rename to app/code/Magento/TaxImportExport/view/adminhtml/templates/importExport.phtml diff --git a/app/code/Magento/Tax/view/adminhtml/templates/importExportHeader.phtml b/app/code/Magento/TaxImportExport/view/adminhtml/templates/importExportHeader.phtml similarity index 100% rename from app/code/Magento/Tax/view/adminhtml/templates/importExportHeader.phtml rename to app/code/Magento/TaxImportExport/view/adminhtml/templates/importExportHeader.phtml diff --git a/app/code/Magento/Theme/Block/Html/Header.php b/app/code/Magento/Theme/Block/Html/Header.php index 1dc1bd5e765ce4c6f48141d334a0441d900ef688..2122de2a370ddb42c800780611e1985d16b7fb0d 100644 --- a/app/code/Magento/Theme/Block/Html/Header.php +++ b/app/code/Magento/Theme/Block/Html/Header.php @@ -132,7 +132,7 @@ class Header extends \Magento\Framework\View\Element\Template public function getWelcome() { if (empty($this->_data['welcome'])) { - if ($this->_appState->isInstalled() && $this->httpContext->getValue(Data::CONTEXT_AUTH)) { + if ($this->httpContext->getValue(Data::CONTEXT_AUTH)) { $customerName = $this->_customerViewHelper->getCustomerName( $this->_customerSession->getCustomerDataObject() ); diff --git a/app/code/Magento/Theme/Model/Config.php b/app/code/Magento/Theme/Model/Config.php index 2a1df6946d9a8e00f1710c850505bb8c8084a8d8..b5d20f50e498fae418c337474fcf46cebde03c4c 100644 --- a/app/code/Magento/Theme/Model/Config.php +++ b/app/code/Magento/Theme/Model/Config.php @@ -40,7 +40,7 @@ class Config protected $_configData; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -64,7 +64,7 @@ class Config /** * @param \Magento\Framework\App\Config\ValueInterface $configData * @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Cache\FrontendInterface $configCache * @param \Magento\Framework\Cache\FrontendInterface $layoutCache @@ -72,7 +72,7 @@ class Config public function __construct( \Magento\Framework\App\Config\ValueInterface $configData, \Magento\Framework\App\Config\Storage\WriterInterface $configWriter, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Cache\FrontendInterface $configCache, \Magento\Framework\Cache\FrontendInterface $layoutCache diff --git a/app/code/Magento/Theme/Model/Config/Customization.php b/app/code/Magento/Theme/Model/Config/Customization.php index b838fbdc3e3aaf5b8abef156eeba53d076066b27..b01eba7a374aea6d5fa4ef089502818453fa5def 100644 --- a/app/code/Magento/Theme/Model/Config/Customization.php +++ b/app/code/Magento/Theme/Model/Config/Customization.php @@ -29,7 +29,7 @@ namespace Magento\Theme\Model\Config; class Customization { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,12 +60,12 @@ class Customization protected $_unassignedTheme; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider ) { diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 0e97827918419ffe7aadff0c17cafc650ada8b3c..9c1cd7028adbe867f8e748efe7d253decb7860c3 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-translation": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-translation": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Translation/Model/Inline/Parser.php b/app/code/Magento/Translation/Model/Inline/Parser.php index 1c809410bd47d09982b354ae4dec6e3afceda6d2..26cc27a7f7e13303a07f73d88159dd6019c768be 100644 --- a/app/code/Magento/Translation/Model/Inline/Parser.php +++ b/app/code/Magento/Translation/Model/Inline/Parser.php @@ -113,7 +113,7 @@ class Parser implements \Magento\Framework\Translate\Inline\ParserInterface protected $_resourceFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -140,7 +140,7 @@ class Parser implements \Magento\Framework\Translate\Inline\ParserInterface /** * Initialize base inline translation model * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Translation\Model\Resource\StringFactory $resource * @param \Zend_Filter_Interface $inputFilter * @param \Magento\Framework\App\State $appState @@ -149,7 +149,7 @@ class Parser implements \Magento\Framework\Translate\Inline\ParserInterface */ public function __construct( \Magento\Translation\Model\Resource\StringFactory $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Zend_Filter_Interface $inputFilter, \Magento\Framework\App\State $appState, \Magento\Framework\App\Cache\TypeListInterface $appCache, diff --git a/app/code/Magento/Translation/Model/Resource/Translate.php b/app/code/Magento/Translation/Model/Resource/Translate.php index 180e00f407106dcd975c691ceea579040e304712..42fc1b678c4ac661a5eb2b8945c72f185cb8470b 100644 --- a/app/code/Magento/Translation/Model/Resource/Translate.php +++ b/app/code/Magento/Translation/Model/Resource/Translate.php @@ -23,12 +23,9 @@ */ namespace Magento\Translation\Model\Resource; -class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implements \Magento\Framework\Translate\ResourceInterface +class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implements + \Magento\Framework\Translate\ResourceInterface { - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; /** * @var \Magento\Framework\App\ScopeResolverInterface @@ -42,17 +39,14 @@ class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implemen /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param null|string $scope */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Framework\App\State $appState, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, $scope = null ) { - $this->_appState = $appState; $this->scopeResolver = $scopeResolver; $this->scope = $scope; parent::__construct($resource); @@ -77,10 +71,6 @@ class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implemen */ public function getTranslationArray($storeId = null, $locale = null) { - if (!$this->_appState->isInstalled()) { - return array(); - } - if (is_null($storeId)) { $storeId = $this->getStoreId(); } @@ -110,10 +100,6 @@ class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implemen */ public function getTranslationArrayByStrings(array $strings, $storeId = null) { - if (!$this->_appState->isInstalled()) { - return array(); - } - if (is_null($storeId)) { $storeId = $this->getStoreId(); } diff --git a/app/code/Magento/Translation/composer.json b/app/code/Magento/Translation/composer.json index 2ce469dc12e6bbe08a5d28a3f86ce08d5b8df058..69638e1b2fffadeef154950794d3bd52ca9b5501 100644 --- a/app/code/Magento/Translation/composer.json +++ b/app/code/Magento/Translation/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-core": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index 29b7125bc8f992c73829d7117a0b1fa5d43c7320..93639fbc240f50219a84b8cc14ce1969f49f3e9c 100644 --- a/app/code/Magento/Ups/composer.json +++ b/app/code/Magento/Ups/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRedirect/Block/Catalog/Edit/Form.php b/app/code/Magento/UrlRedirect/Block/Catalog/Edit/Form.php index 0875908a272676c642eb2f4bf6bd4d1e2e215703..450beaea8d4e87b222cd9f38c01bda9481c2a2d5 100644 --- a/app/code/Magento/UrlRedirect/Block/Catalog/Edit/Form.php +++ b/app/code/Magento/UrlRedirect/Block/Catalog/Edit/Form.php @@ -155,7 +155,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form * Get catalog entity associated stores * * @return array - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\Model\Exception */ protected function _getEntityStores() { @@ -173,7 +173,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form $entityStores = array_intersect($entityStores, $categoryStores); } if (!$entityStores) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\Model\Exception( __( 'We can\'t set up a URL rewrite because the product you chose is not associated with a website.' ) @@ -186,7 +186,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form 'We can\'t set up a URL rewrite because the category your chose is not associated with a website.' ); if (!$entityStores) { - throw new \Magento\Store\Model\Exception($message); + throw new \Magento\Framework\Model\Exception($message); } $this->_requireStoresFilter = true; } diff --git a/app/code/Magento/UrlRedirect/Block/Cms/Page/Edit/Form.php b/app/code/Magento/UrlRedirect/Block/Cms/Page/Edit/Form.php index 519589c91dd6b43b559de42d0450eb59d27fc0d8..6cdc0a33bfc087739cd8a1ab98deb53f9fcc93f1 100644 --- a/app/code/Magento/UrlRedirect/Block/Cms/Page/Edit/Form.php +++ b/app/code/Magento/UrlRedirect/Block/Cms/Page/Edit/Form.php @@ -128,7 +128,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form * Get catalog entity associated stores * * @return array - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ protected function _getEntityStores() { @@ -141,7 +141,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form $this->_requireStoresFilter = !in_array(0, $entityStores); if (!$entityStores) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\App\InitException( __('Chosen cms page does not associated with any website.') ); } diff --git a/app/code/Magento/UrlRedirect/Controller/Router.php b/app/code/Magento/UrlRedirect/Controller/Router.php index 26b365613cddb7e759a01e246b1ce15e14f39dde..2407898978ebc851125854ff6c68314b85cc49c0 100644 --- a/app/code/Magento/UrlRedirect/Controller/Router.php +++ b/app/code/Magento/UrlRedirect/Controller/Router.php @@ -28,13 +28,7 @@ namespace Magento\UrlRedirect\Controller; */ class Router implements \Magento\Framework\App\RouterInterface { - /** @var \Magento\Framework\UrlInterface */ - protected $url; - - /** @var \Magento\Framework\App\State */ - protected $appState; - - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** @var \Magento\Framework\App\ResponseInterface */ @@ -50,23 +44,17 @@ class Router implements \Magento\Framework\App\RouterInterface /** * @param \Magento\Framework\App\ActionFactory $actionFactory - * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\ResponseInterface $response * @param \Magento\UrlRedirect\Service\V1\UrlMatcherInterface $urlMatcher */ public function __construct( \Magento\Framework\App\ActionFactory $actionFactory, - \Magento\Framework\UrlInterface $url, - \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\ResponseInterface $response, \Magento\UrlRedirect\Service\V1\UrlMatcherInterface $urlMatcher ) { $this->actionFactory = $actionFactory; - $this->url = $url; - $this->appState = $appState; $this->storeManager = $storeManager; $this->response = $response; $this->urlMatcher = $urlMatcher; @@ -80,11 +68,6 @@ class Router implements \Magento\Framework\App\RouterInterface */ public function match(\Magento\Framework\App\RequestInterface $request) { - if (!$this->appState->isInstalled()) { - $this->response->setRedirect($this->url->getUrl('install'))->sendResponse(); - return null; - } - $identifier = trim($request->getPathInfo(), '/'); $urlRewrite = $this->urlMatcher->match($identifier, $this->storeManager->getStore()->getId()); if ($urlRewrite === null) { diff --git a/app/code/Magento/UrlRedirect/Model/Resource/UrlRedirect/Collection.php b/app/code/Magento/UrlRedirect/Model/Resource/UrlRedirect/Collection.php index 9cc9f17e6f3b6cb4948cf94043bce37f75795055..edfa155165512706d4658de3e572c0b8160266b9 100644 --- a/app/code/Magento/UrlRedirect/Model/Resource/UrlRedirect/Collection.php +++ b/app/code/Magento/UrlRedirect/Model/Resource/UrlRedirect/Collection.php @@ -30,7 +30,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store Manager Model * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -39,7 +39,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -48,7 +48,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/UrlRedirect/composer.json b/app/code/Magento/UrlRedirect/composer.json index ad444a0f9146afa036addfcd2206988c740bf914..ebfb97ff4fe85224c5a403e7ec73054462445c7b 100644 --- a/app/code/Magento/UrlRedirect/composer.json +++ b/app/code/Magento/UrlRedirect/composer.json @@ -3,16 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-install": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRedirect/etc/module.xml b/app/code/Magento/UrlRedirect/etc/module.xml index 1202c64f7285f0189fcdeac1b6e4463c834d4d4f..dd2376b022c52d444332205fdd97d596de9c901b 100644 --- a/app/code/Magento/UrlRedirect/etc/module.xml +++ b/app/code/Magento/UrlRedirect/etc/module.xml @@ -30,7 +30,6 @@ <module name="Magento_Cms"/> <module name="Magento_Core"/> <module name="Magento_Backend"/> - <module name="Magento_Install"/> <module name="Magento_Store"/> </depends> </module> diff --git a/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php b/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php index f3141604122c534255d86ddb0e54d9ea7ad56e71..be99bf62d82bdad56251a3bcaf2e5a9225c473fa 100644 --- a/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php @@ -32,25 +32,17 @@ class UrlRewrite */ protected $_rewriteService; - /** - * @var \Magento\Framework\App\State - */ - protected $_state; - /** * @param \Magento\UrlRewrite\App\Request\RewriteService $rewriteService - * @param \Magento\Framework\App\State $state */ public function __construct( - \Magento\UrlRewrite\App\Request\RewriteService $rewriteService, - \Magento\Framework\App\State $state + \Magento\UrlRewrite\App\Request\RewriteService $rewriteService ) { $this->_rewriteService = $rewriteService; - $this->_state = $state; } /** - * Perform url rewites + * Perform url rewrites * * @param \Magento\Framework\App\FrontController $subject * @param callable $proceed @@ -64,9 +56,6 @@ class UrlRewrite \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { - if (!$this->_state->isInstalled()) { - return $proceed($request); - } $this->_rewriteService->applyRewrites($request); return $proceed($request); } diff --git a/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php b/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php index de4b19b675e77f7ae562e1be2daaa591aabb900a..8724cf077d21b3af04fcfdeca7baae0884ad25dc 100644 --- a/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php +++ b/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php @@ -30,7 +30,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store Manager Model * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -39,7 +39,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -48,7 +48,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/UrlRewrite/Model/UrlRewrite.php b/app/code/Magento/UrlRewrite/Model/UrlRewrite.php index 6334646455d648789e3ad4af0ae67c45932f769a..e8837ea865dff5bdab000ea30204a1a69cf22e6c 100644 --- a/app/code/Magento/UrlRewrite/Model/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/Model/UrlRewrite.php @@ -81,17 +81,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory - */ - protected $_cookieMetadataFactory; - - /** - * @var \Magento\Framework\Stdlib\CookieManager - */ - protected $_cookieManager; - - /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -104,9 +94,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - * @param \Magento\Framework\Stdlib\CookieManager $cookieManager, - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -116,9 +104,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - \Magento\Framework\Stdlib\CookieManager $cookieManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, @@ -126,8 +112,6 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel ) { $this->_scopeConfig = $scopeConfig; parent::__construct($context, $registry, $resource, $resourceCollection, $data); - $this->_cookieManager = $cookieManager; - $this->_cookieMetadataFactory = $cookieMetadataFactory; $this->_storeManager = $storeManager; $this->_httpContext = $httpContext; } @@ -207,9 +191,6 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel */ public function rewrite(\Magento\Framework\App\RequestInterface $request = null) { - if (!$this->_appState->isInstalled()) { - return false; - } if (is_null($this->getStoreId()) || false === $this->getStoreId()) { $this->setStoreId($this->_storeManager->getStore()->getId()); } @@ -256,14 +237,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel } $currentStore = $this->_storeManager->getStore(); $this->setStoreId($currentStore->getId())->loadByIdPath($this->getIdPath()); - - $cookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() - ->setDurationOneYear(); - $this->_cookieManager->setPublicCookie( - \Magento\Store\Model\Store::COOKIE_NAME, - $currentStore->getCode(), - $cookieMetadata - ); + $currentStore->setCookie(); $targetUrl .= '/' . $this->getRequestPath(); $this->_sendRedirectHeaders($targetUrl, true); @@ -278,16 +252,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel $external = substr($this->getTargetPath(), 0, 6); $isPermanentRedirectOption = $this->hasOption('RP'); if ($external === 'http:/' || $external === 'https:') { - $destinationStoreCode = $this->_storeManager->getStore($this->getStoreId())->getCode(); - - $cookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() - ->setDurationOneYear(); - $this->_cookieManager->setPublicCookie( - \Magento\Store\Model\Store::COOKIE_NAME, - $destinationStoreCode, - $cookieMetadata - ); - + $this->_storeManager->getStore($this->getStoreId())->setCookie(); $this->_sendRedirectHeaders($this->getTargetPath(), $isPermanentRedirectOption); } else { $targetUrl .= '/' . $this->getTargetPath(); diff --git a/app/code/Magento/UrlRewrite/composer.json b/app/code/Magento/UrlRewrite/composer.json index 16b328cf8efdd2b14773d6cb3c7cd8946182b9f0..93f34470c00b3735664e70f66fb6e094e818ab4e 100644 --- a/app/code/Magento/UrlRewrite/composer.json +++ b/app/code/Magento/UrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/User/Controller/Adminhtml/User/InvalidateToken.php b/app/code/Magento/User/Controller/Adminhtml/User/InvalidateToken.php index f4b10c5f9e14dfd864465d2bd66350f9a7a44a9d..f01c928ae02067efc3a87ddf0c9d2842d76e4e8a 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User/InvalidateToken.php +++ b/app/code/Magento/User/Controller/Adminhtml/User/InvalidateToken.php @@ -36,8 +36,8 @@ class InvalidateToken extends \Magento\User\Controller\Adminhtml\User public function execute() { if ($userId = $this->getRequest()->getParam('user_id')) { - /** @var \Magento\Integration\Service\V1\TokenService $tokenService */ - $tokenService = $this->_objectManager->get('\Magento\Integration\Service\V1\TokenService'); + /** @var \Magento\Integration\Service\V1\AdminTokenService $tokenService */ + $tokenService = $this->_objectManager->get('\Magento\Integration\Service\V1\AdminTokenService'); try { $tokenService->revokeAdminAccessToken($userId); $this->messageManager->addSuccess(__('You have revoked the user\'s tokens.')); diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index 3d33fe0582803243c4e3bafe25acb76ca6d4bf98..400c0330ef7abe9fe4bf8cfb2380814648b182a7 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -138,7 +138,7 @@ class User extends AbstractModel implements StorageInterface protected $_transportBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -154,7 +154,7 @@ class User extends AbstractModel implements StorageInterface * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -169,7 +169,7 @@ class User extends AbstractModel implements StorageInterface \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -231,7 +231,7 @@ class User extends AbstractModel implements StorageInterface $this->_roleFactory = $objectManager->get('Magento\Authorization\Model\RoleFactory'); $this->_encryptor = $objectManager->get('Magento\Framework\Encryption\EncryptorInterface'); $this->_transportBuilder = $objectManager->get('Magento\Framework\Mail\Template\TransportBuilder'); - $this->_storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManager = $objectManager->get('Magento\Framework\StoreManagerInterface'); } /** diff --git a/app/code/Magento/User/composer.json b/app/code/Magento/User/composer.json index ccf61d9172bcb91afc2814bf46fbe3d34a2ad7da..bb64e5f3972b8b5f11ea165efe4195bc78969994 100644 --- a/app/code/Magento/User/composer.json +++ b/app/code/Magento/User/composer.json @@ -3,17 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-authorization": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-integration": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-authorization": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-integration": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/User/etc/module.xml b/app/code/Magento/User/etc/module.xml index 7c4efc0c354bf3a1c04fff3a0bf89f5d46163b33..7dfc874d137fe5924c91e4b2adc08c3187f081bb 100644 --- a/app/code/Magento/User/etc/module.xml +++ b/app/code/Magento/User/etc/module.xml @@ -30,7 +30,6 @@ </sequence> <depends> <module name="Magento_Authorization"/> - <module name="Magento_Store"/> <module name="Magento_Backend"/> <module name="Magento_Core"/> <module name="Magento_Integration"/> diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index d8e166eb745e6b403fe84655c17f6bdc9e8078bd..84261a44ba4dd485bc162e4b305b8dd13155a085 100644 --- a/app/code/Magento/Usps/composer.json +++ b/app/code/Magento/Usps/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php index 7e9ba9b4f10520fab5b77217f903ce88378ddf4b..af6fe32e7492a7191e87aaf358b86941a377b6ea 100644 --- a/app/code/Magento/Webapi/Controller/Rest.php +++ b/app/code/Magento/Webapi/Controller/Rest.php @@ -26,9 +26,7 @@ namespace Magento\Webapi\Controller; use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\AuthorizationInterface; use Magento\Framework\Exception\AuthorizationException; -use Magento\Framework\Service\Data\AbstractSimpleObject; -use Magento\Framework\Service\Data\AbstractExtensibleObject; -use Magento\Framework\Service\ExtensibleDataObjectConverter; +use Magento\Framework\Service\SimpleDataObjectConverter; use Magento\Webapi\Controller\Rest\Request as RestRequest; use Magento\Webapi\Controller\Rest\Response as RestResponse; use Magento\Webapi\Controller\Rest\Response\PartialResponseProcessor; @@ -65,9 +63,6 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface /** @var \Magento\Framework\App\State */ protected $_appState; - /** @var \Magento\Framework\View\LayoutInterface */ - protected $_layout; - /** @var AuthorizationInterface */ protected $_authorization; @@ -100,6 +95,11 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface */ protected $userContext; + /** + * @var SimpleDataObjectConverter $dataObjectConverter + */ + protected $dataObjectConverter; + /** * Initialize dependencies * @@ -108,7 +108,6 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface * @param Router $router * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\View\LayoutInterface $layout * @param AuthorizationInterface $authorization * @param ServiceArgsSerializer $serializer * @param ErrorProcessor $errorProcessor @@ -116,6 +115,7 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface * @param \Magento\Framework\App\AreaList $areaList * @param PartialResponseProcessor $partialResponseProcessor * @param UserContextInterface $userContext + * @param SimpleDataObjectConverter $dataObjectConverter * * TODO: Consider removal of warning suppression * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -126,21 +126,20 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface Router $router, \Magento\Framework\ObjectManager $objectManager, \Magento\Framework\App\State $appState, - \Magento\Framework\View\LayoutInterface $layout, AuthorizationInterface $authorization, ServiceArgsSerializer $serializer, ErrorProcessor $errorProcessor, PathProcessor $pathProcessor, \Magento\Framework\App\AreaList $areaList, PartialResponseProcessor $partialResponseProcessor, - UserContextInterface $userContext + UserContextInterface $userContext, + SimpleDataObjectConverter $dataObjectConverter ) { $this->_router = $router; $this->_request = $request; $this->_response = $response; $this->_objectManager = $objectManager; $this->_appState = $appState; - $this->_layout = $layout; $this->_authorization = $authorization; $this->_serializer = $serializer; $this->_errorProcessor = $errorProcessor; @@ -148,6 +147,7 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $this->areaList = $areaList; $this->partialResponseProcessor = $partialResponseProcessor; $this->userContext = $userContext; + $this->dataObjectConverter = $dataObjectConverter; } /** @@ -163,9 +163,6 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $this->areaList->getArea($this->_appState->getAreaCode()) ->load(\Magento\Framework\App\Area::PART_TRANSLATE); try { - if (!$this->_appState->isInstalled()) { - throw new \Magento\Webapi\Exception(__('Magento is not yet installed')); - } $this->checkPermissions(); $route = $this->getCurrentRoute(); if ($route->isSecure() && !$this->_request->isSecure()) { @@ -180,7 +177,7 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $service = $this->_objectManager->get($serviceClassName); /** @var \Magento\Framework\Service\Data\AbstractExtensibleObject $outputData */ $outputData = call_user_func_array([$service, $serviceMethodName], $inputParams); - $outputData = $this->processServiceOutput($outputData); + $outputData = $this->dataObjectConverter->processServiceOutput($outputData); if ($this->_request->getParam(PartialResponseProcessor::FILTER_PARAMETER) && is_array($outputData)) { $outputData = $this->partialResponseProcessor->filter($outputData); } @@ -192,61 +189,6 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface return $this->_response; } - /** - * Converts the incoming data into scalar or an array of scalars format. - * - * If the data provided is null, then an empty array is returned. Otherwise, if the data is an object, it is - * assumed to be a Data Object and converted to an associative array with keys representing the properties of the - * Data Object. - * Nested Data Objects are also converted. If the data provided is itself an array, then we iterate through the - * contents and convert each piece individually. - * - * @param mixed $data - * @return array|int|string|bool|float Scalar or array of scalars - */ - protected function processServiceOutput($data) - { - if (is_array($data)) { - $result = []; - foreach ($data as $datum) { - if ($datum instanceof AbstractSimpleObject) { - $datum = $this->processDataObject($datum->__toArray()); - } - $result[] = $datum; - } - return $result; - } else if ($data instanceof AbstractSimpleObject) { - return $this->processDataObject($data->__toArray()); - } else if (is_null($data)) { - return []; - } else { - /** No processing is required for scalar types */ - return $data; - } - } - - /** - * Convert data object to array and process available custom attributes - * - * @param array $dataObjectArray - * @return array - */ - protected function processDataObject($dataObjectArray) - { - if (isset($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) { - $dataObjectArray = ExtensibleDataObjectConverter::convertCustomAttributesToSequentialArray( - $dataObjectArray - ); - } - //Check for nested custom_attributes - foreach ($dataObjectArray as $key => $value) { - if (is_array($value)) { - $dataObjectArray[$key] = $this->processDataObject($value); - } - } - return $dataObjectArray; - } - /** * Override parameter values based on webapi.xml * diff --git a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php index 824887091673dbe12e1340ec8fbfc6c0f5855bb3..1b40db6cbf42f8f1b672218e49f58e701cab9560 100644 --- a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php +++ b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php @@ -25,13 +25,15 @@ */ namespace Magento\Webapi\Controller; +use Magento\Framework\ObjectManager; +use Magento\Framework\Service\Config\Reader as ServiceConfigReader; +use Magento\Framework\Service\Data\AttributeValue; +use Magento\Framework\Service\Data\AttributeValueBuilder; +use Magento\Webapi\Model\Config\ClassReflector\TypeProcessor; use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\MethodReflection; use Zend\Code\Reflection\ParameterReflection; -use Magento\Framework\ObjectManager; -use Magento\Webapi\Model\Config\ClassReflector\TypeProcessor; -use Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy; -use \Magento\Webapi\DeserializationException; +use Magento\Framework\Service\SimpleDataObjectConverter; class ServiceArgsSerializer { @@ -41,16 +43,30 @@ class ServiceArgsSerializer /** @var ObjectManager */ protected $_objectManager; + /** @var ServiceConfigReader */ + protected $serviceConfigReader; + + /** @var AttributeValueBuilder */ + protected $attributeValueBuilder; + /** * Initialize dependencies. * * @param TypeProcessor $typeProcessor * @param ObjectManager $objectManager + * @param ServiceConfigReader $serviceConfigReader + * @param AttributeValueBuilder $attributeValueBuilder */ - public function __construct(TypeProcessor $typeProcessor, ObjectManager $objectManager) - { + public function __construct( + TypeProcessor $typeProcessor, + ObjectManager $objectManager, + ServiceConfigReader $serviceConfigReader, + AttributeValueBuilder $attributeValueBuilder + ) { $this->_typeProcessor = $typeProcessor; $this->_objectManager = $objectManager; + $this->serviceConfigReader = $serviceConfigReader; + $this->attributeValueBuilder = $attributeValueBuilder; } /** @@ -139,18 +155,78 @@ class ServiceArgsSerializer foreach ($data as $propertyName => $value) { // Converts snake_case to uppercase CamelCase to help form getter/setter method names // This use case is for REST only. SOAP request data is already camel cased - $camelCaseProperty = str_replace(' ', '', ucwords(str_replace('_', ' ', $propertyName))); + $camelCaseProperty = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($propertyName); $methodName = $this->_processGetterMethod($class, $camelCaseProperty); $methodReflection = $class->getMethod($methodName); if ($methodReflection->isPublic()) { $returnType = $this->_typeProcessor->getGetterReturnType($methodReflection)['type']; $setterName = 'set' . $camelCaseProperty; - $builder->{$setterName}($this->_convertValue($value, $returnType)); + if ($camelCaseProperty === 'CustomAttributes') { + $setterValue = $this->convertCustomAttributeValue($value, $returnType, $className); + } else { + $setterValue = $this->_convertValue($value, $returnType); + } + $builder->{$setterName}($setterValue); } } return $builder->create(); } + /** + * Convert custom attribute data array to array of AttributeValue Data Object + * + * @param array $customAttributesValueArray + * @param string $returnType + * @param string $dataObjectClassName + * @return AttributeValue[] + */ + protected function convertCustomAttributeValue($customAttributesValueArray, $returnType, $dataObjectClassName) + { + $result = []; + $allAttributes = $this->serviceConfigReader->read(); + $dataObjectClassName = ltrim($dataObjectClassName, '\\'); + if (!isset($allAttributes[$dataObjectClassName])) { + return $this->_convertValue($customAttributesValueArray, $returnType); + } + $dataObjectAttributes = $allAttributes[$dataObjectClassName]; + $camelCaseAttributeCodeKey = lcfirst( + SimpleDataObjectConverter::snakeCaseToUpperCamelCase(AttributeValue::ATTRIBUTE_CODE) + ); + foreach ($customAttributesValueArray as $customAttribute) { + if (isset($customAttribute[AttributeValue::ATTRIBUTE_CODE])) { + $customAttributeCode = $customAttribute[AttributeValue::ATTRIBUTE_CODE]; + } else if (isset($customAttribute[$camelCaseAttributeCodeKey])) { + $customAttributeCode = $customAttribute[$camelCaseAttributeCodeKey]; + } else { + $customAttributeCode = null; + } + + //Check if type is defined, else default to mixed + $type = isset($dataObjectAttributes[$customAttributeCode]) + ? $dataObjectAttributes[$customAttributeCode] + : TypeProcessor::ANY_TYPE; + + $customAttributeValue = $customAttribute[AttributeValue::VALUE]; + if (is_array($customAttributeValue)) { + //If type for AttributeValue's value as array is mixed, further processing is not possible + if ($type === TypeProcessor::ANY_TYPE) { + continue; + } + //If custom attribute value is an array then its a data object type + $attributeValue = $this->_createFromArray($type, $customAttributeValue); + } else { + $attributeValue = $this->_convertValue($customAttributeValue, $type); + } + //Populate the attribute value data object once the value for custom attribute is derived based on type + $result[] = $this->attributeValueBuilder + ->setAttributeCode($customAttributeCode) + ->setValue($attributeValue) + ->create(); + } + + return $result; + } + /** * Convert data from array to Data Object representation if type is Data Object or array of Data Objects. * @@ -172,8 +248,10 @@ class ServiceArgsSerializer // Initializing the result for array type else it will return null for empty array $result = is_array($value) ? [] : null; $itemType = $this->_typeProcessor->getArrayItemType($type); - foreach ($value as $key => $item) { - $result[$key] = $this->_createFromArray($itemType, $item); + if (is_array($value)) { + foreach ($value as $key => $item) { + $result[$key] = $this->_createFromArray($itemType, $item); + } } } else { $result = $this->_createFromArray($type, $value); diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php index 523e41baa3d6bbbf473ceedc946e80b185aa607f..bbb8e1c5e0f32bad736b25780afc1fccfe507e29 100644 --- a/app/code/Magento/Webapi/Controller/Soap.php +++ b/app/code/Magento/Webapi/Controller/Soap.php @@ -45,25 +45,34 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface /**#@-*/ - /** @var \Magento\Webapi\Model\Soap\Server */ + /** + * @var \Magento\Webapi\Model\Soap\Server + */ protected $_soapServer; - /** @var \Magento\Webapi\Model\Soap\Wsdl\Generator */ + /** + * @var \Magento\Webapi\Model\Soap\Wsdl\Generator + */ protected $_wsdlGenerator; - /** @var \Magento\Webapi\Controller\Soap\Request */ + /** + * @var \Magento\Webapi\Controller\Soap\Request + */ protected $_request; - /** @var Response */ + /** + * @var Response + */ protected $_response; - /** @var ErrorProcessor */ + /** + * @var ErrorProcessor + */ protected $_errorProcessor; - /** @var \Magento\Framework\App\State */ - protected $_appState; - - /** @var \Magento\Framework\View\LayoutInterface */ + /** + * @var \Magento\Framework\View\LayoutInterface + */ protected $_layout; /** @@ -132,9 +141,6 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface $this->areaList->getArea($this->_appState->getAreaCode()) ->load(\Magento\Framework\App\Area::PART_TRANSLATE); try { - if (!$this->_appState->isInstalled()) { - throw new WebapiException(__('Magento is not yet installed')); - } if ($this->_isWsdlRequest()) { $responseBody = $this->_wsdlGenerator->generate( $this->_request->getRequestedServices(), diff --git a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php index f7fb7f1c4aca1753669bf2944f6e69254a569367..d6a84c81e967af7079c4bf6350c9da532edcbe92 100644 --- a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php +++ b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php @@ -110,6 +110,9 @@ class Handler } $isAllowed = false; + $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES] = array_values( + $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES][0] + ); foreach ($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES] as $resource) { if ($this->_authorization->isAllowed($resource)) { $isAllowed = true; @@ -121,7 +124,7 @@ class Handler // TODO: Consider passing Integration ID instead of Consumer ID throw new AuthorizationException( AuthorizationException::NOT_AUTHORIZED, - ['resources' => implode($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES], ', ')] + ['resources' => implode(', ', $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES])] ); } $service = $this->_objectManager->get($serviceClass); @@ -142,7 +145,7 @@ class Handler { /** SoapServer wraps parameters into array. Thus this wrapping should be removed to get access to parameters. */ $arguments = reset($arguments); - $arguments = $this->_dataObjectConverter->convertStdObjectToArray($arguments); + $arguments = $this->_dataObjectConverter->convertStdObjectToArray($arguments, true); return $this->_serializer->getInputData($serviceClass, $serviceMethod, $arguments); } @@ -155,13 +158,16 @@ class Handler */ protected function _prepareResponseData($data) { + $result = null; if ($data instanceof AbstractSimpleObject) { $result = $this->_dataObjectConverter->convertKeysToCamelCase($data->__toArray()); } elseif (is_array($data)) { foreach ($data as $key => $value) { - $result[$key] = $value instanceof AbstractSimpleObject - ? $this->_dataObjectConverter->convertKeysToCamelCase($value->__toArray()) - : $value; + if ($value instanceof AbstractSimpleObject) { + $result[] = $this->_dataObjectConverter->convertKeysToCamelCase($value->__toArray()); + } else { + $result[$key] = $value; + } } } elseif (is_scalar($data) || is_null($data)) { $result = $data; diff --git a/app/code/Magento/Webapi/Model/PathProcessor.php b/app/code/Magento/Webapi/Model/PathProcessor.php index fcf0a9aeae459180819e548ac150110743d18531..0586867a6d5d999cb0f90951fcf084d751864e9b 100644 --- a/app/code/Magento/Webapi/Model/PathProcessor.php +++ b/app/code/Magento/Webapi/Model/PathProcessor.php @@ -29,14 +29,14 @@ use Magento\Framework\Exception\NoSuchEntityException; class PathProcessor { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->storeManager = $storeManager; } diff --git a/app/code/Magento/Webapi/Model/Soap/Server.php b/app/code/Magento/Webapi/Model/Soap/Server.php index a12bcc43cc28c84fff3a92b8434db065621d8528..750cfef9b62f80f90c3c4fe48559ebc574c6d53e 100644 --- a/app/code/Magento/Webapi/Model/Soap/Server.php +++ b/app/code/Magento/Webapi/Model/Soap/Server.php @@ -57,7 +57,7 @@ class Server /** @var \Magento\Webapi\Controller\Soap\Request */ protected $_request; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** @var \Magento\Webapi\Model\Soap\Server\Factory */ @@ -78,7 +78,7 @@ class Server * @param \Magento\Framework\Config\ScopeInterface $configScope * @param \Magento\Webapi\Controller\Soap\Request $request * @param \Magento\Framework\DomDocument\Factory $domDocumentFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -89,7 +89,7 @@ class Server \Magento\Framework\Config\ScopeInterface $configScope, \Magento\Webapi\Controller\Soap\Request $request, \Magento\Framework\DomDocument\Factory $domDocumentFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory, \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php index 65a822617d95e8546f231a9b915728f75fc29c0a..0b68461418b9ad9cc314b0e96ffe23d89e2f61a1 100644 --- a/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php +++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php @@ -62,7 +62,7 @@ class Generator protected $_registeredTypes = array(); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -73,14 +73,14 @@ class Generator * @param Factory $wsdlFactory * @param \Magento\Webapi\Model\Cache\Type $cache * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Webapi\Model\Soap\Config $apiConfig, Factory $wsdlFactory, \Magento\Webapi\Model\Cache\Type $cache, \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_apiConfig = $apiConfig; $this->_wsdlFactory = $wsdlFactory; diff --git a/app/code/Magento/Webapi/composer.json b/app/code/Magento/Webapi/composer.json index 274878dce637beaff79570fcc0f46d324adcbcb3..ea3af99e71e6709489f1b83541fb079b7888ce37 100644 --- a/app/code/Magento/Webapi/composer.json +++ b/app/code/Magento/Webapi/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-authorization": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-integration": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-user": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-authorization": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-integration": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-user": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Webapi/etc/webapi_rest/di.xml b/app/code/Magento/Webapi/etc/webapi_rest/di.xml index 531736c376f9851287aa5310a6db3c6debd2843e..df47064738db5fa95528ebfb880587d63ac0e294 100644 --- a/app/code/Magento/Webapi/etc/webapi_rest/di.xml +++ b/app/code/Magento/Webapi/etc/webapi_rest/di.xml @@ -30,11 +30,6 @@ <argument name="request" xsi:type="object">Magento\Webapi\Controller\Rest\Request</argument> </arguments> </type> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Authorization\Model\CompositeUserContext"> <arguments> <argument name="userContexts" xsi:type="array"> diff --git a/app/code/Magento/Weee/Helper/Data.php b/app/code/Magento/Weee/Helper/Data.php index 0de6a7aa9ea523354ee3e5d606e859c69ce9f580..dc5afada3fecfae71d7f743e5a5f7a7fc471e318 100644 --- a/app/code/Magento/Weee/Helper/Data.php +++ b/app/code/Magento/Weee/Helper/Data.php @@ -61,13 +61,13 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_weeeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Weee\Model\Tax $weeeTax * @param \Magento\Weee\Model\Config $weeeConfig * @param \Magento\Tax\Helper\Data $taxData @@ -75,7 +75,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Weee\Model\Tax $weeeTax, \Magento\Weee\Model\Config $weeeConfig, \Magento\Tax\Helper\Data $taxData, diff --git a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php index 4d25426bf2d32c6cb546bcdd673c880067cb53f6..fe7afcf1f815e06cab0820827aa28fa09865afe1 100644 --- a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -33,7 +33,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price protected $_attributeTax; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -45,7 +45,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price /** * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Directory\Helper\Data $directoryHelper @@ -54,7 +54,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Directory\Helper\Data $directoryHelper, diff --git a/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php index e0cf8e9cc18191e8233ae520593ae32f5f193240..a94a900ffc0110caa91570d168eaf38fa5b25f63 100644 --- a/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php @@ -31,17 +31,17 @@ namespace Magento\Weee\Model\Resource\Attribute\Backend\Weee; class Tax extends \Magento\Framework\Model\Resource\Db\AbstractDb { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; parent::__construct($resource); diff --git a/app/code/Magento/Weee/Model/Tax.php b/app/code/Magento/Weee/Model/Tax.php index 78a5959b02be7027fbab357a64d2306f4dea7b4c..cd2f168d5e5cda7466d8fe255d91d816b39ad386 100644 --- a/app/code/Magento/Weee/Model/Tax.php +++ b/app/code/Magento/Weee/Model/Tax.php @@ -73,7 +73,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel protected $_attributeFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -103,7 +103,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Tax\Model\CalculationFactory $calculationFactory * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Tax\Helper\Data $taxData @@ -117,7 +117,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Tax\Model\CalculationFactory $calculationFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Tax\Helper\Data $taxData, diff --git a/app/code/Magento/Weee/composer.json b/app/code/Magento/Weee/composer.json index 08b213277a3e3cda29755c1bc173f583f6c95927..52b372e515ad8b8bb57f5b83b3dedd45b72725fe 100644 --- a/app/code/Magento/Weee/composer.json +++ b/app/code/Magento/Weee/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-bundle": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-bundle": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Widget/Model/Template/Filter.php b/app/code/Magento/Widget/Model/Template/Filter.php index cf69ae091fa632f0e18d66383d3161e3ab83d3dc..000df5615db4aafa0999a5e0d84fb77c394d5e05 100644 --- a/app/code/Magento/Widget/Model/Template/Filter.php +++ b/app/code/Magento/Widget/Model/Template/Filter.php @@ -45,7 +45,7 @@ class Filter extends \Magento\Cms\Model\Template\Filter * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Core\Model\VariableFactory $coreVariableFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\View\LayoutFactory $layoutFactory * @param \Magento\Framework\App\State $appState @@ -60,7 +60,7 @@ class Filter extends \Magento\Cms\Model\Template\Filter \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Core\Model\VariableFactory $coreVariableFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Framework\App\State $appState, diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index af2ee26b9915040e59d27382d2fc331d303767f1..786d83ac56949096bd0a062e9a69288a8ef995f6 100644 --- a/app/code/Magento/Widget/composer.json +++ b/app/code/Magento/Widget/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Wishlist/Controller/Index/Send.php b/app/code/Magento/Wishlist/Controller/Index/Send.php index 196242e3f4c803316c234a668e51dd4f332046d8..591cae51aa3cbf18777b38648ff174f76a9d5c7e 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Send.php +++ b/app/code/Magento/Wishlist/Controller/Index/Send.php @@ -177,7 +177,7 @@ class Send extends Action\Action implements IndexInterface try { $scopeConfig = $this->_objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface'); - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); foreach ($emails as $email) { $transport = $this->_transportBuilder->setTemplateIdentifier( $scopeConfig->getValue( diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index 9e3b36d7ac771ff1a055b7f223fb7da46dd008d9..796882bfbb0e0f838e61b51fbbc49ccbdbbc59a8 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -102,7 +102,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_wishlistFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -128,7 +128,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\PostData $postDataHelper * @param \Magento\Customer\Helper\View $customerViewHelper * @param WishlistProviderInterface $wishlistProvider @@ -140,7 +140,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Model\Session $customerSession, \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\PostData $postDataHelper, \Magento\Customer\Helper\View $customerViewHelper, WishlistProviderInterface $wishlistProvider diff --git a/app/code/Magento/Wishlist/Helper/Rss.php b/app/code/Magento/Wishlist/Helper/Rss.php index 5ebeb5e9bae2222c5e32062ec84d2bb511f69a08..28a18f60e8633df494794da144a58cd25d3620d3 100644 --- a/app/code/Magento/Wishlist/Helper/Rss.php +++ b/app/code/Magento/Wishlist/Helper/Rss.php @@ -43,7 +43,7 @@ class Rss extends \Magento\Wishlist\Helper\Data * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\PostData $postDataHelper * @param \Magento\Customer\Helper\View $customerViewHelper * @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider @@ -56,7 +56,7 @@ class Rss extends \Magento\Wishlist\Helper\Data \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Model\Session $customerSession, \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\PostData $postDataHelper, \Magento\Customer\Helper\View $customerViewHelper, \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider, diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php index e10f40ee9ed837f8978bc3980f26e55a3a368fa8..070ca460a745ab7e18b013f434abc579eb7b78f4 100644 --- a/app/code/Magento/Wishlist/Model/Item.php +++ b/app/code/Magento/Wishlist/Model/Item.php @@ -101,7 +101,7 @@ class Item extends AbstractModel implements ItemInterface protected $_flagOptionsSaved = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -138,7 +138,7 @@ class Item extends AbstractModel implements ItemInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl @@ -152,7 +152,7 @@ class Item extends AbstractModel implements ItemInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, diff --git a/app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php b/app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php index 69d35a90fb003279f804e3691be06606f7252d63..3f7663f3b9887f6cc28419f891aacd91ea7eddcc 100644 --- a/app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php +++ b/app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php @@ -32,17 +32,20 @@ class LocaleQuantityProcessor protected $localeResolver; /** - * @var \Zend_Filter_LocalizedToNormalized + * @var \Magento\Framework\Filter\LocalizedToNormalized */ protected $localFilter; /** * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Framework\Filter\LocalizedToNormalized $localFilter */ public function __construct( - \Magento\Framework\Locale\ResolverInterface $localeResolver + \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Framework\Filter\LocalizedToNormalized $localFilter ) { $this->localeResolver = $localeResolver; + $this->localFilter = $localFilter; } /** @@ -53,11 +56,7 @@ class LocaleQuantityProcessor */ public function process($qty) { - if (!$this->localFilter) { - $this->localFilter = new \Zend_Filter_LocalizedToNormalized( - array('locale' => $this->localeResolver->getLocaleCode()) - ); - } + $this->localFilter->setOptions(array('locale' => $this->localeResolver->getLocaleCode())); $qty = $this->localFilter->filter((double)$qty); if ($qty < 0) { $qty = null; diff --git a/app/code/Magento/Wishlist/Model/Observer.php b/app/code/Magento/Wishlist/Model/Observer.php index 28371051459f557345de0658fa22c93f4485d0a7..8c07bb5488a99205e2f93236db19d80c63431d9e 100644 --- a/app/code/Magento/Wishlist/Model/Observer.php +++ b/app/code/Magento/Wishlist/Model/Observer.php @@ -29,7 +29,7 @@ */ namespace Magento\Wishlist\Model; -class Observer extends \Magento\Framework\Model\AbstractModel +class Observer { /** * Wishlist data @@ -59,35 +59,24 @@ class Observer extends \Magento\Framework\Model\AbstractModel protected $messageManager; /** - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry * @param \Magento\Wishlist\Helper\Data $wishlistData * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession * @param WishlistFactory $wishlistFactory * @param \Magento\Framework\Message\ManagerInterface $messageManager - * @param \Magento\Framework\Model\Resource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\Db $resourceCollection - * @param array $data */ public function __construct( - \Magento\Framework\Model\Context $context, - \Magento\Framework\Registry $registry, \Magento\Wishlist\Helper\Data $wishlistData, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, WishlistFactory $wishlistFactory, - \Magento\Framework\Message\ManagerInterface $messageManager, - \Magento\Framework\Model\Resource\AbstractResource $resource = null, - \Magento\Framework\Data\Collection\Db $resourceCollection = null, - array $data = array() + \Magento\Framework\Message\ManagerInterface $messageManager ) { $this->_wishlistData = $wishlistData; $this->_checkoutSession = $checkoutSession; $this->_customerSession = $customerSession; $this->_wishlistFactory = $wishlistFactory; $this->messageManager = $messageManager; - parent::__construct($context, $registry, $resource, $resourceCollection, $data); } /** @@ -177,9 +166,8 @@ class Observer extends \Magento\Framework\Model\AbstractModel return; } - $wishlist->getItemCollection()->load(); - - foreach ($wishlist->getItemCollection() as $wishlistItem) { + $wishlists = $wishlist->getItemCollection()->load(); + foreach ($wishlists as $wishlistItem) { if ($wishlistItem->getId() == $wishlistId) { $wishlistItem->delete(); } diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php index 64f2f263c29791f53ab659d24900e5bdca18c9c6..3b4ef483802c322c39f4c0c99f2024072f9ad29e 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php @@ -99,7 +99,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac protected $_inventoryData = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -155,7 +155,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Sales\Helper\Admin $adminhtmlSales - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Wishlist\Model\Config $wishlistConfig * @param \Magento\Catalog\Model\Product\Visibility $productVisibility @@ -177,7 +177,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Sales\Helper\Admin $adminhtmlSales, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Wishlist\Model\Config $wishlistConfig, \Magento\Catalog\Model\Product\Visibility $productVisibility, diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php index 13575824043f9dd3789d1a6493433310d491ad96..d3a8e1bf5616c2a433cd1a113ab1019f20451280 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php @@ -43,7 +43,7 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Sales\Helper\Admin $adminhtmlSales - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Wishlist\Model\Config $wishlistConfig * @param \Magento\Catalog\Model\Product\Visibility $productVisibility @@ -66,7 +66,7 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Sales\Helper\Admin $adminhtmlSales, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Wishlist\Model\Config $wishlistConfig, \Magento\Catalog\Model\Product\Visibility $productVisibility, diff --git a/app/code/Magento/Wishlist/Model/Wishlist.php b/app/code/Magento/Wishlist/Model/Wishlist.php index f1bf6dd3ebea998af5fe2732b190b7426c52da34..fbd951686610aae300d843aeff5f46474c12655a 100644 --- a/app/code/Magento/Wishlist/Model/Wishlist.php +++ b/app/code/Magento/Wishlist/Model/Wishlist.php @@ -90,7 +90,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent protected $_catalogProduct; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -136,7 +136,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent * @param \Magento\Wishlist\Helper\Data $wishlistData * @param ResourceWishlist $resource * @param Collection $resourceCollection - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param ItemFactory $wishlistItemFactory * @param CollectionFactory $wishlistCollectionFactory @@ -153,7 +153,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent \Magento\Wishlist\Helper\Data $wishlistData, ResourceWishlist $resource, Collection $resourceCollection, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, ItemFactory $wishlistItemFactory, CollectionFactory $wishlistCollectionFactory, @@ -185,6 +185,9 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent */ public function loadByCustomerId($customerId, $create = false) { + if (is_null($customerId)) { + return $this; + } $customerId = (int)$customerId; $customerIdFieldName = $this->_getResource()->getCustomerIdFieldName(); $this->_getResource()->load($this, $customerId, $customerIdFieldName); @@ -297,21 +300,14 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent if ($item === null) { $storeId = $product->hasWishlistStoreId() ? $product->getWishlistStoreId() : $this->getStore()->getId(); $item = $this->_wishlistItemFactory->create(); - $item->setProductId( - $product->getId() - )->setWishlistId( - $this->getId() - )->setAddedAt( - $this->dateTime->now() - )->setStoreId( - $storeId - )->setOptions( - $product->getCustomOptions() - )->setProduct( - $product - )->setQty( - $qty - )->save(); + $item->setProductId($product->getId()); + $item->setWishlistId($this->getId()); + $item->setAddedAt($this->dateTime->now()); + $item->setStoreId($storeId); + $item->setOptions($product->getCustomOptions()); + $item->setProduct($product); + $item->setQty($qty); + $item->save(); if ($item->getId()) { $this->getItemCollection()->addItem($item); } @@ -403,7 +399,9 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent } /* @var $product \Magento\Catalog\Model\Product */ - $product = $this->_productFactory->create()->setStoreId($storeId)->load($productId); + $product = $this->_productFactory->create(); + $product->setStoreId($storeId); + $product->load($productId); if ($buyRequest instanceof \Magento\Framework\Object) { $_buyRequest = $buyRequest; @@ -649,7 +647,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent * Error message */ if (is_string($resultItem)) { - throw new \Magento\Framework\Model\Exception(__($resultItem)); + throw new Exception(__($resultItem)); } if ($resultItem->getId() != $itemId) { @@ -663,7 +661,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent $resultItem->setOrigData('qty', 0); } } else { - throw new \Magento\Framework\Model\Exception(__('The product does not exist.')); + throw new Exception(__('The product does not exist.')); } return $this; } diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index 7956e7620cb98b96c6bd5b9e83369cd123e7248e..cbad874b331c3da1dff7bdc0e509e7858b37fec6 100644 --- a/app/code/Magento/Wishlist/composer.json +++ b/app/code/Magento/Wishlist/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-rss": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-bundle": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-grouped-product": "0.1.0-alpha94", - "magento/module-configurable-product": "0.1.0-alpha94", - "magento/module-downloadable": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-rss": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-bundle": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-grouped-product": "0.1.0-alpha95", + "magento/module-configurable-product": "0.1.0-alpha95", + "magento/module-downloadable": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Wishlist/etc/adminhtml/di.xml b/app/code/Magento/Wishlist/etc/adminhtml/di.xml index acb985b627d5da450c0c12e20abcffd65f187b95..44c0a0ce75abba5ce0aeea669f1f050ee7724fea 100644 --- a/app/code/Magento/Wishlist/etc/adminhtml/di.xml +++ b/app/code/Magento/Wishlist/etc/adminhtml/di.xml @@ -37,7 +37,6 @@ <virtualType name="Magento\Wishlist\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Wishlist\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> </config> diff --git a/app/code/Magento/Wishlist/etc/frontend/di.xml b/app/code/Magento/Wishlist/etc/frontend/di.xml index 1bd1fde51a6d0a0744c5d3114a6bf14ddd95b10a..35681b33c802397e297c6164bf446271ec7922dd 100644 --- a/app/code/Magento/Wishlist/etc/frontend/di.xml +++ b/app/code/Magento/Wishlist/etc/frontend/di.xml @@ -32,14 +32,8 @@ <virtualType name="Magento\Wishlist\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Wishlist\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index 1034885d4a5113eaa1335fe06dc47fdf3c32c246..711429eb7ef3b609d34d5ace36d1a498d973675d 100644 --- a/app/design/adminhtml/Magento/backend/composer.json +++ b/app/design/adminhtml/Magento/backend/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/design/adminhtml/Magento/backend/theme.xml b/app/design/adminhtml/Magento/backend/theme.xml index a3ebe78fb615a4b83025a7540a447f603abfd7d8..6b53d84f0ecb1d5a8b127023edd32f0c198ae975 100644 --- a/app/design/adminhtml/Magento/backend/theme.xml +++ b/app/design/adminhtml/Magento/backend/theme.xml @@ -24,5 +24,5 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento 2 backend</title> - <version>0.1.0-alpha94</version> + <version>0.1.0-alpha95</version> </theme> diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index 34c8a20d0f3e2141cb2870bc480f78964749feaa..32dc1d66d139dd251022295f23c7f35094ecf7fd 100644 --- a/app/design/frontend/Magento/blank/composer.json +++ b/app/design/frontend/Magento/blank/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/blank/theme.xml b/app/design/frontend/Magento/blank/theme.xml index 1b6d152a2cbf88be910c9be1eee9c97005f73dd6..bce93110a1a69c67b7ce4153ef0b9ba433a1e2db 100644 --- a/app/design/frontend/Magento/blank/theme.xml +++ b/app/design/frontend/Magento/blank/theme.xml @@ -24,7 +24,7 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Blank</title> - <version>0.1.0-alpha94</version> + <version>0.1.0-alpha95</version> <media> <preview_image>media/preview.jpg</preview_image> </media> diff --git a/app/design/frontend/Magento/plushe/composer.json b/app/design/frontend/Magento/plushe/composer.json index 2e0afdc7d2ad61e63a5cd30de03ae4d08e5061ad..ae10f5ca67eb765d22c503124fd3fbde575886ad 100644 --- a/app/design/frontend/Magento/plushe/composer.json +++ b/app/design/frontend/Magento/plushe/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/theme-frontend-blank": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/theme-frontend-blank": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/plushe/theme.xml b/app/design/frontend/Magento/plushe/theme.xml index e260fdaa45ba96db30fcbc474e5e6e0ed8ea051d..b88603c9db483061be0779f68fe60fc644c8fe1e 100644 --- a/app/design/frontend/Magento/plushe/theme.xml +++ b/app/design/frontend/Magento/plushe/theme.xml @@ -24,7 +24,7 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Plushe</title> - <version>0.1.0-alpha94</version> + <version>0.1.0-alpha95</version> <parent>Magento/blank</parent> <media> <preview_image>media/preview.jpg</preview_image> diff --git a/app/design/install/Magento/basic/theme.xml b/app/design/install/Magento/basic/theme.xml index d799aa2be575413ab778b274de238a0833a4efcd..abefe60889376b1dcc381d2ad32a12713ab88f58 100644 --- a/app/design/install/Magento/basic/theme.xml +++ b/app/design/install/Magento/basic/theme.xml @@ -24,5 +24,5 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Basic</title> - <version>0.1.0-alpha94</version> + <version>0.1.0-alpha95</version> </theme> diff --git a/app/etc/di.xml b/app/etc/di.xml index 1d4db9faf2beed48adb1d78ddaaa54091033801c..1ad347d47eb5c880df3af932c385da5bb0a9ee1f 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -29,11 +29,10 @@ <preference for="Magento\Framework\App\ResponseInterface" type="Magento\Framework\App\Response\Http" /> <preference for="Magento\Framework\App\RouterListInterface" type="Magento\Framework\App\RouterList" /> <preference for="Magento\Framework\App\FrontControllerInterface" type="Magento\Framework\App\FrontController" /> - <preference for="Magento\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\Updater" /> <preference for="Magento\Framework\App\CacheInterface" type="Magento\Framework\App\Cache\Proxy" /> <preference for="Magento\Framework\App\Cache\StateInterface" type="Magento\Framework\App\Cache\State" /> <preference for="Magento\Framework\App\Cache\TypeListInterface" type="Magento\Framework\App\Cache\TypeList" /> - <preference for="Magento\Store\Model\StoreManagerInterface" type="Magento\Store\Model\StoreManager" /> + <preference for="Magento\Framework\StoreManagerInterface" type="Magento\Store\Model\StoreManager" /> <preference for="Magento\Framework\View\DesignInterface" type="Magento\Core\Model\View\Design\Proxy" /> <preference for="Magento\Framework\View\Design\ThemeInterface" type="Magento\Core\Model\Theme" /> <preference for="Magento\Framework\View\Design\Theme\ResolverInterface" type="Magento\Core\Model\Theme\Resolver" /> @@ -79,6 +78,7 @@ <preference for="Magento\Framework\View\Design\Theme\Image\PathInterface" type="Magento\Core\Model\Theme\Image\Path" /> <preference for="Magento\Framework\Session\Config\ConfigInterface" type="Magento\Framework\Session\Config" /> <preference for="Magento\Framework\Session\SidResolverInterface" type="Magento\Framework\Session\SidResolver\Proxy" /> + <preference for="Magento\Framework\Stdlib\Cookie\CookieScopeInterface" type="\Magento\Framework\Stdlib\Cookie\CookieScope" /> <preference for="Magento\Framework\Stdlib\CookieManager" type="Magento\Framework\Stdlib\Cookie\PhpCookieManager" /> <preference for="Magento\Framework\TranslateInterface" type="Magento\Framework\Translate" /> <preference for="Magento\Framework\Config\ScopeListInterface" type="interceptionConfigScope" /> @@ -111,7 +111,6 @@ <argument name="pathInfoProcessor" xsi:type="object">Magento\Store\App\Request\PathInfoProcessor\Proxy</argument> </arguments> </type> - <preference for="Magento\Framework\Error\HandlerInterface" type="Magento\Framework\App\Error\Handler" /> <preference for="Magento\Framework\Session\SaveHandlerInterface" type="Magento\Framework\Session\SaveHandler" /> <type name="Magento\Framework\Session\SaveHandler"> <arguments> @@ -136,7 +135,7 @@ <argument name="mode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument> </arguments> </type> - <type name="Magento\Framework\Module\FrontController\Plugin\Install"> + <type name="Magento\Framework\Module\Plugin\DbStatusValidator"> <arguments> <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> </arguments> diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index d31dca76915aa68abf0b740863194d99ea1fe2a1..d9943b55b49fc9df2a58302634e11634278d3e15 100644 --- a/app/i18n/magento/de_de/composer.json +++ b/app/i18n/magento/de_de/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-de_de", "description": "German (Germany) language", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/en_us/composer.json b/app/i18n/magento/en_us/composer.json index e98a83a5544629b449d01ed66d592205a2db1a3e..02f6f7dbd8f1c603c16054d191212987694c48f4 100644 --- a/app/i18n/magento/en_us/composer.json +++ b/app/i18n/magento/en_us/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-en_us", "description": "English (United States) language", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/es_es/composer.json b/app/i18n/magento/es_es/composer.json index dea863bf3299aabcb66ebe438f1e48961e0ac6ca..d1b456a5710018d8c90700a41e8395090b51d7f9 100644 --- a/app/i18n/magento/es_es/composer.json +++ b/app/i18n/magento/es_es/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-es_es", "description": "Spanish (Spain) language", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/fr_fr/composer.json b/app/i18n/magento/fr_fr/composer.json index ffbb844d2b245661a42badbe1f389d75eaa24194..481e9f18dc1d6b65e47aa9fbe6e6b2fbfd6fcf12 100644 --- a/app/i18n/magento/fr_fr/composer.json +++ b/app/i18n/magento/fr_fr/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-fr_fr", "description": "French (France) language", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/nl_nl/composer.json b/app/i18n/magento/nl_nl/composer.json index 87ca743f70e7d6100bb780ddd2696f757843b0c1..d11fccd5ddda7378d14ca97d9986f3683b78bd5e 100644 --- a/app/i18n/magento/nl_nl/composer.json +++ b/app/i18n/magento/nl_nl/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-nl_nl", "description": "Dutch (Netherlands) language", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/pt_br/composer.json b/app/i18n/magento/pt_br/composer.json index f1e384782607fc5ff1a6fdc8398f7a686f210f38..9d356d9c58965e43bde93fffce713fbe265e397f 100644 --- a/app/i18n/magento/pt_br/composer.json +++ b/app/i18n/magento/pt_br/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-pt_br", "description": "Portuguese (Brazil) language", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/zh_cn/composer.json b/app/i18n/magento/zh_cn/composer.json index 4ae023afd5a34f06eee93770b009a299bf4deb9c..a7b59b219c7fa288091e4c855791ac58e1003f80 100644 --- a/app/i18n/magento/zh_cn/composer.json +++ b/app/i18n/magento/zh_cn/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-zh_cn", "description": "Chinese (China) language", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index 21615dc9e92c5aa37ee74b5b9d0cfd8ce7ca4733..c96c089d47cd44318e1d057599245bb0388d6ab2 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/project-community-edition", "description": "Magento project (Community Edition)", "type": "project", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { "php": "~5.4.11|~5.5.0" }, @@ -81,6 +81,7 @@ "magento/module-sitemap": "self.version", "magento/module-store": "self.version", "magento/module-tax": "self.version", + "magento/module-tax-import-export": "self.version", "magento/module-theme": "self.version", "magento/module-translation": "self.version", "magento/module-ups": "self.version", @@ -103,6 +104,7 @@ "magento/language-pt_br": "self.version", "magento/language-zh_cn": "self.version", "magento/framework": "self.version", + "magento/project-setup": "0.1.0", "zendframework/zend-eventmanager": "2.0.3", "zendframework/zend-stdlib": "2.0.3", "zendframework/zend-di": "2.0.3", diff --git a/dev/shell/indexer.php b/dev/shell/indexer.php index 54460cff8c137aee1cc41ce26835b835b925e2b3..41703be84e9fcff26f2fe57a862237ab081b426b 100644 --- a/dev/shell/indexer.php +++ b/dev/shell/indexer.php @@ -22,13 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Framework\App\Bootstrap; use Magento\Store\Model\StoreManager; -$params = array( - StoreManager::PARAM_RUN_CODE => 'admin', - StoreManager::PARAM_RUN_TYPE => 'store' -); - -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Index\App\Shell', array('entryFileName' => basename(__FILE__))); +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +$params[StoreManager::PARAM_RUN_CODE] = 'admin'; +$params[StoreManager::PARAM_RUN_TYPE] = 'store'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Index\App\Shell $application */ +$app = $bootstrap->createApplication('Magento\Index\App\Shell', ['entryFileName' => basename(__FILE__)]); +$bootstrap->run($app); diff --git a/dev/shell/install.php b/dev/shell/install.php index cb8406e18e2b6486f5147650a5c0e64cdd50ea99..02783cc5d09fc255f945a835c443cd61c3beaa39 100644 --- a/dev/shell/install.php +++ b/dev/shell/install.php @@ -22,6 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +use Magento\Framework\App\State as AppState; +use Magento\Framework\App\Bootstrap; + /** * Parse command line arguments */ @@ -48,13 +51,7 @@ if (empty($args)) { foreach ($detailedOptions as $option) { echo ' php -f ' . $_SERVER['argv'][0] . ' -- --' . $option . PHP_EOL; } - echo <<<INSTALLSCHEME -Installation scheme: - php -f {$_SERVER['argv'][0]} -- [--<install_option_name> "<option_value>" ...] -Uninstallation: - php -f {$_SERVER['argv'][0]} -- --uninstall - -INSTALLSCHEME; + echo "php -f {$_SERVER['argv'][0]} -- [--<install_option_name> \"<option_value>\" ...]\n"; $exampleOptions = array( 'license_agreement_accepted' => 'yes', @@ -74,7 +71,8 @@ INSTALLSCHEME; 'admin_password' => '1234qasd', 'use_secure' => 'no', 'secure_base_url' => '"https://magento.local"', - 'cleanup_database' => '' + 'cleanup_database' => '', + 'bootstrap' => '{"extra":{"key":"value"}}', ); echo 'Example of installation:' . PHP_EOL; echo ' php -f ' . $_SERVER['argv'][0] . ' --'; @@ -89,12 +87,21 @@ INSTALLSCHEME; exit(1); } -define('BARE_BOOTSTRAP', 1); -require_once __DIR__ . '/../../app/bootstrap.php'; - -$_SERVER[\Magento\Framework\App\State::PARAM_MODE] = isset($_SERVER[\Magento\Framework\App\State::PARAM_MODE]) - ? $_SERVER[\Magento\Framework\App\State::PARAM_MODE] - : \Magento\Framework\App\State::MODE_DEVELOPER; +require __DIR__ . '/../../app/bootstrap.php'; -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $_SERVER); -$entryPoint->run('Magento\Install\App\Console', array('arguments' => $args)); +$params = $_SERVER; +$params[Bootstrap::PARAM_REQUIRE_IS_INSTALLED] = false; +if (!isset($params[AppState::PARAM_MODE])) { + $params[AppState::PARAM_MODE] = AppState::MODE_DEVELOPER; +} +if (isset($args['bootstrap'])) { + $extra = json_decode($args['bootstrap'], true); + if (!is_array($extra)) { + throw new \Exception("Unable to decode JSON in the parameter 'bootstrap'"); + } + $params = array_replace_recursive($params, $extra); +} +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Install\App\Console $app */ +$app = $bootstrap->createApplication('Magento\Install\App\Console', ['arguments' => $args]); +$bootstrap->run($app); diff --git a/dev/shell/log.php b/dev/shell/log.php index da6fb049b279eb4c37a6558c7c64a0b566bebca9..4642107aa829e1c884bf858de33d3d3ea5a7a97c 100644 --- a/dev/shell/log.php +++ b/dev/shell/log.php @@ -22,13 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Framework\App\Bootstrap; use Magento\Store\Model\StoreManager; -$params = array( - StoreManager::PARAM_RUN_CODE => 'admin', - StoreManager::PARAM_RUN_TYPE => 'store' -); - -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Log\App\Shell', array('entryFileName' => basename(__FILE__))); +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +$params[StoreManager::PARAM_RUN_CODE] = 'admin'; +$params[StoreManager::PARAM_RUN_TYPE] = 'store'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Log\App\Shell $app */ +$app = $bootstrap->createApplication('Magento\Log\App\Shell', ['entryFileName' => basename(__FILE__)]); +$bootstrap->run($app); diff --git a/dev/shell/maintenance.php b/dev/shell/maintenance.php new file mode 100644 index 0000000000000000000000000000000000000000..ce0c850cc8e7720ca172c710ffd699c84df18416 --- /dev/null +++ b/dev/shell/maintenance.php @@ -0,0 +1,77 @@ +<?php +/** + * Maintenance mode tool + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +define( + 'USAGE', + "Usage: php -f maintenance.php -- [--set=1|0] [--addresses=127.0.0.1,...|none'] [--bootstrap=<json>] + --set - enable or disable maintenance mode + --addresses - list of allowed IP addresses, comma-separated + --bootstrap - add or override parameters of the bootstrap\n" +); +$opt = getopt('', ['set::', 'addresses::', 'bootstrap::']); +if (empty($opt)) { + echo USAGE; +} + +require __DIR__ . '/../../app/bootstrap.php'; +try { + $params = $_SERVER; + if (isset($opt['bootstrap'])) { + $extra = json_decode($opt['bootstrap'], true); + if (!is_array($extra)) { + throw new \Exception("Unable to decode JSON in the parameter 'bootstrap'"); + } + $params = array_replace_recursive($params, $extra); + } + $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); + /** @var \Magento\Framework\App\MaintenanceMode $maintenance */ + $maintenance = $bootstrap->getObjectManager()->get('Magento\Framework\App\MaintenanceMode'); + if (isset($opt['set'])) { + if (1 === (int)$opt['set']) { + echo "Enabling maintenance mode...\n"; + $maintenance->set(true); + } else { + echo "Disabling maintenance mode...\n"; + $maintenance->set(false); + } + } + if (isset($opt['addresses'])) { + $addresses = ('none' == $opt['addresses']) ? '' : $opt['addresses']; + $maintenance->setAddresses($addresses); + } + echo 'Status: maintenance mode is ' . ($maintenance->isOn() ? 'active' : 'not active') . ".\n"; + $addresses = implode(', ', $maintenance->getAddressInfo()); + echo "List of exempt IP-addresses:"; + if ($addresses) { + echo " {$addresses}\n"; + } else { + echo " none.\n"; + } + exit(0); +} catch (Exception $e) { + echo $e; + exit(1); +} diff --git a/dev/shell/newindexer.php b/dev/shell/newindexer.php index 6b3f3887b2f7721897dc81fd5ad7c915d820b091..d3e76fa709721a85fc7a00447d2ad740a633660d 100644 --- a/dev/shell/newindexer.php +++ b/dev/shell/newindexer.php @@ -22,13 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Framework\App\Bootstrap; use Magento\Store\Model\StoreManager; -$params = array( - StoreManager::PARAM_RUN_CODE => 'admin', - StoreManager::PARAM_RUN_TYPE => 'store' -); - -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Indexer\App\Shell', array('entryFileName' => basename(__FILE__))); +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +$params[StoreManager::PARAM_RUN_CODE] = 'admin'; +$params[StoreManager::PARAM_RUN_TYPE] = 'store'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var Magento\Indexer\App\Shell $app */ +$app = $bootstrap->createApplication('Magento\Indexer\App\Shell', ['entryFileName' => basename(__FILE__)]); +$bootstrap->run($app); diff --git a/dev/shell/run_data_fixtures.php b/dev/shell/run_data_fixtures.php new file mode 100644 index 0000000000000000000000000000000000000000..51001b2fa16d4c1230fe824db92ff6b7c3ab3715 --- /dev/null +++ b/dev/shell/run_data_fixtures.php @@ -0,0 +1,36 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +use Magento\Framework\App\Bootstrap; +use Magento\Framework\App\State as AppState; + +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +if (!isset($params[AppState::PARAM_MODE])) { + $extra[AppState::PARAM_MODE] = AppState::MODE_DEVELOPER; +} +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Framework\Module\Updater $updater */ +$updater = $bootstrap->getObjectManager()->create('\Magento\Framework\Module\Updater'); +$updater->updateData(); diff --git a/dev/shell/run_schema_updater.php b/dev/shell/run_schema_updater.php new file mode 100644 index 0000000000000000000000000000000000000000..9a329a4105f889be7dd6b8e16552e6407e3f58fe --- /dev/null +++ b/dev/shell/run_schema_updater.php @@ -0,0 +1,36 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +use Magento\Framework\App\State as AppState; + +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +$extra = []; +if (!isset($params[AppState::PARAM_MODE])) { + $extra[AppState::PARAM_MODE] = AppState::MODE_DEVELOPER; +} +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Framework\Module\Updater $updater */ +$updater = $bootstrap->getObjectManager()->create('\Magento\Framework\Module\Updater'); +$updater->updateScheme(); diff --git a/dev/shell/uninstall.php b/dev/shell/uninstall.php new file mode 100644 index 0000000000000000000000000000000000000000..1d7538276ac408e626596bf8303d2e7e22228120 --- /dev/null +++ b/dev/shell/uninstall.php @@ -0,0 +1,49 @@ +<?php +/** + * Uninstall utility + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +define('USAGE', "Usage: php -f uninstall.php -- [--bootstrap=<json>]\n"); +$opt = getopt('', ['bootstrap::']); + +require __DIR__ . '/../../app/bootstrap.php'; +try { + $params = $_SERVER; + if (isset($opt['bootstrap'])) { + $extra = json_decode($opt['bootstrap'], true); + if (!is_array($extra)) { + throw new \Exception("Unable to decode JSON in the parameter 'bootstrap'"); + } + $params = array_replace_recursive($params, $extra); + } + $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); + $log = new \Zend_Log(new \Zend_Log_Writer_Stream('php://stdout')); + /** @var \Magento\Install\Model\Uninstaller $uninstall */ + $uninstall = $bootstrap->getObjectManager()->create('\Magento\Install\Model\Uninstaller', ['log' => $log]); + $uninstall->uninstall(); + exit(0); +} catch (\Exception $e) { + echo $e; + exit(1); +} diff --git a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectElement.php b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectElement.php deleted file mode 100644 index 618124ef1d80f981e9875b9e5c7cb0b1916bf450..0000000000000000000000000000000000000000 --- a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectElement.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Mtf\Client\Driver\Selenium\Element; - -use Mtf\Client\Driver\Selenium\Element; -use Mtf\Client\Element\Locator; - -/** - * Class LiselectElement - * Typified element class for lists selectors - * - */ -class LiselectElement extends Element -{ - /** - * Template for each element of option - * - * @var string - */ - protected $optionMaskElement = 'li[*[contains(text(), "%s")]]'; - - /** - * Additional part for each child element of option - * - * @var string - */ - protected $optionMaskFollowing = '/following-sibling::'; - - /** - * Select value in liselect dropdown - * - * @param array $value - * @throws \Exception - */ - public function setValue($value) - { - $this->_context->find('.toggle', Locator::SELECTOR_CSS)->click(); - - $optionSelector = array(); - foreach ($value as $key => $option) { - $optionSelector[] = sprintf($this->optionMaskElement, $value[$key]); - } - $optionSelector = './/' . implode($this->optionMaskFollowing, $optionSelector) . '/a'; - - $option = $this->_context->find($optionSelector, Locator::SELECTOR_XPATH); - if (!$option->isVisible()) { - throw new \Exception('[' . implode('/', $value) . '] option is not visible in store switcher.'); - } - $option->click(); - } -} diff --git a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectstoreElement.php b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectstoreElement.php new file mode 100644 index 0000000000000000000000000000000000000000..890f157acb8bc46fa9cf5e916545e173cd612af2 --- /dev/null +++ b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectstoreElement.php @@ -0,0 +1,200 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Mtf\Client\Driver\Selenium\Element; + +use Mtf\Client\Driver\Selenium\Element; +use Mtf\Client\Element\Locator; + +/** + * Class LiselectstoreElement + * Typified element class for lists selectors + */ +class LiselectstoreElement extends Element +{ + /** + * Template for each element of option + * + * @var string + */ + protected $optionMaskElement = 'li[*[contains(text(), "%s")]]'; + + /** + * Additional part for each child element of option + * + * @var string + */ + protected $optionMaskFollowing = '/following-sibling::'; + + /** + * Website selector + * + * @var string + */ + protected $websiteSelector = '(.//li[a[@data-role="website-id"]])[%d]'; + + /** + * Store selector + * + * @var string + */ + protected $storeSelector = '(.//li[@class = "store-switcher-store disabled"])[%d]'; + + /** + * StoreView selector + * + * @var string + */ + protected $storeViewSelector = './/li[a[@data-role="store-view-id"]]'; + + /** + * Toggle element selector + * + * @var string + */ + protected $toggleSelector = '.toggle'; + + /** + * Select value in liselect dropdown + * + * @param string $value + * @throws \Exception + */ + public function setValue($value) + { + $this->_eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]); + $this->_context->find($this->toggleSelector)->click(); + + $value = explode('/', $value); + $optionSelector = []; + foreach ($value as $key => $option) { + $optionSelector[] = sprintf($this->optionMaskElement, $value[$key]); + } + $optionSelector = './/' . implode($this->optionMaskFollowing, $optionSelector) . '/a'; + + $option = $this->_context->find($optionSelector, Locator::SELECTOR_XPATH); + if (!$option->isVisible()) { + throw new \Exception('[' . implode('/', $value) . '] option is not visible in store switcher.'); + } + $option->click(); + } + + /** + * Get all li elements from dropdown + * + * @return array + */ + protected function getLiElements() + { + $this->_context->find($this->toggleSelector)->click(); + $criteria = new \PHPUnit_Extensions_Selenium2TestCase_ElementCriteria('css selector'); + $criteria->value('li'); + $elements = $this->_getWrappedElement()->elements($criteria); + $dropdownData = []; + foreach ($elements as $element) { + $class = $element->attribute('class'); + $dropdownData[] = [ + 'element' => $element, + 'storeView' => $this->isSubstring($class, "store-switcher-store-view"), + 'store' => $this->isSubstring($class, "store-switcher-store "), + 'website' => $this->isSubstring($class, "store-switcher-website"), + 'current' => $this->isSubstring($class, "current"), + 'default_config' => $this->isSubstring($class, "store-switcher-all"), + ]; + } + return $dropdownData; + } + + /** + * Get all available store views + * + * @return array + */ + public function getValues() + { + $dropdownData = $this->getLiElements(); + $data = []; + foreach ($dropdownData as $key => $dropdownElement) { + if ($dropdownElement['storeView']) { + $data[] = $this->findNearestElement('website', $key, $dropdownData) . "/" + . $this->findNearestElement('store', $key, $dropdownData) . "/" + . $dropdownElement['element']->text(); + } + } + return $data; + } + + /** + * Check if string contains substring + * + * @param string $haystack + * @param string $pattern + * @return bool + */ + protected function isSubstring($haystack, $pattern) + { + return preg_match("/$pattern/", $haystack) != 0 ? true : false; + } + + /** + * Return nearest elements name according to criteria + * + * @param string $criteria + * @param string $key + * @param array $elements + * @return bool + */ + protected function findNearestElement($criteria, $key, array $elements) + { + $elementText = false; + while ($elementText == false) { + $elementText = $elements[$key][$criteria] == true ? $elements[$key]['element']->text() : false; + $key--; + } + return $elementText; + } + + /** + * Get selected store value + * + * @throws \Exception + * @return string + */ + public function getValue() + { + $this->_eventManager->dispatchEvent(['get_value'], [(string)$this->_locator]); + $elements = $this->getLiElements(); + foreach ($elements as $key => $element) { + if ($element['current'] == true) { + if ($element['default_config'] == true) { + return $element['element']->text(); + } + $path = $this->findNearestElement('website', $key, $elements) . "/" + . $this->findNearestElement('store', $key, $elements) . "/" + . $element['element']->text(); + return $path; + } + } + } +} diff --git a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php index a1d028108947cc93f113c125d0d7fe415d8295df..250347eacd0013b051073e6da1180e9db5597f4c 100755 --- a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php +++ b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php @@ -45,7 +45,7 @@ class SuggestElement extends Element * * @var string */ - protected $searchResult = '.mage-suggest-dropdown > ul'; + protected $searchResult = '.mage-suggest-dropdown'; /** * Selector item of search result @@ -96,4 +96,22 @@ class SuggestElement extends Element return $this->find($this->suggest)->getValue(); } + + /** + * Checking exist value in search result + * + * @param string $value + * @return bool + */ + public function isExistValueInSearchResult($value) + { + $searchResult = $this->find($this->searchResult); + + $this->find($this->suggest)->setValue($value); + $this->waitResult(); + if (!$searchResult->isVisible()) { + return false; + } + return $searchResult->find(sprintf($this->resultItem, $value), Locator::SELECTOR_XPATH)->isVisible(); + } } diff --git a/dev/tests/functional/lib/Mtf/Util/Generate/Factory.php b/dev/tests/functional/lib/Mtf/Util/Generate/Factory.php index 1ffd322e72542e731b63a69c6214bec183f8de09..3ff33762419e7c6663ad6f8eed38e38a9f30190e 100644 --- a/dev/tests/functional/lib/Mtf/Util/Generate/Factory.php +++ b/dev/tests/functional/lib/Mtf/Util/Generate/Factory.php @@ -25,6 +25,7 @@ namespace Mtf\Util\Generate; use Magento\Framework\ObjectManager; +use Magento\Framework\App; /** * Class Factory diff --git a/dev/tests/functional/lib/Mtf/Util/Generate/TestCase.php b/dev/tests/functional/lib/Mtf/Util/Generate/TestCase.php index 264557871c39f931dd123d85389d08d0b3963193..cc2b06011c884d31a362ca31b57619f9dcfe3f1c 100644 --- a/dev/tests/functional/lib/Mtf/Util/Generate/TestCase.php +++ b/dev/tests/functional/lib/Mtf/Util/Generate/TestCase.php @@ -25,6 +25,7 @@ namespace Mtf\Util\Generate; use Mtf\Util\Protocol\CurlInterface; use Mtf\Util\Protocol\CurlTransport; +use Magento\Framework\App; /** * Class TestCaseClass diff --git a/dev/tests/functional/lib/Mtf/Util/Generate/testcase.xml b/dev/tests/functional/lib/Mtf/Util/Generate/testcase.xml index b82b9673628ae62ee225afec81fefa8ae717a8fb..e98ae08401e3f6c2b91ea99f2c09bfcece60303a 100644 --- a/dev/tests/functional/lib/Mtf/Util/Generate/testcase.xml +++ b/dev/tests/functional/lib/Mtf/Util/Generate/testcase.xml @@ -24,93 +24,93 @@ */ --> <testcases> - <testcase module="Magento\Tax"> - <id>MTA-120</id> - <ticketId>MTA-120</ticketId> - <name>CreateTaxRateEntityTest</name> - <description>Test Creation for CreateTaxRateEntity</description> - <module>Tax</module> - <components> - <component>Tax (CS)</component> - </components> - <steps> - <step/> - <step>Steps:</step> - <step>Log in as default admin user.</step> - <step>Go to Stores > Taxes > Tax Zones and Rates.</step> - <step>Click 'Add New Tax Rate' button.</step> - <step>Fill in data according to dataSet</step> - <step>Save Tax Rate.</step> - <step>Perform all assertions.</step> - </steps> - </testcase> - <testcase> - <id>MTA-128</id> - <ticketId>MTA-128</ticketId> - <name>SuggestSearchingResult(SearchEntity)WithFucntionalTestsDesignedForAutomationTest</name> - <description>Cover Suggest Searching Result (SearchEntity) with fucntional tests designed for automation</description> - <module>Search</module> - <components> - <component>Search Frontend (CS)</component> - </components> - <steps/> - </testcase> - <testcase> - <id>MTA-15</id> - <ticketId>MTA-15</ticketId> - <name>CreateDownloadableProductEntityTest</name> - <description>Test Creation for Create DownloadableProductEntity </description> - <module>Catalog</module> - <components> - <component>Downloadable Product (CS)</component> - </components> - <steps> - <step>Log in to Backend.</step> - <step>Navigate to Products > Catalog.</step> - <step>Start to create new Downloadable product.</step> - <step>Fill in data according to data set.</step> - <step>Fill Downloadable Information tab according to data set.</step> - <step>Save product.</step> - <step>Verify created product.</step> - </steps> - </testcase> - <testcase> - <id>MTA-93</id> - <ticketId>MTA-93</ticketId> - <name>AdvancedSearchEntityTest</name> - <description>Test Creation for AdvancedSearchEntity</description> - <module>CatalogSearch</module> - <components> - <component>Search Frontend (MX)</component> - </components> - <steps> - <step/> - <step>Preconditions:</step> - <step> Two specific simple product is created(unique sku,name,short/full description, tax class)</step> - <step/> - <step>Steps</step> - <step>Navigate to Frontend</step> - <step>Click "Advanced Search"</step> - <step>Fill test data in to field(s)</step> - <step>Click "Search" button</step> - <step>Perform all asserts</step> - </steps> - </testcase> - <testcase> - <id>MTA-129</id> - <ticketId>MTA-129</ticketId> - <name>SearchEntityResultsTest</name> - <description>Test Creation for SearchEntity results</description> - <module>Search</module> - <components> - <component>Search Frontend (MX)</component> - </components> - <step>Preconditions:</step> - <step>1. All product types are created.</step> - <step/> - <step>Steps:</step> - <step>1. Navigate to frontend on index page.</step> - <step>2. Input test data into "search field" and press Enter key.</step> - <step>3. Perform all assertions.</step> - </testcase> + <testcase module="Magento\Tax"> + <id>MTA-120</id> + <ticketId>MTA-120</ticketId> + <name>CreateTaxRateEntityTest</name> + <description>Test Creation for CreateTaxRateEntity</description> + <module>Tax</module> + <components> + <component>Tax (CS)</component> + </components> + <steps> + <step/> + <step>Steps:</step> + <step>Log in as default admin user.</step> + <step>Go to Stores > Taxes > Tax Zones and Rates.</step> + <step>Click 'Add New Tax Rate' button.</step> + <step>Fill in data according to dataSet</step> + <step>Save Tax Rate.</step> + <step>Perform all assertions.</step> + </steps> + </testcase> + <testcase> + <id>MTA-128</id> + <ticketId>MTA-128</ticketId> + <name>SuggestSearchingResult(SearchEntity)WithFucntionalTestsDesignedForAutomationTest</name> + <description>Cover Suggest Searching Result (SearchEntity) with fucntional tests designed for automation</description> + <module>Search</module> + <components> + <component>Search Frontend (CS)</component> + </components> + <steps/> + </testcase> + <testcase> + <id>MTA-15</id> + <ticketId>MTA-15</ticketId> + <name>CreateDownloadableProductEntityTest</name> + <description>Test Creation for Create DownloadableProductEntity </description> + <module>Catalog</module> + <components> + <component>Downloadable Product (CS)</component> + </components> + <steps> + <step>Log in to Backend.</step> + <step>Navigate to Products > Catalog.</step> + <step>Start to create new Downloadable product.</step> + <step>Fill in data according to data set.</step> + <step>Fill Downloadable Information tab according to data set.</step> + <step>Save product.</step> + <step>Verify created product.</step> + </steps> + </testcase> + <testcase> + <id>MTA-93</id> + <ticketId>MTA-93</ticketId> + <name>AdvancedSearchEntityTest</name> + <description>Test Creation for AdvancedSearchEntity</description> + <module>CatalogSearch</module> + <components> + <component>Search Frontend (MX)</component> + </components> + <steps> + <step/> + <step>Preconditions:</step> + <step> Two specific simple product is created(unique sku,name,short/full description, tax class)</step> + <step/> + <step>Steps</step> + <step>Navigate to Frontend</step> + <step>Click "Advanced Search"</step> + <step>Fill test data in to field(s)</step> + <step>Click "Search" button</step> + <step>Perform all asserts</step> + </steps> + </testcase> + <testcase> + <id>MTA-129</id> + <ticketId>MTA-129</ticketId> + <name>SearchEntityResultsTest</name> + <description>Test Creation for SearchEntity results</description> + <module>Search</module> + <components> + <component>Search Frontend (MX)</component> + </components> + <step>Preconditions:</step> + <step>1. All product types are created.</step> + <step/> + <step>Steps:</step> + <step>1. Navigate to frontend on index page.</step> + <step>2. Input test data into "search field" and press Enter key.</step> + <step>3. Perform all assertions.</step> + </testcase> </testcases> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php index 1c31480dba11c3ef7607d045cf1c8ace1f7b851e..3c726bbcdec0621e14e099c669dde5b4965603cc 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php @@ -28,6 +28,7 @@ namespace Magento\Backend\Test\Block\System\Config; use Mtf\Client\Element\Locator; use Magento\Backend\Test\Block\FormPageActions as AbstractPageActions; +use Magento\Store\Test\Fixture\Store; /** * Class PageActions @@ -45,14 +46,28 @@ class PageActions extends AbstractPageActions /** * Select store * - * @param array $websiteScope + * @param string $websiteScope * @return $this */ public function selectStore($websiteScope) { - $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselect')->setValue($websiteScope); + $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselectstore') + ->setValue($websiteScope); $this->_rootElement->acceptAlert(); return $this; } + + /** + * Check if store visible in scope dropdown + * + * @param Store $store + * @return bool + */ + public function isStoreVisible($store) + { + $storeViews = $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselectstore') + ->getValues(); + return in_array($store->getGroupId() . "/" . $store->getName(), $storeViews); + } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/GroupForm.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/GroupForm.php index 7d06c49614f0924217b05c823a22f03836cece7b..b04cda9434b4dacee4afabc22aa48414fb9f3309 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/GroupForm.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/GroupForm.php @@ -25,6 +25,7 @@ namespace Magento\Backend\Test\Block\System\Store\Edit\Form; use Mtf\Block\Form; +use Mtf\Client\Element\Locator; /** * Class GroupForm @@ -32,5 +33,21 @@ use Mtf\Block\Form; */ class GroupForm extends Form { - // + /** + * Website name selector in dropdown + * + * @var string + */ + protected $website = '//option[contains(.,"%s")]'; + + /** + * Check that Website visible in Website dropdown + * + * @param string $websiteName + * @return bool + */ + public function isWebsiteVisible($websiteName) + { + return $this->_rootElement->find(sprintf($this->website, $websiteName), Locator::SELECTOR_XPATH)->isVisible(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.xml index 6991d725b4df88482fad8d710fdf8db5dc940ec2..74c12972435c16ee8953e9484e9947c1cb48b281 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.xml @@ -27,8 +27,10 @@ <wrapper>store</wrapper> <fields> <group_id> - <input>select</input> + <input>optgroupselect</input> </group_id> + <name /> + <code /> <is_active> <input>select</input> </is_active> diff --git a/lib/internal/Magento/Framework/Session/SessionConsole.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.php similarity index 83% rename from lib/internal/Magento/Framework/Session/SessionConsole.php rename to dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.php index 24788222a00c667b5bff4f7a31557a80e8e46f7c..e84495e9e3b8bb13aa74a7c0fec0cb08e276ebac 100644 --- a/lib/internal/Magento/Framework/Session/SessionConsole.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.php @@ -21,15 +21,16 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\Session; -class SessionConsole extends Generic -{ - /** - * Empty constructor to prevent session start - */ - public function __construct() - { +namespace Magento\Backend\Test\Block\System\Store\Edit\Form; + +use Mtf\Block\Form; - } +/** + * Class WebsiteForm + * Form for Website creation + */ +class WebsiteForm extends Form +{ + // } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.xml similarity index 85% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.xml rename to dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.xml index 211a7cc5252b6f14a319caf84ed0ea00f0ad9764..14bebd283b1fd70f424b4768d2b7414e310f03dc 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.xml @@ -24,10 +24,13 @@ */ --> <mapping strict="0"> + <wrapper>website</wrapper> <fields> - <display> - <selector>td [name$='associated_product_ids[]']</selector> - <input>checkbox</input> - </display> + <name /> + <code /> + <sort_order /> + <default_group_id> + <input>select</input> + </default_group_id> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/StoreGrid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/StoreGrid.php index e3a0a7229d9dc9d990878b7fbc551c7175d0dbf5..b47ca9bce554461684c3c09440caa5ba9280b1b8 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/StoreGrid.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/StoreGrid.php @@ -26,6 +26,8 @@ namespace Magento\Backend\Test\Block\System\Store; use Mtf\Client\Element\Locator; use Magento\Store\Test\Fixture\StoreGroup; +use Magento\Store\Test\Fixture\Website; +use Magento\Store\Test\Fixture\Store; use Magento\Backend\Test\Block\Widget\Grid as GridInterface; /** @@ -52,6 +54,9 @@ class StoreGrid extends GridInterface ], 'group_title' => [ 'selector' => '#storeGrid_filter_group_title' + ], + 'website_title' => [ + 'selector' => '#storeGrid_filter_website_title' ] ]; @@ -82,26 +87,53 @@ class StoreGrid extends GridInterface } /** - * Click to appropriate store in Store grid for edit + * Check if website exists + * + * @param Website $website + * @return bool + */ + public function isWebsiteExists($website) + { + return $this->_rootElement->find(sprintf($this->titleFormat, $website->getName()), Locator::SELECTOR_XPATH) + ->isVisible(); + } + + /** + * Search and open appropriate Website + * + * @param Website $website + * @return void + */ + public function searchAndOpenWebsite(Website $website) + { + $websiteName = $website->getName(); + $this->search(['website_title' => $websiteName]); + $this->_rootElement->find(sprintf($this->storeName, $websiteName), Locator::SELECTOR_XPATH)->click(); + } + + /** + * Search and open appropriate Store View * - * @param string $name + * @param Store $store * @return void */ - public function editStore($name) + public function searchAndOpenStore(Store $store) { - $this->_rootElement->find(sprintf($this->storeName, $name), Locator::SELECTOR_XPATH)->click(); + $storeName = $store->getName(); + $this->search(['store_title' => $storeName]); + $this->_rootElement->find(sprintf($this->storeName, $storeName), Locator::SELECTOR_XPATH)->click(); } /** - * Search and open appropriate store + * Search and open appropriate Store * * @param StoreGroup $storeGroup * @return void */ - public function searchAndOpenStore(StoreGroup $storeGroup) + public function searchAndOpenStoreGroup(StoreGroup $storeGroup) { - $storeName = $storeGroup->getName(); - $this->search(['group_title' => $storeName]); - $this->editStore($storeName); + $storeGroupName = $storeGroup->getName(); + $this->search(['group_title' => $storeGroupName]); + $this->_rootElement->find(sprintf($this->storeName, $storeGroupName), Locator::SELECTOR_XPATH)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php old mode 100644 new mode 100755 diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php index 9df2043bbad95c04abbc5a680d3efbd676b6b3f6..c65e426bbd4ed3843e302886957ce53aa9be2dc9 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php @@ -144,11 +144,11 @@ abstract class Grid extends Block protected $waitForSelectorVisible = true; /** - * Selector for status select + * Selector for action option select * * @var string */ - protected $status = '[name="status"]'; + protected $option = '[name="status"]'; /** * Get backend abstract block @@ -283,7 +283,7 @@ abstract class Grid extends Block $actionType = key($action); $this->_rootElement->find($this->massactionSelect, Locator::SELECTOR_CSS, 'select')->setValue($actionType); if (isset($action[$actionType]) && $action[$actionType] != '-') { - $this->_rootElement->find($this->status, Locator::SELECTOR_CSS, 'select')->setValue($action[$actionType]); + $this->_rootElement->find($this->option, Locator::SELECTOR_CSS, 'select')->setValue($action[$actionType]); } $this->massActionSubmit($acceptAlert); } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Dashboard.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/Dashboard.xml similarity index 100% rename from dev/tests/functional/tests/app/Magento/Backend/Test/Page/Dashboard.xml rename to dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/Dashboard.xml diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/DeleteWebsite.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/DeleteWebsite.xml new file mode 100644 index 0000000000000000000000000000000000000000..41c456b6d024a82c45e2d7452c54da06999fa09a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/DeleteWebsite.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="system_store/deleteWebsite" module="Magento_Backend"> + <blocks> + <deleteWebsiteForm> + <class>Magento\Backend\Test\Block\System\Store\Delete\Form</class> + <locator>#edit_form</locator> + <strategy>css selector</strategy> + </deleteWebsiteForm> + <formPageFooterActions> + <class>Magento\Backend\Test\Block\System\Store\FormPageFooterActions</class> + <locator>.content-footer</locator> + <strategy>css selector</strategy> + </formPageFooterActions> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditStore.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditStore.xml new file mode 100644 index 0000000000000000000000000000000000000000..eaa0aad866b8977ef4fd0d2ab7e6708c46f96921 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditStore.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="admin/system_store/editStore" module="Magento_Backend"> + <blocks> + <formPageActions> + <class>Magento\Backend\Test\Block\System\Store\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <storeForm> + <class>Magento\Backend\Test\Block\System\Store\Edit\Form\StoreForm</class> + <locator>[id="page:main-container"]</locator> + <strategy>css selector</strategy> + </storeForm> + <messagesBlock> + <class>Magento\Core\Test\Block\Messages</class> + <locator>#messages</locator> + <strategy>css selector</strategy> + </messagesBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditWebsite.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditWebsite.xml new file mode 100644 index 0000000000000000000000000000000000000000..ab08c0a7af4fe65397e18974dda8a7279dedc455 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditWebsite.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="system_store/editWebsite" module="Magento_Backend"> + <blocks> + <formPageActions> + <class>Magento\Backend\Test\Block\System\Store\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <editFormWebsite> + <class>Magento\Backend\Test\Block\System\Store\Edit\Form\WebsiteForm</class> + <locator>#edit_form</locator> + <strategy>css selector</strategy> + </editFormWebsite> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/NewWebsiteIndex.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/NewWebsiteIndex.xml new file mode 100644 index 0000000000000000000000000000000000000000..0e5fe3b06246602e818aa7741f60e1e5be7f80cb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/NewWebsiteIndex.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="system_store/newWebsite/index" module="Magento_Backend"> + <blocks> + <formPageActions> + <class>Magento\Backend\Test\Block\System\Store\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <editWebsiteForm> + <class>Magento\Backend\Test\Block\System\Store\Edit\Form\WebsiteForm</class> + <locator>#edit_form</locator> + <strategy>css selector</strategy> + </editWebsiteForm> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/etc/page.xml index 0d41709f69ec3eac473b7d4384acde1d5b1d0f62..8364e6ccc99cf58a2b91c8f713a8063d7aadee2d 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/etc/page.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/etc/page.xml @@ -24,6 +24,11 @@ */ --> <page module="Magento_Backend"> + <dashboard> + <mca>admin/dashboard</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\Dashboard</class> + </dashboard> <systemConfig> <mca>admin/system_config</mca> <area>adminhtml</area> @@ -39,6 +44,11 @@ <area>adminhtml</area> <class>Magento\Backend\Test\Page\Adminhtml\StoreNew</class> </storeNew> + <editStore> + <mca>admin/system_store/editStore</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\EditStore</class> + </editStore> <storeDelete> <mca>admin/system_store/deleteStore</mca> <area>adminhtml</area> @@ -59,4 +69,19 @@ <area>adminhtml</area> <class>Magento\Backend\Test\Page\Adminhtml\DeleteGroup</class> </deleteGroup> + <newWebsiteIndex> + <mca>system_store/newWebsite/index</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\NewWebsiteIndex</class> + </newWebsiteIndex> + <editWebsite> + <mca>system_store/editWebsite</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\EditWebsite</class> + </editWebsite> + <deleteWebsite> + <mca>system_store/deleteWebsite</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\DeleteWebsite</class> + </deleteWebsite> </page> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php index be2d98aef7ddce09e033560e067fe3034ba8dd38..1dcbcaaab5bbb715d5663b531a9963dc62fb7a80 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php @@ -25,15 +25,24 @@ namespace Magento\Bundle\Test\Block\Catalog\Product; use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Block\Product\View as ParentView; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Bundle; +use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\Bundle\Test\Fixture\CatalogProductBundle; /** * Class View * Bundle product view block on the product page */ -class View extends ParentView +class View extends \Magento\Catalog\Test\Block\Product\View { + /** + * Customize and add to cart button selector + * + * @var string + */ + protected $customizeButton = '.action.primary.customize'; + /** * Bundle options block * @@ -53,4 +62,55 @@ class View extends ParentView ['element' => $this->_rootElement->find($this->bundleBlock, Locator::SELECTOR_XPATH)] ); } + + /** + * Click "Customize and add to cart button" + * + * @return void + */ + public function clickCustomize() + { + $this->_rootElement->find($this->customizeButton)->click(); + $this->waitForElementVisible($this->addToCart); + } + + /** + * Return product options + * + * @param FixtureInterface $product [optional] + * @return array + */ + public function getOptions(FixtureInterface $product = null) + { + $options = []; + + $this->clickCustomize(); + $options['bundle_options'] = $this->getBundleBlock()->getOptions($product); + $options += parent::getOptions($product); + + return $options; + } + + /** + * Fill in the option specified for the product + * + * @param FixtureInterface $product + * @return void + */ + public function fillOptions(FixtureInterface $product) + { + if ($product instanceof InjectableFixture) { + /** @var \Magento\Bundle\Test\Fixture\CatalogProductBundle $product */ + $checkoutData = $product->getCheckoutData(); + $bundleCheckoutData = isset($checkoutData['bundle_options']) ? $checkoutData['bundle_options'] : []; + } else { + // TODO: Removed after refactoring(removed) old product fixture. + /** @var \Magento\Bundle\Test\Fixture\BundleFixed $product */ + $bundleCheckoutData = $product->getSelectionData(); + } + $this->_rootElement->find($this->customizeButton)->click(); + $this->getBundleBlock()->fillBundleOptions($bundleCheckoutData); + + parent::fillOptions($product); + } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php index 24d023cc12205cffab851495cb5c8adf38652d08..ca9e34056288c336f749732d6ddf99fec0488c1b 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php @@ -25,10 +25,14 @@ namespace Magento\Bundle\Test\Block\Catalog\Product\View\Type; use Mtf\Block\Block; +use Mtf\Client\Element; use Mtf\Client\Element\Locator; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; -use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\Bundle\Test\Fixture\Bundle as BundleDataFixture; +use Magento\Bundle\Test\Fixture\CatalogProductBundle; /** * Class Bundle @@ -37,85 +41,228 @@ use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; class Bundle extends Block { /** - * Bundle options block + * Selector for single option block * * @var string */ - protected $bundleBlock = './div[%d]'; + protected $optionElement = './div[contains(@class,"option")][%d]'; /** - * Label item option + * Selector for title of option * * @var string */ - protected $requiredOptions = '[%s(contains(@class,"required"))]'; + protected $title = './label/span'; /** - * Label item option + * Selector for required option * * @var string */ - protected $optionSelect = './/select/option[@value != ""][%d][contains(text(), "%s")]'; + protected $required = './self::*[contains(@class,"required")]'; /** - * Label item option + * Selector for select element of option * * @var string */ - protected $optionLabel = './/div[%d][contains(@class, "field")]//*[contains(text(), "%s")]'; + protected $selectOption = './/div[@class="control"]/select'; /** - * Selector DropDown type + * Selector for label of option value element * * @var string */ - protected $typeDropDown = './/select[contains(@class,"bundle-option-select")]'; + protected $optionLabel = './/div[@class="control"]//label[contains(@for, "options_")][%d]'; /** - * Selector Multiselect type + * Selector for option of select element * * @var string */ - protected $typeMultiple = './/select[contains(@class,"multiselect")]'; + protected $option = './/option[%d]'; /** - * Selector RadioButton type + * Selector bundle option block for fill * * @var string */ - protected $typeRadio = './/input[contains(@class,"radio")]'; + protected $bundleOptionBlock = './/div[label[span[contains(text(), "%s")]]]'; /** - * Selector Checkbox type + * Fill bundle option on frontend add click "Add to cart" button * - * @var string + * @param CatalogProductBundle $product + * @param CatalogProductView $catalogProductView + * @return void */ - protected $typeCheckbox = './/input[contains(@class,"checkbox")]'; + public function addToCart(CatalogProductBundle $product, CatalogProductView $catalogProductView) + { + $catalogProductView->getViewBlock()->fillOptions($product); + $catalogProductView->getViewBlock()->clickAddToCart(); + } /** - * Selector bundle option block for fill + * Get product options * - * @var string + * @param FixtureInterface $product + * @return array + * @throws \Exception */ - protected $bundleOptionBlock = './/div[label[span[contains(text(), "%s")]]]'; + public function getOptions(FixtureInterface $product) + { + if ($product instanceof InjectableFixture) { + /** @var CatalogProductBundle $product */ + $bundleSelections = $product->getBundleSelections(); + $bundleOptions = isset($bundleSelections['bundle_options']) ? $bundleSelections['bundle_options'] : []; + } else { + // TODO: Removed after refactoring(removed) old product fixture. + /** @var BundleDataFixture $product */ + $bundleOptions = $product->getBundleOptions(); + } + + $listFormOptions = $this->getListOptions(); + $formOptions = []; + + foreach ($bundleOptions as $option) { + $title = $option['title']; + if (!isset($listFormOptions[$title])) { + throw new \Exception("Can't find option: \"{$title}\""); + } + + /** @var Element $optionElement */ + $optionElement = $listFormOptions[$title]; + $getTypeData = 'get' . $this->optionNameConvert($option['type']) . 'Data'; + + $optionData = $this->$getTypeData($optionElement); + $optionData['title'] = $title; + $optionData['type'] = $option['type']; + $optionData['is_require'] = $optionElement->find($this->required, Locator::SELECTOR_XPATH)->isVisible() + ? 'Yes' + : 'No'; + + $formOptions[] = $optionData; + } + + return $formOptions; + } /** - * Fill bundle option on frontend add click "Add to cart" button + * Get list options * - * @param CatalogProductBundle $product - * @param CatalogProductView $catalogProductView - * @return void + * @return array */ - public function addToCart(CatalogProductBundle $product, CatalogProductView $catalogProductView) + protected function getListOptions() + { + $options = []; + + $count = 1; + $optionElement = $this->_rootElement->find(sprintf($this->optionElement, $count), Locator::SELECTOR_XPATH); + while ($optionElement->isVisible()) { + $title = $optionElement->find($this->title, Locator::SELECTOR_XPATH)->getText(); + $options[$title] = $optionElement; + + ++$count; + $optionElement = $this->_rootElement->find(sprintf($this->optionElement, $count), Locator::SELECTOR_XPATH); + } + return $options; + } + + /** + * Get data of "Drop-down" option + * + * @param Element $option + * @return array + */ + protected function getDropdownData(Element $option) + { + $select = $option->find($this->selectOption, Locator::SELECTOR_XPATH, 'select'); + // Skip "Choose option ..."(option #1) + return $this->getSelectOptionsData($select, 2); + } + + /** + * Get data of "Multiple" option + * + * @param Element $option + * @return array + */ + protected function getMultipleselectData(Element $option) + { + $multiselect = $option->find($this->selectOption, Locator::SELECTOR_XPATH, 'multiselect'); + return $this->getSelectOptionsData($multiselect, 1); + } + + /** + * Get data of "Radio" option + * + * @param Element $option + * @return array + */ + protected function getRadiobuttonsData(Element $option) { - $fillData = $product->getDataFieldConfig('checkout_data')['source']->getPreset(); - if (isset($fillData['bundle_options'])) { - $this->fillBundleOptions($fillData['bundle_options']); + $listOptions = []; + + $count = 1; + $option = $option->find(sprintf($this->optionLabel, $count), Locator::SELECTOR_XPATH); + while ($option->isVisible()) { + $listOptions[] = $this->parseOptionText($option->getText()); + ++$count; + $option = $option->find(sprintf($this->optionLabel, $count), Locator::SELECTOR_XPATH); } - if (isset($fillData['custom_options'])) { - $catalogProductView->getCustomOptionsBlock()->fillCustomOptions($product, $fillData['custom_options']); + + return ['options' => $listOptions]; + } + + /** + * Get data of "Checkbox" option + * + * @param Element $option + * @return array + */ + protected function getCheckboxData(Element $option) + { + return $this->getRadiobuttonsData($option); + } + + /** + * Get data from option of select and multiselect + * + * @param Element $element + * @param int $firstOption + * @return array + */ + protected function getSelectOptionsData(Element $element, $firstOption = 1) + { + $listOptions = []; + + $count = $firstOption; + $selectOption = $element->find(sprintf($this->option, $count), Locator::SELECTOR_XPATH); + while ($selectOption->isVisible()) { + $listOptions[] = $this->parseOptionText($selectOption->getText()); + ++$count; + $selectOption = $element->find(sprintf($this->option, $count), Locator::SELECTOR_XPATH); } - $catalogProductView->getViewBlock()->clickAddToCart(); + + return ['options' => $listOptions]; + } + + /** + * Parse option text to title and price + * + * @param string $optionText + * @return array + */ + protected function parseOptionText($optionText) + { + preg_match('`^(.*?)\+ ?\$(\d.*?)$`', $optionText, $match); + $optionPrice = isset($match[2]) ? str_replace(',', '', $match[2]) : 0; + $optionTitle = isset($match[1]) ? trim($match[1]) : $optionText; + + return [ + 'title' => $optionTitle, + 'price' => $optionPrice + ]; } /** @@ -138,62 +285,15 @@ class Bundle extends Block } } - /** - * Get bundle item option - * - * @param array $fields - * @param int $index - * @return bool|string - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function displayedBundleItemOption(array $fields, $index) - { - $bundleOptionBlock = $this->_rootElement->find(sprintf($this->bundleBlock, $index), Locator::SELECTOR_XPATH); - $option = $bundleOptionBlock->find( - $this->{'type' . $this->optionNameConvert($fields['type'])}, - Locator::SELECTOR_XPATH - ); - if (!$option->isVisible()) { - return '"' . $fields['title'] . '" Option does not equal to fixture option type.'; - } - - $formatRequired = sprintf( - $this->bundleBlock . $this->requiredOptions, - $index, - (($fields['required'] == 'Yes') ? '' : 'not') - ); - if (!$this->_rootElement->find($formatRequired, Locator::SELECTOR_XPATH)->isVisible()) { - return "This Option must be " . ($fields['required'] == 'Yes') ? '' : 'not' . " required."; - } - - foreach ($fields['assigned_products'] as $increment => $item) { - $isMultiAssigned = count($fields['assigned_products']) > 1; - $isSelectType = $fields['type'] == 'Drop-down' || $fields['type'] == 'Multiple Select'; - $selectOptions = $isMultiAssigned && $isSelectType ? $this->optionSelect : $this->optionLabel; - $formatOption = sprintf($selectOptions, ++$increment, $item['name']); - if (!$bundleOptionBlock->find($formatOption, Locator::SELECTOR_XPATH)->isVisible()) { - return 'SelectOption ' . $item['name'] . ' with index ' - . $increment . ' data is not equals with fixture SelectOption data.'; - } - } - return true; - } - /** * Convert option name * - * @param string $optionName + * @param string $optionType * @return string */ - protected function optionNameConvert($optionName) + protected function optionNameConvert($optionType) { - if ($end = strpos($optionName, ' ')) { - $optionName = substr($optionName, 0, $end); - } elseif ($end = strpos($optionName, '-')) { - $optionName = substr($optionName, 0, $end) . ucfirst(substr($optionName, ($end + 1))); - } - return $optionName; + $trimmedOptionType = preg_replace('/[^a-zA-Z]/', '', $optionType); + return ucfirst(strtolower($trimmedOptionType)); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.php similarity index 95% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.php index f49b2e934e6b032367a026fe265ecdeac1277399..0e4585c1f2e90b4a3680990ba916463cd9735ab8 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.php @@ -27,10 +27,10 @@ namespace Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; /** - * Class DropDown + * Class Dropdown * Bundle option drop-down type */ -class DropDown extends Option +class Dropdown extends Option { // Parent behavior } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.xml similarity index 100% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.xml rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.xml diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php old mode 100644 new mode 100755 index 273e557f4b02954d31797564788bd4bb7141a9fc..8bc169f289f4a2bdfc9d176155d249768b3c3883 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php @@ -25,14 +25,15 @@ namespace Magento\Bundle\Test\Constraint; use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Bundle\Test\Fixture\CatalogProductBundle; use Magento\Catalog\Test\Page\Product\CatalogProductView; /** * Class AssertBundleItemsOnProductPage + * Assert that displayed product bundle items data on product page equals passed from fixture preset */ -class AssertBundleItemsOnProductPage extends AbstractConstraint +class AssertBundleItemsOnProductPage extends AbstractAssertForm { /** * Constraint severeness @@ -55,41 +56,56 @@ class AssertBundleItemsOnProductPage extends AbstractConstraint Browser $browser ) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $catalogProductView->getViewBlock()->clickCustomize(); - $result = $this->displayedBundleBlock($catalogProductView, $product); - \PHPUnit_Framework_Assert::assertTrue(empty($result), $result); + + $productOptions = $this->prepareBundleOptions($product); + $productOptions = $this->sortDataByPath($productOptions, '::title'); + foreach ($productOptions as $key => $productOption) { + $productOptions[$key] = $this->sortDataByPath($productOption, 'options::title'); + } + $formOptions = $catalogProductView->getViewBlock()->getOptions($product)['bundle_options']; + $formOptions = $this->sortDataByPath($formOptions, '::title'); + foreach ($formOptions as $key => $formOption) { + $formOptions[$key] = $this->sortDataByPath($formOption, 'options::title'); + } + + $error = $this->verifyData($productOptions, $formOptions); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); } /** - * Displayed bundle block on frontend with correct fixture product + * Prepare bundle options * - * @param CatalogProductView $catalogProductView * @param CatalogProductBundle $product - * @return string|null + * @return array */ - protected function displayedBundleBlock(CatalogProductView $catalogProductView, CatalogProductBundle $product) + protected function prepareBundleOptions(CatalogProductBundle $product) { - $fields = $product->getData(); - $bundleOptions = $fields['bundle_selections']['bundle_options']; - if (!isset($bundleOptions)) { - return 'Bundle options data on product page is not equals to fixture preset.'; - } + $bundleSelections = $product->getBundleSelections(); + $bundleOptions = isset($bundleSelections['bundle_options']) ? $bundleSelections['bundle_options'] : []; + $result = []; - $catalogProductView->getViewBlock()->clickCustomize(); - foreach ($bundleOptions as $index => $item) { - foreach ($item['assigned_products'] as &$selection) { - $selection = $selection['search_data']; - } - $result = $catalogProductView->getBundleViewBlock()->getBundleBlock()->displayedBundleItemOption( - $item, - ++$index - ); + foreach ($bundleOptions as $optionKey => $bundleOption) { + $optionData = [ + 'title' => $bundleOption['title'], + 'type' => $bundleOption['type'], + 'is_require' => $bundleOption['required'], + ]; + + foreach ($bundleOption['assigned_products'] as $productKey => $assignedProduct) { + $price = isset($assignedProduct['data']['selection_price_value']) + ? $assignedProduct['data']['selection_price_value'] + : $bundleSelections['products'][$optionKey][$productKey]->getPrice(); - if ($result !== true) { - return $result; + $optionData['options'][$productKey] = [ + 'title' => $assignedProduct['search_data']['name'], + 'price' => number_format($price, 2) + ]; } + + $result[$optionKey] = $optionData; } - return null; + + return $result; } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php old mode 100644 new mode 100755 index 87997d57d385c0fb1bcf126f3a7fe80aaa266868..466b2c9c085672dd0e85412d30ab7d6140bad4b9 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php @@ -95,15 +95,12 @@ class AssertBundlePriceType extends AbstractConstraint CatalogProductBundle $originalProduct = null ) { $customerGroup = 'NOT LOGGED IN'; - $catalogProductView->getViewBlock()->clickCustomize(); $bundleData = $product->getData(); $this->productPriceType = $originalProduct !== null ? $originalProduct->getPriceType() : $product->getPriceType(); - $fillData = $product->getDataFieldConfig('checkout_data')['source']->getPreset(); - $bundleBlock = $catalogProductView->getBundleViewBlock()->getBundleBlock(); - $bundleBlock->addToCart($product, $catalogProductView); - $cartBlock = $checkoutCartView->getCartBlock(); + $catalogProductView->getViewBlock()->addToCart($product); + $cartItem = $checkoutCartView->getCartBlock()->getCartItem($product); $specialPrice = 0; if (isset($bundleData['group_price'])) { $specialPrice = @@ -111,6 +108,7 @@ class AssertBundlePriceType extends AbstractConstraint } $optionPrice = []; + $fillData = $product->getCheckoutData(); foreach ($fillData['bundle_options'] as $key => $data) { $subProductPrice = 0; foreach ($bundleData['bundle_selections']['products'][$key] as $productKey => $itemProduct) { @@ -133,13 +131,13 @@ class AssertBundlePriceType extends AbstractConstraint $item['price'] -= $item['price'] * $specialPrice; \PHPUnit_Framework_Assert::assertEquals( number_format($item['price'], 2), - $cartBlock->getPriceBundleOptions($index + 1), + $cartItem->getPriceBundleOptions($index + 1), 'Bundle item ' . ($index + 1) . ' options on frontend don\'t equal to fixture.' ); } $sumOptionsPrice = $product->getDataFieldConfig('price')['source']->getPreset()['cart_price']; - $subTotal = number_format($cartBlock->getCartItemUnitPrice($product), 2); + $subTotal = number_format($cartItem->getPrice(), 2); \PHPUnit_Framework_Assert::assertEquals( $sumOptionsPrice, $subTotal, diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php index e6d495c55baf0e7a92f988ee95e2d748b5a9ca89..8795fb227723c69754adb3030abab40d12f74e2c 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php @@ -71,7 +71,7 @@ class AssertBundlePriceView extends AbstractConstraint protected function assertPrice(CatalogProductBundle $product, CatalogProductView $catalogProductView) { $priceData = $product->getDataFieldConfig('price')['source']->getPreset(); - $priceBlock = $catalogProductView->getViewBlock()->getProductPriceBlock(); + $priceBlock = $catalogProductView->getViewBlock()->getPriceBlock(); $priceLow = ($product->getPriceView() == 'Price Range') ? $priceBlock->getPriceFrom() diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php index 76880a4c01508fef07cc9ca946c3f960e79183a4..1c93336ce9fc1d74d92df41ec8e2b1e49762d496 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php @@ -24,7 +24,6 @@ namespace Magento\Bundle\Test\Constraint; -use Mtf\Fixture\FixtureInterface; use Magento\Catalog\Test\Constraint\AssertProductForm; /** @@ -57,17 +56,16 @@ class AssertBundleProductForm extends AssertProductForm * Prepares fixture data for comparison * * @param array $data - * @param FixtureInterface $product * @param array $sortFields [optional] * @return array */ - protected function prepareFixtureData(array $data, FixtureInterface $product, array $sortFields = []) + protected function prepareFixtureData(array $data, array $sortFields = []) { $data['bundle_selections'] = $this->prepareBundleOptions( $data['bundle_selections']['bundle_options'] ); - return parent::prepareFixtureData($data, $product, $sortFields); + return parent::prepareFixtureData($data, $sortFields); } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php index 874df95f117b3b8d1cce4699d1b93c8796d642cf..6fcb84c3a302808e9bdd0ad76bcfb232a64735fd 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php @@ -32,59 +32,26 @@ use Magento\Catalog\Test\Constraint\AssertProductPage; class AssertBundleProductPage extends AssertProductPage { /** - * Constraint severeness + * Verify displayed product price on product page(front-end) equals passed from fixture * - * @var string + * @return string|null */ - protected $severeness = 'low'; - - /** - * Error messages - * - * @var array - */ - protected $errorsMessages = [ - 'name' => '- product name on product view page is not correct.', - 'sku' => '- product sku on product view page is not correct.', - 'price_from' => '- bundle product price from on product view page is not correct.', - 'price_to' => '- bundle product price to on product view page is not correct.', - 'short_description' => '- product short description on product view page is not correct.', - 'description' => '- product description on product view page is not correct.' - ]; - - /** - * Prepare Price data - * - * @param array $price - * @return array - */ - protected function preparePrice($price) + protected function verifyPrice() { $priceData = $this->product->getDataFieldConfig('price')['source']->getPreset(); - $priceView = $this->product->getPriceView(); - if ($priceView === null || $priceView == 'Price Range') { - if (isset($price['price_from']) && isset($price['price_to'])) { - return [ - ['price_from' => $price['price_from'], 'price_to' => $price['price_to']], - [ - 'price_from' => number_format($priceData['price_from'], 2), - 'price_to' => number_format($priceData['price_to'], 2) - ] - ]; - } - return [ - ['price_regular_price' => $price['price_regular_price']], - ['price_regular_price' => number_format($priceData['price_from'], 2)] - ]; - } else { - return [ - ['price_from' => $price['price_regular_price']], - [ - 'price_from' => is_numeric($priceData['price_from']) - ? number_format($priceData['price_from'], 2) - : $priceData['price_from'] - ] - ]; + $priceBlock = $this->productView->getPriceBlock(); + $priceLow = ($this->product->getPriceView() == 'Price Range') + ? $priceBlock->getPriceFrom() + : $priceBlock->getRegularPrice(); + $errors = []; + + if ($priceData['price_from'] != $priceLow) { + $errors[] = 'Bundle price "From" on product view page is not correct.'; } + if ($this->product->getPriceView() == 'Price Range' && $priceData['price_to'] != $priceBlock->getPriceTo()) { + $errors[] = 'Bundle price "To" on product view page is not correct.'; + } + + return empty($errors) ? null : implode("\n", $errors); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php index a067d4a8fdedd323b913b03bdffd71b7406ed169..4d0931c789bcf4e400941646d796f41fd322fc19 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php @@ -24,9 +24,6 @@ namespace Magento\Bundle\Test\Constraint; -use Mtf\Client\Browser; -use Mtf\Fixture\FixtureInterface; -use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Catalog\Test\Constraint\AssertProductCustomOptionsOnProductPage; /** @@ -41,21 +38,4 @@ class AssertProductCustomOptionsOnBundleProductPage extends AssertProductCustomO * @var bool */ protected $isPrice = false; - - /** - * Open product view page - * - * @param CatalogProductView $catalogProductView - * @param FixtureInterface $product - * @param Browser $browser - * @return void - */ - protected function openProductPage( - CatalogProductView $catalogProductView, - FixtureInterface $product, - Browser $browser - ) { - $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $catalogProductView->getViewBlock()->clickCustomize(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Bundle.php index a6f6acd904439dd74e6018c326d3c52e7e92aabd..92fa8a108f05442220cdff3c9410373ea0dd57f8 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Bundle.php @@ -85,14 +85,21 @@ class Bundle extends Product */ public function getBundleOptions() { - $options = array(); + $options = []; $bundleOptions = $this->getData('fields/bundle_selections/value'); foreach ($bundleOptions['bundle_options'] as $optionData) { - $optionName = $optionData['title']; + $option = [ + 'title' => $optionData['title'], + 'type' => $optionData['type'], + 'options' => [] + ]; + foreach ($optionData['assigned_products'] as $productData) { - $options[$optionName][] = $productData['search_data']['name']; + $option['options'][] = ['title' => $productData['search_data']['name']]; } + $options[] = $option; } + return $options; } @@ -138,14 +145,15 @@ class Bundle extends Product protected function _initData() { parent::_initData(); - $this->_dataConfig = array( + $this->_dataConfig = [ + 'type_id' => 'bundle', 'constraint' => 'Success', - 'create_url_params' => array( + 'create_url_params' => [ 'type' => 'bundle', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID, - ), + ], 'input_prefix' => 'product' - ); + ]; $this->_repository = Factory::getRepositoryFactory() ->getMagentoBundleBundle($this->_dataConfig, $this->_data); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php index 2b1819dab070cea1788a9332845fd5e07b056227..42d24dc006d141f64e9516eebb7fff2356224fd5 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php @@ -89,6 +89,7 @@ class CatalogProductBundle extends InjectableFixture } protected $dataConfig = [ + 'type_id' => 'bundle', 'create_url_params' => [ 'type' => 'bundle', 'set' => '4', @@ -621,6 +622,7 @@ class CatalogProductBundle extends InjectableFixture 'attribute_code' => 'checkout_data', 'backend_type' => 'virtual', 'is_required' => '1', + 'group' => null, 'source' => 'Magento\Bundle\Test\Fixture\CatalogProductBundle\CheckoutData', ]; @@ -947,6 +949,11 @@ class CatalogProductBundle extends InjectableFixture return $this->getData('bundle_selections'); } + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } + public function getCustomOptions() { return $this->getData('custom_options'); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml index 3400eb8faf2c9a78da9db8483bc7801665d18972..dbee01e084877c8b5e4cdedd7c66f587aaab97ad 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml @@ -431,6 +431,12 @@ <group>bundle</group> <fixture>Magento\Bundle\Test\Fixture\Bundle\BundleSelections</fixture> </bundle_selections> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <fixture>Magento\Bundle\Test\Fixture\CatalogProductBundle\CheckoutData</fixture> + </checkout_data> <custom_options> <attribute_code>custom_options</attribute_code> <backend_type>virtual</backend_type> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php index 1485dc7940253536f3f4133395058c6a81243497..e53658aae9aec9daf100621b21de2a7331943217 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php @@ -24,23 +24,22 @@ namespace Magento\Bundle\Test\Fixture\CatalogProductBundle; -use Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData as AbstractCheckoutData; - /** * Class CheckoutData * Data keys: * - preset (Checkout data verification preset name) - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ -class CheckoutData extends AbstractCheckoutData +class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData { /** * Get preset array * + * @param string $name * @return array|null + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function getPreset() + protected function getPreset($name) { $presets = [ 'default' => [ @@ -84,52 +83,52 @@ class CheckoutData extends AbstractCheckoutData ], 'custom_options' => [ [ - 'option' => 1, - 'value' => [1], + 'title' => 0, + 'value' => 0, ], [ - 'option' => 2, - 'value' => [1], + 'title' => 1, + 'value' => 0, ], [ - 'option' => 3, - 'value' => ['Field'], + 'title' => 2, + 'value' => 'Field', ], [ - 'option' => 4, - 'value' => ['Field'], + 'title' => 3, + 'value' => 'Field', ], [ - 'option' => 5, - 'value' => ['Area'], + 'title' => 4, + 'value' => 'Area', ], [ - 'option' => 7, - 'value' => [1], + 'title' => 6, + 'value' => 0, ], [ - 'option' => 8, - 'value' => [1], + 'title' => 7, + 'value' => 0, ], [ - 'option' => 9, - 'value' => [1], + 'title' => 8, + 'value' => 0, ], [ - 'option' => 10, - 'value' => [1], + 'title' => 9, + 'value' => 0, ], [ - 'option' => 11, - 'value' => ['12/12/2014'], + 'title' => 10, + 'value' => '12/12/2014', ], [ - 'option' => 12, - 'value' => ['12/12/2014/12/30/AM'], + 'title' => 11, + 'value' => '12/12/2014/12/30/AM', ], [ - 'option' => 13, - 'value' => ['12/12/AM'], + 'title' => 12, + 'value' => '12/12/AM', ], ] ], @@ -145,8 +144,8 @@ class CheckoutData extends AbstractCheckoutData ], 'custom_options' => [ [ - 'option' => 1, - 'value' => [1], + 'title' => 0, + 'value' => 0, ], ] ], @@ -183,40 +182,40 @@ class CheckoutData extends AbstractCheckoutData ], 'custom_options' => [ [ - 'option' => 1, - 'value' => ['Field'], + 'title' => 0, + 'value' => 'Field', ], [ - 'option' => 2, - 'value' => ['Area'], + 'title' => 1, + 'value' => 'Area', ], [ - 'option' => 4, - 'value' => [1], + 'title' => 3, + 'value' => 0, ], [ - 'option' => 5, - 'value' => [1], + 'title' => 4, + 'value' => 0, ], [ - 'option' => 6, - 'value' => [1], + 'title' => 5, + 'value' => 0, ], [ - 'option' => 7, - 'value' => [1], + 'title' => 6, + 'value' => 0, ], [ - 'option' => 8, - 'value' => ['12/12/2014'], + 'title' => 7, + 'value' => '12/12/2014', ], [ - 'option' => 9, - 'value' => ['12/12/2014/12/30/AM'], + 'title' => 8, + 'value' => '12/12/2014/12/30/AM', ], [ - 'option' => 10, - 'value' => ['12/12/AM'], + 'title' => 9, + 'value' => '12/12/AM', ], ] ], @@ -253,9 +252,6 @@ class CheckoutData extends AbstractCheckoutData ], ], ]; - if (!isset($presets[$this->currentPreset])) { - return null; - } - return $presets[$this->currentPreset]; + return isset($presets[$name]) ? $presets[$name] : null; } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml index e8e3783a8f094725380567133571cf30d4bf4fd5..470c1a0e668edc6fb79481fb7ee7ac8951bcc79c 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml @@ -25,10 +25,12 @@ --> <page mca="catalog/product/view"> <blocks> - <bundleViewBlock> - <class>Magento\Bundle\Test\Block\Catalog\Product\View</class> - <locator>.bundle-options-container</locator> - <strategy>css selector</strategy> - </bundleViewBlock> + <viewBlock> + <renders> + <bundle> + <class>Magento\Bundle\Test\Block\Catalog\Product\View</class> + </bundle> + </renders> + </viewBlock> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php index 3e5aed8a36ba3915030ba85e20c6cb88de182d91..5385a4baa14f22a3e142940a28bc55801c15eb7e 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php @@ -58,13 +58,13 @@ class BundleDynamicTest extends Functional //Pages & Blocks $manageProductsGrid = Factory::getPageFactory()->getCatalogProductIndex(); $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); - $productForm = $createProductPage->getForm(); + $productForm = $createProductPage->getProductForm(); //Steps $manageProductsGrid->open(); $manageProductsGrid->getGridPageActionBlock()->addProduct('bundle'); $category = $bundle->getCategories()['category']; $productForm->fill($bundle, null, $category); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verification $createProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache @@ -88,7 +88,7 @@ class BundleDynamicTest extends Functional $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** @@ -118,12 +118,10 @@ class BundleDynamicTest extends Functional $this->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), $productViewBlock->getProductPrice()); - // @TODO: add click on "Customize and Add To Cart" button and assert options count - $productOptionsBlock = $productPage->getCustomOptionsBlock(); - $actualOptions = $productOptionsBlock->getOptions(); + $actualOptions = $productPage->getViewBlock()->getOptions($product)['bundle_options']; $expectedOptions = $product->getBundleOptions(); - foreach ($actualOptions as $optionType => $actualOption) { - $this->assertContains($expectedOptions[$optionType], $actualOption); + foreach ($actualOptions as $key => $actualOption) { + $this->assertContains($expectedOptions[$key]['title'], $actualOption); } } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php index 0fb7cab4454a0510be4aabcf5e99cb8246520a2d..990347f630b2a3e4826861f736f0aa17fbb0eb35 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php @@ -61,10 +61,10 @@ class BundleFixedTest extends Functional //Steps $manageProductsGrid->open(); $manageProductsGrid->getGridPageActionBlock()->addProduct('bundle'); - $productForm = $createProductPage->getForm(); + $productForm = $createProductPage->getProductForm(); $category = $bundle->getCategories()['category']; $productForm->fill($bundle, null, $category); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verification $createProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache @@ -88,7 +88,7 @@ class BundleFixedTest extends Functional $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** @@ -115,12 +115,10 @@ class BundleFixedTest extends Functional $this->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), $productViewBlock->getProductPrice()); - // @TODO: add click on "Customize and Add To Cart" button and assert options count - $productOptionsBlock = $productPage->getCustomOptionsBlock(); - $actualOptions = $productOptionsBlock->getOptions(); + $actualOptions = $productPage->getViewBlock()->getOptions($product)['bundle_options']; $expectedOptions = $product->getBundleOptions(); - foreach ($actualOptions as $optionType => $actualOption) { - $this->assertContains($expectedOptions[$optionType], $actualOption); + foreach ($actualOptions as $key => $actualOption) { + $this->assertContains($expectedOptions[$key]['title'], $actualOption); } } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php index 3c8ca29df084bf21546c9c7e4f1bf18dc9cfafca..a5715f30f566ff301b4a340899fee3c5495bb754 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php @@ -101,8 +101,8 @@ class CreateBundleProductEntityTest extends Injectable { $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('bundle'); - $productBlockForm = $this->catalogProductNew->getForm(); + $productBlockForm = $this->catalogProductNew->getProductForm(); $productBlockForm->fill($product, null, $category); - $this->catalogProductNew->getFormAction()->save(); + $this->catalogProductNew->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php index ed3b6068a95831ccd77e503f8b966e71f700775f..dceb96430dfdb5834b1435e488f63f720c7d0b85 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php @@ -68,7 +68,7 @@ class EditBundleTest extends Functional $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $gridBlock = $productGridPage->getProductGrid(); $editProductPage = Factory::getPageFactory()->getCatalogProductEdit(); - $productForm = $editProductPage->getForm(); + $productForm = $editProductPage->getProductForm(); $cachePage = Factory::getPageFactory()->getAdminCache(); $productGridPage->open(); @@ -77,7 +77,7 @@ class EditBundleTest extends Functional 'type' => 'Bundle Product' ]); $productForm->fill($editProduct); - $editProductPage->getFormAction()->save(); + $editProductPage->getFormPageActions()->save(); //Verifying $editProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache @@ -112,7 +112,7 @@ class EditBundleTest extends Functional $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php index 9cbf6996f500b7848bbd9a15f1f20418072600f9..aebdd19677df39894f82c61124f64692474388e6 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php @@ -94,7 +94,7 @@ class UpdateBundleProductEntityTest extends Injectable $this->catalogProductIndex->open(); $filter = ['sku' => $originalProduct->getSku()]; $this->catalogProductIndex->getProductGrid()->searchAndOpen($filter); - $this->catalogProductEdit->getForm()->fill($product); - $this->catalogProductEdit->getFormAction()->save(); + $this->catalogProductEdit->getProductForm()->fill($product); + $this->catalogProductEdit->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php index 9c47b9ffe2e9812d0ea80f4b827bc3091c48a0e3..cc915d53a45accea0c4e183709aad8f0efc29e6f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php @@ -27,6 +27,7 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Composite; use Mtf\Block\Form; use Mtf\Client\Element\Locator; +use Mtf\Fixture\FixtureInterface; /** * Class Configure @@ -38,20 +39,37 @@ class Configure extends Form /** * Fill options for the product * - * @param array $productOptions + * @param FixtureInterface $product + * @return void */ - public function fillOptions($productOptions) + public function fillOptions(FixtureInterface $product) { - foreach ($productOptions as $attributeLabel => $attributeValue) { - $select = $this->_rootElement->find( - '//div[@class="product-options"]//label[text()="' . - $attributeLabel . - '"]//following-sibling::*//select', - Locator::SELECTOR_XPATH, - 'select' - ); - $select->setValue($attributeValue); + $productOptions = $product->getCheckoutData(); + if (!empty($productOptions['configurable_options'])) { + $configurableAttributesData = $product->getData('fields/configurable_attributes_data/value'); + $checkoutData = []; + + foreach ($productOptions['configurable_options'] as $optionData) { + $titleKey = $optionData['title']; + $valueKey = $optionData['value']; + + $checkoutData[] = [ + 'title' => $configurableAttributesData[$titleKey]['label']['value'], + 'value' => $configurableAttributesData[$titleKey][$valueKey]['option_label']['value'] + ]; + } + + foreach ($checkoutData as $option) { + $select = $this->_rootElement->find( + '//div[@class="product-options"]//label[text()="' . + $option['title'] . + '"]//following-sibling::*//select', + Locator::SELECTOR_XPATH, + 'select' + ); + $select->setValue($option['value']); + } + $this->_rootElement->find('.ui-dialog-buttonset button:nth-of-type(2)')->click(); } - $this->_rootElement->find('.ui-dialog-buttonset button:nth-of-type(2)')->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php index bdcbd5fa3022b5ef431254b884c7afc9a22ac8df..c9698598a47e2fa0c6ff8006ea8152b6ac2d8689 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php @@ -53,20 +53,21 @@ class AdvancedPricingTab extends Tab */ public function fillFormTab(array $fields, Element $element = null) { + $context = $element ? $element : $this->_rootElement; foreach ($fields as $fieldName => $field) { // Fill form if (isset($this->childrenForm[$fieldName]) && is_array($field['value'])) { - /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Options $optionsForm */ + /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options\AbstractOptions $optionsForm */ $optionsForm = $this->blockFactory->create( __NAMESPACE__ . '\\' . $this->childrenForm[$fieldName], - ['element' => $this->_rootElement] + ['element' => $context] ); foreach ($field['value'] as $key => $option) { ++$key; $optionsForm->fillOptions( $option, - $this->_rootElement->find( + $context->find( '#attribute-' . $fieldName . '-container tbody tr:nth-child(' . $key . ')' ) ); @@ -93,7 +94,7 @@ class AdvancedPricingTab extends Tab foreach ($fields as $fieldName => $field) { // Data collection forms if (isset($this->childrenForm[$fieldName]) && is_array($field['value'])) { - /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Options $optionsForm */ + /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options\AbstractOptions $optionsForm */ $optionsForm = $this->blockFactory->create( __NAMESPACE__ . '\\' . $this->childrenForm[$fieldName], ['element' => $this->_rootElement] diff --git a/lib/internal/Magento/Framework/Module/UpdaterInterface.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ParentCategoryIds.php similarity index 74% rename from lib/internal/Magento/Framework/Module/UpdaterInterface.php rename to dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ParentCategoryIds.php index 849cf67d898471c82f7105ae6ace412c2daabb4e..8e0f25dcf77eb5f51c0b0717c1eed12ceb442eb4 100644 --- a/lib/internal/Magento/Framework/Module/UpdaterInterface.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ParentCategoryIds.php @@ -1,7 +1,5 @@ <?php /** - * DB updater interface - * * Magento * * NOTICE OF LICENSE @@ -23,21 +21,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\Module; -interface UpdaterInterface -{ - /** - * Apply database scheme updates whenever needed - * - * @return void - */ - public function updateScheme(); +namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails; +/** + * Class ParentCategoryIds + * Typified element class for parent category element + */ +class ParentCategoryIds extends CategoryIds +{ /** - * Apply database data updates whenever needed + * Selector suggest input * - * @return void + * @var string */ - public function updateData(); + protected $suggest = '#new_category_parent-suggest'; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php deleted file mode 100755 index 074465b0fa54378f41becf625d4408c496a02546..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php +++ /dev/null @@ -1,141 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Block\Block; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; - -/** - * Class Attribute - * Attribute block in Variation section - * - */ -class Attribute extends Block -{ - /** - * Attribute option pricing value - * - * @var string - */ - protected $pricingValue = '[name*=pricing_value]'; - - /** - * Attribute option price type button - * - * @var string - */ - protected $priceTypeButton = '[data-toggle=dropdown]'; - - /** - * Attribute option price type value - * - * @var string - */ - protected $priceTypeValue = '//*[@data-role="dropdown-menu"]'; - - /** - * Attribute option Include checkbox - * - * @var string - */ - protected $include = '[data-column=include ] [type=checkbox]'; - - /** - * Attribute option Label - * - * @var string - */ - protected $labelValue = 'input[class=required-entry][name*=value]'; - - /** - * Attribute option row - * - * @var string - */ - protected $attributeRow = '//*[@data-role="options"]/tr[%row%]'; - - /** - * Add option selector - * - * @var string - */ - protected $addOption = '[data-action="add-option"]'; - - /** - * Fill in data to attribute options - * - * @param array $fields - */ - public function fillAttributeOptions(array $fields) - { - $row = 0; - foreach ($fields as $field) { - if (isset($field['option_label']['value'])) { - $optionRow = $this->getOptionRow($field['option_label']['value']); - if (!$optionRow->isVisible()) { - $this->_rootElement->find($this->addOption)->click(); - $optionRow = $this->getOptionNewRow($row); - if (isset($field['option_label']['value'])) { - $optionRow->find($this->labelValue)->setValue($field['option_label']['value']); - } - } - if (isset($field['pricing_value']['value'])) { - $optionRow->find($this->pricingValue, Locator::SELECTOR_CSS) - ->setValue($field['pricing_value']['value']); - } - if (isset($field['is_percent']['value']) && $field['is_percent']['value'] == 'Yes') { - $optionRow->find($this->priceTypeButton, Locator::SELECTOR_CSS)->click(); - $optionRow->find($this->priceTypeValue . '//a[text()="%"]', Locator::SELECTOR_XPATH)->click(); - } - $optionRow->find($this->include, Locator::SELECTOR_CSS, 'checkbox') - ->setValue($field['include']['value']); - } - ++$row; - } - } - - /** - * Get option row - * - * @param string $optionLabel - * @return Element - */ - protected function getOptionRow($optionLabel) - { - return $this->_rootElement->find('//tr[td="' . $optionLabel . '"]', Locator::SELECTOR_XPATH); - } - - /** - * Get option new row - * - * @param int $row - * @return Element - */ - protected function getOptionNewRow($row) - { - return $this->_rootElement->find(str_replace('%row%', $row, $this->attributeRow), Locator::SELECTOR_XPATH); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php deleted file mode 100644 index aefe47026b037ece7c9a025324ef158135765574..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php +++ /dev/null @@ -1,212 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Client\Element; -use Mtf\Factory\Factory; -use Mtf\Client\Element\Locator; -use Magento\Backend\Test\Block\Widget\Tab; - -/** - * Class Variations - * Adminhtml catalog super product configurable tab - * - */ -class Config extends Tab -{ - /** - * 'Generate Variations' button - * - * @var string - */ - protected $generateVariations = '[data-ui-id=product-variations-generator-generate]'; - - /** - * Product variations matrix block - * - * @var string - */ - protected $matrixBlock = '[data-role=product-variations-matrix] table'; - - /** - * Product attribute block selector by attribute name - * - * @var string - */ - protected $attribute = '//div[*/*/span="%s"]'; - - /** - * Magento loader - * - * @var string - */ - protected $loader = './ancestor::body//*[contains(@data-role,"loader")]'; - - /** - * Attribute Opened - * - * @var string - */ - protected $attributeOpen = './/*[@class = "title active"]/span[text()="%attributeLabel%"]'; - - /** - * Attribute tab - * - * @var string - */ - protected $attributeTab = '//*[@data-role="configurable-attribute"]//*[text()="%attributeTab%"]'; - - /** - * Get attribute block - * - * @param string $attributeName - * @return \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Attribute - */ - protected function getAttributeBlock($attributeName) - { - $attributeSelector = sprintf($this->attribute, $attributeName); - $this->waitForElementVisible($attributeSelector, Locator::SELECTOR_XPATH); - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlProductEditTabSuperAttribute( - $this->_rootElement->find($attributeSelector, Locator::SELECTOR_XPATH) - ); - } - - /** - * Get product variations matrix block - * - * @return \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix - */ - protected function getMatrixBlock() - { - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlProductEditTabSuperConfigMatrix( - $this->_rootElement->find($this->matrixBlock, Locator::SELECTOR_CSS) - ); - } - - /** - * Press 'Generate Variations' button - * - * @return void - */ - public function generateVariations() - { - $browser = $this->_rootElement; - $browser->find($this->generateVariations, Locator::SELECTOR_CSS)->click(); - $loaderSelector = $this->loader; - $browser->waitUntil( - function () use ($browser, $loaderSelector) { - $loaderElement = $browser->find($loaderSelector, Locator::SELECTOR_XPATH); - return $loaderElement->isVisible() == false ? true : null; - } - ); - } - - /** - * Fill variations fieldset - * - * @param array $fields - * @param Element|null $element - * @return $this - */ - public function fillFormTab(array $fields, Element $element = null) - { - if (!isset($fields['configurable_attributes_data'])) { - return $this; - } - $attributes = $fields['configurable_attributes_data']['value']; - foreach ($attributes as $attribute) { - $this->selectAttribute($attribute['label']['value']); - } - $this->fillAttributeOptions($attributes); - $this->generateVariations(); - $this->fillVariationsMatrix($fields['variations-matrix']['value']); - - return $this; - } - - /** - * Fill variations matrix - * - * @param array $fields - * @return void - */ - public function fillVariationsMatrix(array $fields) - { - $variations = []; - foreach ($fields as $key => $field) { - foreach ($field['value'] as $fieldName => $value) { - $variations[$key][$fieldName] = $value['value']; - } - foreach ($field['configurable_attribute'] as $options) { - $variations[$key]['options_names'][] = $options['attribute_option']; - } - } - - $this->getMatrixBlock()->fillVariation($variations); - } - - /** - * Fill attribute options - * - * @param array $attributes - * @return void - */ - public function fillAttributeOptions(array $attributes) - { - foreach ($attributes as $attribute) { - $this->getAttributeBlock($attribute['label']['value'])->fillAttributeOptions($attribute); - } - } - - /** - * Select attribute for variations - * - * @param string $attributeName - * @return void - */ - private function selectAttribute($attributeName) - { - // TODO should be removed after suggest widget implementation as typified element - $attributeFieldSet = $this->_rootElement - ->find(str_replace('%attributeLabel%', $attributeName, $this->attributeOpen), Locator::SELECTOR_XPATH); - $attributeVisible = $this->_rootElement - ->find(str_replace('%attributeTab%', $attributeName, $this->attributeTab), Locator::SELECTOR_XPATH); - if ($attributeVisible->isVisible()) { - if (!$attributeFieldSet->isVisible()) { - $attributeVisible->click(); - } - } else { - $this->_rootElement->find('#configurable-attribute-selector')->setValue($attributeName); - $attributeListLocation = '#variations-search-field .mage-suggest-dropdown'; - $this->waitForElementVisible($attributeListLocation, Locator::SELECTOR_CSS); - $attribute = $this->_rootElement->find( - "//div[@class='mage-suggest-dropdown']//a[text()='$attributeName']", - Locator::SELECTOR_XPATH - ); - if ($attribute->isVisible()) { - $attribute->click(); - } - } - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php deleted file mode 100644 index 2aa9fdefb67b7087d49b24bf93510b981f6338cc..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config; - -use Mtf\Block\Form; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; - -/** - * Class Matrix - * Product variations matrix block - */ -class Matrix extends Form -{ - /** - * Fill qty to current variations - * - * @param array $variations - * @return void - */ - public function fillVariation(array $variations) - { - foreach ($variations as $variation) { - $variationRow = $this->getVariationRow($variation['options_names']); - foreach ($variation as $key => $value) { - if (!empty($this->mapping[$key])) { - $this->_rootElement->find( - $variationRow . $this->mapping[$key]['selector'], - Locator::SELECTOR_XPATH, - isset($this->mapping[$key]['input']) ? $this->mapping[$key]['input'] : null - )->setValue($value); - } - } - } - } - - /** - * Define row that clarifies which line in Current Variations grid will be used - * - * @param array $variationData - * @return string - */ - private function getVariationRow(array $variationData) - { - $options = array(); - foreach ($variationData as $attributeData) { - $options[] = 'td[text()="' . $attributeData . '"]'; - } - - return '//tr[' . implode(' and ', $options) . ']'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Search.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Search.php deleted file mode 100644 index 00a7d7297c521758210c1534713976fae99b5b03..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Search.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Variations; - -use Mtf\Client\Element; -use Mtf\Client\Driver\Selenium\Element\SuggestElement; -use Magento\Catalog\Test\Fixture\CatalogProductAttribute; - -/** - * Class FormAttributeSearch - * Form Attribute Search on Product page - */ -class Search extends SuggestElement -{ - /** - * Attribute Set locator - * - * @var string - */ - protected $value = '.action-toggle > span'; - - /** - * Attribute Set button - * - * @var string - */ - protected $actionToggle = '.action-toggle'; - - /** - * Search attribute result locator - * - * @var string - */ - protected $searchResult = '.mage-suggest-dropdown .ui-corner-all'; - - /** - * Set value - * - * @param string $value - * @return void - */ - public function setValue($value) - { - $this->find($this->actionToggle)->click(); - parent::setValue($value); - } - - /** - * Get value - * - * @return string - */ - public function getValue() - { - return $this->find($this->value)->getText(); - } - - /** - * Checking not exist configurable attribute in search result - * - * @param CatalogProductAttribute $productAttribute - * @return bool - */ - public function isExistAttributeInSearchResult(CatalogProductAttribute $productAttribute) - { - $attribute = $productAttribute->getFrontendLabel(); - $searchResult = $this->find($this->searchResult); - - $this->find($this->suggest)->setValue($attribute); - if (!$searchResult->isVisible()) { - return false; - } - if ($searchResult->getText() == $attribute) { - return true; - } - return false; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php index b5fe622c14b4eba0372390a7201eeaeb5c5b65c0..3dbd522c6aa08bd09b4c63947844a6eba5946f90 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php @@ -72,18 +72,27 @@ class FormPageActions extends ParentFormPageActions protected $saveButton = '#save-split-button-button'; /** - * Save product form with window confirmation + * Click on "Save" button * - * @param BackendPage $page - * @param FixtureInterface $product + * @param FixtureInterface|null $product [optional] * @return void */ - public function saveProduct(BackendPage $page, FixtureInterface $product) + public function save(FixtureInterface $product = null) { - parent::save(); - /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\AffectedAttributeSetForm $affectedAttributeSetForm */ - $affectedAttributeSetForm = $page->getAffectedAttributeSetForm(); - $affectedAttributeSetForm->fill($product)->confirm(); + $typeId = null; + + if ($product) { + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + } + + if ($this->hasRender($typeId)) { + $this->callRender($typeId, 'save', ['product' => $product]); + } else { + $this->_rootElement->find($this->saveButton)->click(); + $this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH); + $this->waitForElementNotVisible($this->loaderOld, Locator::SELECTOR_XPATH); + } } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php index f2ab98df6df055c71d864c3a6bcfd542068df5aa..b3e903278f156904b0dd6f0a219c0c0e305ceb1e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php @@ -24,12 +24,14 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product; -use Magento\Backend\Test\Block\Widget\FormTabs; use Mtf\Client\Element; +use Mtf\Fixture\DataFixture; +use Mtf\Client\Element\Locator; +use Magento\Backend\Test\Block\Widget\FormTabs; use Mtf\Fixture\FixtureInterface; use Mtf\Fixture\InjectableFixture; use Magento\Catalog\Test\Fixture\Product; -use Mtf\Client\Element\Locator; +use Magento\Backend\Test\Block\Widget\Tab; use Magento\Catalog\Test\Fixture\CatalogCategory; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; @@ -69,25 +71,46 @@ class ProductForm extends FormTabs protected $advancedSettingContent = '#product_info_tabs-advanced [data-role="content"]'; /** - * Variations Attribute Search locator the Product page + * Custom Tab locator * * @var string */ - protected $variationsAttributeSearch = '#variations-search-field'; + protected $customTab = './/*/a[contains(@id,"product_info_tabs_%s")]'; /** - * Variations Tab locator the Product page + * Button "New Category" * * @var string */ - protected $variationsTab = '#product_info_tabs_super_config_content .title'; + protected $buttonNewCategory = '#add_category_button'; /** - * Custom Tab locator + * Dialog box "Create Category" * * @var string */ - protected $customTab = './/*/a[contains(@id,"product_info_tabs_%s")]'; + protected $createCategoryDialog = './/ancestor::body//*[contains(@class,"mage-new-category-dialog")]'; + + /** + * "Parent Category" block on dialog box + * + * @var string + */ + protected $parentCategoryBlock = '//*[contains(@class,"field-new_category_parent")]'; + + /** + * Field "Category Name" on dialog box + * + * @var string + */ + protected $fieldNewCategoryName = '//input[@id="new_category_name"]'; + + /** + * Button "Create Category" on dialog box + * + * @var string + */ + protected $createCategoryButton = '//button[contains(@class,"action-create")]'; /** * Fill the product form @@ -99,16 +122,34 @@ class ProductForm extends FormTabs */ public function fill(FixtureInterface $product, Element $element = null, FixtureInterface $category = null) { - $tabs = $this->getFieldsByTabs($product); + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + + if ($this->hasRender($typeId)) { + $renderArguments = [ + 'product' => $product, + 'element' => $element, + 'category' => $category + ]; + $this->callRender($typeId, 'fill', $renderArguments); + } else { + $tabs = $this->getFieldsByTabs($product); + + if (null === $category && $product instanceof DataFixture) { + $categories = $product->getCategories(); + $category = reset($categories); + } + if ($category) { + $tabs['product-details']['category_ids']['value'] = ($category instanceof InjectableFixture ) + ? $category->getName() + : $category->getCategoryName(); + } - if ($category) { - $tabs['product-details']['category_ids']['value'] = ($category instanceof InjectableFixture ) - ? $category->getName() - : $category->getCategoryName(); + $this->showAdvancedSettings(); + $this->fillTabs($tabs, $element); } - $this->showAdvancedSettings(); - return parent::fillTabs($tabs, $element); + return $this; } /** @@ -137,6 +178,19 @@ class ProductForm extends FormTabs } } + /** + * Open tab + * + * @param string $tabName + * @return Tab + */ + public function openTab($tabName) + { + $this->showAdvancedSettings(); + + return parent::openTab($tabName); + } + /** * Save new category * @@ -145,15 +199,19 @@ class ProductForm extends FormTabs */ public function addNewCategory(Product $fixture) { + $this->openTab('product-details'); $this->openNewCategoryDialog(); - $this->_rootElement->find('input#new_category_name', Locator::SELECTOR_CSS) - ->setValue($fixture->getNewCategoryName()); + $this->_rootElement->find( + $this->createCategoryDialog . $this->fieldNewCategoryName, + Locator::SELECTOR_XPATH + )->setValue($fixture->getNewCategoryName()); $this->clearCategorySelect(); $this->selectParentCategory(); - $this->_rootElement->find('div.ui-dialog-buttonset button.action-create')->click(); - $this->waitForElementNotVisible('div.ui-dialog-buttonset button.action-create'); + $buttonCreateCategory = $this->createCategoryDialog . $this->createCategoryButton; + $this->_rootElement->find($buttonCreateCategory, Locator::SELECTOR_XPATH)->click(); + $this->waitForElementNotVisible($buttonCreateCategory, Locator::SELECTOR_XPATH); } /** @@ -163,12 +221,11 @@ class ProductForm extends FormTabs */ protected function selectParentCategory() { - // TODO should be removed after suggest widget implementation as typified element - $this->fillCategoryField( - 'Default Category', - 'new_category_parent-suggest', - '//*[@id="new_category_form_fieldset"]' - ); + $this->_rootElement->find( + $this->createCategoryDialog . $this->parentCategoryBlock, + Locator::SELECTOR_XPATH, + '\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails\ParentCategoryIds' + )->setValue('Default Category'); } /** @@ -191,8 +248,8 @@ class ProductForm extends FormTabs */ protected function openNewCategoryDialog() { - $this->_rootElement->find('#add_category_button', Locator::SELECTOR_CSS)->click(); - $this->waitForElementVisible('input#new_category_name'); + $this->_rootElement->find($this->buttonNewCategory)->click(); + $this->waitForElementVisible($this->createCategoryDialog, Locator::SELECTOR_XPATH); } /** @@ -226,33 +283,6 @@ class ProductForm extends FormTabs )->isExistAttributeInSearchResult($productAttribute); } - /** - * Call method that checking present attribute in search result - * - * @param CatalogProductAttribute $productAttribute - * @return bool - */ - public function checkAttributeInVariationsSearchAttributeForm(CatalogProductAttribute $productAttribute) - { - return $this->_rootElement->find( - $this->variationsAttributeSearch, - Locator::SELECTOR_CSS, - 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Variations\Search' - )->isExistAttributeInSearchResult($productAttribute); - } - - /** - * Open Variations tab on Product form - * - * @return void - */ - public function openVariationsTab() - { - if (!$this->_rootElement->find($this->variationsAttributeSearch, Locator::SELECTOR_CSS)->isVisible()) { - $this->_rootElement->find($this->variationsTab, Locator::SELECTOR_CSS)->click(); - } - } - /** * Check tab visibility on Product form * @@ -262,8 +292,9 @@ class ProductForm extends FormTabs public function isTabVisible($tabName) { $tabName = strtolower($tabName); - - return $this->_rootElement->find(sprintf($this->customTab, $tabName), Locator::SELECTOR_XPATH)->isVisible(); + $selector = sprintf($this->customTab, $tabName); + $this->waitForElementVisible($selector, Locator::SELECTOR_XPATH); + return $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->isVisible(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml index 1d5f379a164bbe378fd6899b6de37d12aa7d8678..e54210bf60065f98c811d3c7ff8b14b4abbefee8 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml @@ -82,9 +82,16 @@ <strategy>css selector</strategy> <wrapper>product</wrapper> <fields> - <special_price> - <selector>#special_price</selector> - </special_price> + <special_price /> + <group_price> + <input>select</input> + </group_price> + <tier_price> + <input>select</input> + </tier_price> + <msrp_enabled> + <input>select</input> + </msrp_enabled> </fields> </advanced-pricing> <advanced-inventory> @@ -139,11 +146,6 @@ </use_config_gift_message_available> </fields> </autosettings> - <variations> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - </variations> <grouped-product> <class>\Magento\Catalog\Test\Block\Product\Grouped\AssociatedProducts</class> <selector>#product_info_tabs_product-details</selector> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.php deleted file mode 100644 index bc56affda4c873bddefb2c61b499220ca442c581..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Catalog\Test\Block\Backend\Product\Attribute; - -use Mtf\Fixture\FixtureInterface; -use Mtf\Client\Element; -use Magento\Backend\Test\Block\Widget\Form; - -/** - * Product attribute edit page - * - */ -class Edit extends Form -{ - /** - * Frontend properties selector - * - * @var string - */ - protected $frontendProperties = '#front_fieldset-wrapper .title'; - - /** - * Save attribute selector - * - * @var string - */ - protected $saveAttribute = '[data-ui-id="attribute-edit-content-save-button"]'; - - /** - * 'Add new option' button selector - * - * @var string - */ - protected $addNewOption = '#add_new_option_button'; - - /** - * Attribute option row - * - * @var string - */ - protected $optionRow = '//*[@id="manage-options-panel"]//tbody//tr[%row%]'; - - /** - * Open frontend properties - */ - public function openFrontendProperties() - { - $this->_rootElement->find($this->frontendProperties)->click(); - } - - /** - * Save attribute - */ - public function saveAttribute() - { - $this->_rootElement->find($this->saveAttribute)->click(); - } - - /** - * Fill form with attribute options - * - * @param FixtureInterface $fixture - * @param Element|null $element - * @return $this - */ - public function fill(FixtureInterface $fixture, Element $element = null) - { - parent::fill($fixture, $element); - $this->fillOptions($fixture); - - return $this; - } - - /** - * Fill attribute options - * - * @param FixtureInterface $fixture - */ - protected function fillOptions(FixtureInterface $fixture) - { - /** @var $fixture \Magento\Catalog\Test\Fixture\ProductAttribute */ - $options = $fixture->getOptions(); - - $row = 1; - foreach ($options as $option) { - $this->_rootElement->find($this->addNewOption)->click(); - // TODO: implement filling for any number of stores - $this->_rootElement->find( - str_replace('%row%', $row, $this->optionRow) . '/td[2]/input', - Element\Locator::SELECTOR_XPATH, - 'checkbox' - )->setValue($option['default']['value']); - $this->_rootElement->find( - str_replace('%row%', $row, $this->optionRow) . '/td[3]/input', - Element\Locator::SELECTOR_XPATH - )->setValue($option['label']['value']); - ++$row; - } - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.xml deleted file mode 100644 index d604e00a11d312c9fb974fcef1ebd1d50a88644b..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<mapping strict="0"> - <fields> - <attribute_label> - <selector>[name='frontend_label[0]']</selector> - </attribute_label> - <frontend_input> - <input>select</input> - </frontend_input> - <is_searchable> - <input>select</input> - </is_searchable> - <is_visible_in_advanced_search> - <input>select</input> - </is_visible_in_advanced_search> - <is_comparable> - <input>select</input> - </is_comparable> - <is_filterable> - <input>select</input> - </is_filterable> - <is_visible_on_front> - <input>select</input> - </is_visible_on_front> - <is_filterable_in_search> - <input>select</input> - </is_filterable_in_search> - </fields> -</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.php deleted file mode 100644 index d9d81ec8cc94127d8b60800d0c0b3ec9cab92ab4..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.php +++ /dev/null @@ -1,380 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Catalog\Test\Block\Backend; - -use Mtf\Client\Element; -use Mtf\Factory\Factory; -use Mtf\Client\Element\Locator; -use Mtf\Fixture\FixtureInterface; -use Magento\Catalog\Test\Fixture\Product; -use Magento\Catalog\Test\Fixture\Category; -use Magento\Backend\Test\Block\Widget\Tab; -use Magento\Backend\Test\Block\Widget\FormTabs; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; - -/** - * Class ProductForm - * Product creation form - */ -class ProductForm extends FormTabs -{ - /** - * 'Save' split button - * - * @var string - */ - protected $saveButton = '#save-split-button-button'; - - /** - * Variations tab selector - * - * @var string - */ - protected $variationsTab = '[data-ui-id="product-tabs-tab-content-super-config"] .title'; - - /** - * Variations wrapper selector - * - * @var string - */ - protected $variationsWrapper = '[data-ui-id="product-tabs-tab-content-super-config"]'; - - /** - * New variation set button selector - * - * @var string - */ - protected $newVariationSet = '[data-ui-id="admin-product-edit-tab-super-config-grid-container-add-attribute"]'; - - /** - * Choose affected attribute set dialog popup window - * - * @var string - */ - protected $affectedAttributeSet = "//div[div/@data-id='affected-attribute-set-selector']"; - - /** - * Category name selector - * - * @var string - */ - protected $categoryName = '//*[contains(@class, "mage-suggest-choice")]/*[text()="%categoryName%"]'; - - /** - * 'Advanced Settings' tab - * - * @var string - */ - protected $advancedSettings = '#product_info_tabs-advanced [data-role="trigger"]'; - - /** - * Advanced tab list - * - * @var string - */ - protected $advancedTabList = '#product_info_tabs-advanced[role="tablist"]'; - - /** - * Advanced tab panel - * - * @var string - */ - protected $advancedTabPanel = '[role="tablist"] [role="tabpanel"][aria-expanded="true"]:not("overflow")'; - - /** - * Selector popups 'New category' - * - * @var string - */ - protected $newCategoryPopup = "./ancestor::body//div[div[contains(@id,'new-category')]]"; - - /** - * Category fixture - * - * @var Category - */ - protected $category; - - /** - * Get choose affected attribute set dialog popup window - * - * @return \Magento\Catalog\Test\Block\Product\Configurable\AffectedAttributeSet - */ - protected function getAffectedAttributeSetBlock() - { - return Factory::getBlockFactory()->getMagentoCatalogProductConfigurableAffectedAttributeSet( - $this->_rootElement->find($this->affectedAttributeSet, Locator::SELECTOR_XPATH) - ); - } - - /** - * Set category - * - * @param Category $category - * @return void - */ - public function setCategory(Category $category) - { - $this->category = $category; - } - - /** - * Fill the product form - * - * @param FixtureInterface $fixture - * @param Element $element - * @return $this - */ - public function fill(FixtureInterface $fixture, Element $element = null) - { - $this->fillCategory($fixture); - return parent::fill($fixture); - } - - /** - * Select category - * - * @param FixtureInterface $fixture - * @return void - */ - protected function fillCategory(FixtureInterface $fixture) - { - // TODO should be removed after suggest widget implementation as typified element - $categoryName = $this->category - ? $this->category->getCategoryName() - : ($fixture->getCategoryName() ? $fixture->getCategoryName() : ''); - - if (!$categoryName) { - return; - } - $category = $this->_rootElement->find( - str_replace('%categoryName%', $categoryName, $this->categoryName), - Locator::SELECTOR_XPATH - ); - if (!$category->isVisible()) { - $this->fillCategoryField( - $categoryName, - 'category_ids-suggest', - '//*[@id="attribute-category_ids-container"]' - ); - } - } - - /** - * Save product - * - * @param FixtureInterface $fixture - * @return \Magento\Backend\Test\Block\Widget\Form|void - */ - public function save(FixtureInterface $fixture = null) - { - parent::save($fixture); - if ($this->getAffectedAttributeSetBlock()->isVisible()) { - $this->getAffectedAttributeSetBlock()->chooseAttributeSet($fixture); - } - } - - /** - * Save new category - * - * @param Product $fixture - * @return void - */ - public function addNewCategory(Product $fixture) - { - $this->openNewCategoryDialog(); - $popupElement = $this->_rootElement->find($this->newCategoryPopup, Locator::SELECTOR_XPATH); - - if ($popupElement->isVisible()) { - $popupElement->find('input#new_category_name', Locator::SELECTOR_CSS) - ->setValue($fixture->getNewCategoryName()); - $this->clearCategorySelect($popupElement); - $this->selectParentCategory($popupElement); - $popupElement->find('div.ui-dialog-buttonset button.action-create')->click(); - $this->waitForElementNotVisible('div.ui-dialog-buttonset button.action-create'); - } - - } - - /** - * Get variations block - * - * @return \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config - */ - protected function getVariationsBlock() - { - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlProductEditTabSuperConfig( - $this->_rootElement->find($this->variationsWrapper) - ); - } - - /** - * Fill product variations - * - * @param ConfigurableProduct $variations - * @return void - */ - public function fillVariations(ConfigurableProduct $variations) - { - $variationsBlock = $this->getVariationsBlock(); - $variationsBlock->fillAttributeOptions($variations->getConfigurableAttributes()); - $variationsBlock->generateVariations(); - $variationsBlock->fillVariationsMatrix($variations->getVariationsMatrix()); - } - - /** - * Open variations tab - * - * @return void - */ - public function openVariationsTab() - { - $this->_rootElement->find($this->variationsTab)->click(); - } - - /** - * Click on 'Create New Variation Set' button - * - * @return void - */ - public function clickCreateNewVariationSet() - { - $this->_rootElement->find($this->newVariationSet)->click(); - } - - /** - * Clear category field - * - * @param Element $element - * @return void - */ - public function clearCategorySelect(Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - $selectedCategory = 'li.mage-suggest-choice span.mage-suggest-choice-close'; - if ($element->find($selectedCategory)->isVisible()) { - $element->find($selectedCategory)->click(); - } - } - - /** - * Select parent category for new one - * - * @param Element $element - * @return void - */ - protected function selectParentCategory(Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - // TODO should be removed after suggest widget implementation as typified element - $this->fillCategoryField( - 'Default Category', - 'new_category_parent-suggest', - '//*[@id="new_category_form_fieldset"]', - $element - ); - } - - /** - * Fills select category field - * - * @param string $name - * @param string $elementId - * @param string $parentLocation - * @param Element $element - * @return void - */ - protected function fillCategoryField($name, $elementId, $parentLocation, Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - // TODO should be removed after suggest widget implementation as typified element - $element->find($elementId, Locator::SELECTOR_ID)->setValue($name); - //*[@id="attribute-category_ids-container"] //*[@id="new_category_form_fieldset"] - $categoryListLocation = $parentLocation . '//div[@class="mage-suggest-dropdown"]'; // - $this->waitForElementVisible($categoryListLocation, Locator::SELECTOR_XPATH); - $categoryLocation = $parentLocation . '//li[contains(@data-suggest-option, \'"label":"' . $name . '",\')]//a'; - $element->find($categoryLocation, Locator::SELECTOR_XPATH)->click(); - } - - /** - * Open new category dialog - * - * @return void - */ - protected function openNewCategoryDialog() - { - $this->_rootElement->find('#add_category_button', Locator::SELECTOR_CSS)->click(); - $this->waitForElementVisible($this->newCategoryPopup, Locator::SELECTOR_XPATH); - } - - /** - * Open tab - * - * @param string $tabName - * @return Tab|bool - */ - public function openTab($tabName) - { - $rootElement = $this->_rootElement; - $selector = $this->tabs[$tabName]['selector']; - $strategy = isset($this->tabs[$tabName]['strategy']) - ? $this->tabs[$tabName]['strategy'] - : Locator::SELECTOR_CSS; - $advancedTabList = $this->advancedTabList; - $tab = $this->_rootElement->find($selector, $strategy); - $advancedSettings = $this->_rootElement->find($this->advancedSettings); - - // Wait until all tabs will load - $this->_rootElement->waitUntil( - function () use ($rootElement, $advancedTabList) { - return $rootElement->find($advancedTabList)->isVisible(); - } - ); - - if ($tab->isVisible()) { - $tab->click(); - } elseif ($advancedSettings->isVisible()) { - $advancedSettings->click(); - // Wait for open tab animation - $tabPanel = $this->advancedTabPanel; - $this->_rootElement->waitUntil( - function () use ($rootElement, $tabPanel) { - return $rootElement->find($tabPanel)->isVisible(); - } - ); - // Wait until needed tab will appear - $this->_rootElement->waitUntil( - function () use ($rootElement, $selector, $strategy) { - return $rootElement->find($selector, $strategy)->isVisible(); - } - ); - $tab->click(); - } else { - return false; - } - - return $this; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.xml deleted file mode 100644 index 8e7c8113ab29e46632ec0e49dc909ee001958d91..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.xml +++ /dev/null @@ -1,138 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<tabs> - <product-details> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <tax_class_id> - <input>select</input> - </tax_class_id> - <is_virtual> - <input>checkbox</input> - </is_virtual> - <qty> - <selector>[name='product[quantity_and_stock_status][qty]']</selector> - </qty> - <quantity_and_stock_status> - <selector>[name='product[quantity_and_stock_status][is_in_stock]']</selector> - <input>select</input> - </quantity_and_stock_status> - </fields> - </product-details> - <websites> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_websites</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <product_website_1> - <selector>[name='product[website_ids][]']</selector> - <input>checkbox</input> - </product_website_1> - </fields> - </websites> - <advanced-pricing> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\AdvancedPricingTab</class> - <selector>#product_info_tabs_advanced-pricing</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <special_price> - <selector>[name='product[special_price]']</selector> - </special_price> - <group_price> - <input>select</input> - </group_price> - <tier_price> - <input>select</input> - </tier_price> - </fields> - </advanced-pricing> - <advanced-inventory> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_advanced-inventory</selector> - <strategy>css selector</strategy> - <wrapper>product[stock_data]</wrapper> - <fields> - <inventory_manage_stock> - <selector>[name='product[stock_data][manage_stock]']</selector> - <input>select</input> - </inventory_manage_stock> - <inventory_qty> - <selector>[name='product[stock_data][qty]']</selector> - </inventory_qty> - </fields> - </advanced-inventory> - <autosettings> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_autosettings</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <visibility> - <input>select</input> - </visibility> - </fields> - </autosettings> - <variations> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - </variations> - <grouped-product> - <class>\Magento\Catalog\Test\Block\Product\Grouped\AssociatedProducts</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - </grouped-product> - <customer-options> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options</class> - <selector>#product_info_tabs_customer_options</selector> - <strategy>css selector</strategy> - <fields> - <custom_options> - <input>select</input> - </custom_options> - </fields> - </customer-options> - <related-products> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Related</class> - <selector>#product_info_tabs_related</selector> - <strategy>css selector</strategy> - </related-products> - <upsells> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Upsell</class> - <selector>#product_info_tabs_upsell</selector> - <strategy>css selector</strategy> - </upsells> - <crosssells> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Crosssell</class> - <selector>#product_info_tabs_crosssell</selector> - <strategy>css selector</strategy> - </crosssells> -</tabs> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php index 98cfd200d72d1f45ba87d06e3c9d543cf9b7ba8b..e1a681048ccdb8525fb431369390b7d6e647f81c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php @@ -53,7 +53,7 @@ class ListCompare extends Block * * @var string */ - protected $nameSelector = './/*[contains(@class, "product name")]/a'; + protected $nameSelector = './/*[contains(@class, "product-item-name")]/a'; /** * Selector for search product via name diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Configurable/AffectedAttributeSet.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Configurable/AffectedAttributeSet.php deleted file mode 100644 index a1be12d13cf4c9b90e61441df1f2faa8df9a283e..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Configurable/AffectedAttributeSet.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Catalog\Test\Block\Product\Configurable; - -use Mtf\Block\Block; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; - -/** - * Class AffectedAttributeSet - * Choose affected attribute set dialog popup window - * - */ -class AffectedAttributeSet extends Block -{ - /** - * Create new attribute set based on default - * - * @var string - */ - protected $affectedAttributeSet = '[name=affected-attribute-set][value=new]'; - - /** - * New attribute set name - * - * @var string - */ - protected $attributeSetName = '[name=new-attribute-set-name]'; - - /** - * 'Confirm' button - * - * @var string - */ - protected $confirmButton = '[id*=confirm-button]'; - - /** - * Choose affected attribute set - * - * @param ConfigurableProduct $fixture - */ - public function chooseAttributeSet(ConfigurableProduct $fixture) - { - $attributeSetName = $fixture->getAffectedAttributeSet(); - if ($attributeSetName) { - $this->_rootElement->find($this->affectedAttributeSet)->click(); - $this->_rootElement->find($this->attributeSetName)->setValue($attributeSetName); - } - $this->_rootElement->find($this->confirmButton)->click(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/BottomToolbar.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/BottomToolbar.php new file mode 100644 index 0000000000000000000000000000000000000000..ceff3348c3dc61a5a847dbae2f1f9a58bebbf079 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/BottomToolbar.php @@ -0,0 +1,57 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Test\Block\Product\ProductList; + +use Mtf\Block\Block; + +/** + * Class BottomToolbar + * Bottom toolbar the product list page + */ +class BottomToolbar extends Block +{ + /** + * Selector next active element + * + * @var string + */ + protected $nextPageSelector = '.item.current + .item a'; + + /** + * Go to the next page + * + * @return bool + */ + public function nextPage() + { + $nextPageItem = $this->_rootElement->find($this->nextPageSelector); + + if ($nextPageItem->isVisible()) { + $nextPageItem->click(); + return true; + } + return false; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Toolbar.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php similarity index 74% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Toolbar.php rename to dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php index ff9eeaae543fa43525867cb0e8e05809e6c5b872..0bf728d67d6645a14b065cd976ab441fc6162f2c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Toolbar.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php @@ -27,18 +27,11 @@ namespace Magento\Catalog\Test\Block\Product\ProductList; use Mtf\Block\Block; /** - * Class Toolbar - * Toolbar the product list page + * Class TopToolbar + * Top toolbar the product list page */ -class Toolbar extends Block +class TopToolbar extends Block { - /** - * Selector next active element - * - * @var string - */ - protected $nextPageSelector = '.item.current + .item a'; - /** * Selector for "sort by" element * @@ -46,22 +39,6 @@ class Toolbar extends Block */ protected $sorter = '#sorter'; - /** - * Go to the next page - * - * @return bool - */ - public function nextPage() - { - $nextPageItem = $this->_rootElement->find($this->nextPageSelector); - if ($nextPageItem->isVisible()) { - $nextPageItem->click(); - return true; - } - - return false; - } - /** * Get method of sorting product * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php index 8ff2ae1ef2301fe545a332b97dcaa6684656e1d5..de14d5daef584f2b374142ff9bbe522a60fd10e7 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php @@ -25,11 +25,11 @@ namespace Magento\Catalog\Test\Block\Product; use Mtf\Block\Block; -use Mtf\Factory\Factory; use Mtf\Client\Element\Locator; use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\Catalog\Test\Fixture\GroupedProduct; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; /** * Class View @@ -117,13 +117,6 @@ class View extends Block */ protected $productPrice = '.price-box .price'; - /** - * Bundle options block - * - * @var string - */ - protected $bundleBlock = '#product-options-wrapper'; - /** * Click for Price link on Product page * @@ -145,13 +138,6 @@ class View extends Block */ protected $stockAvailability = '.stock span'; - /** - * Customize and add to cart button selector - * - * @var string - */ - protected $customizeButton = '.action.primary.customize'; - /** * This member holds the class name of the tier price block. * @@ -181,27 +167,28 @@ class View extends Block protected $addToWishlist = '[data-action="add-to-wishlist"]'; /** - * Get bundle options block + * Get block price * - * @return \Magento\Bundle\Test\Block\Catalog\Product\View\Type\Bundle + * @return \Magento\Catalog\Test\Block\Product\Price */ - public function getBundleBlock() + public function getPriceBlock() { - return Factory::getBlockFactory()->getMagentoBundleCatalogProductViewTypeBundle( - $this->_rootElement->find($this->bundleBlock) + return $this->blockFactory->create( + 'Magento\Catalog\Test\Block\Product\Price', + ['element' => $this->_rootElement->find($this->priceBlock, Locator::SELECTOR_XPATH)] ); } /** - * Get block price + * This method returns the custom options block. * - * @return \Magento\Catalog\Test\Block\Product\Price + * @return \Magento\Catalog\Test\Block\Product\View\CustomOptions */ - protected function getPriceBlock() + public function getCustomOptionsBlock() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\Price', - ['element' => $this->_rootElement->find($this->priceBlock, Locator::SELECTOR_XPATH)] + 'Magento\Catalog\Test\Block\Product\View\CustomOptions', + ['element' => $this->_rootElement->find($this->customOptionsSelector)] ); } @@ -217,16 +204,6 @@ class View extends Block $this->clickAddToCart(); } - /** - * Find button 'Add to cart' - * - * @return boolean - */ - public function addToCartIsVisible() - { - return $this->_rootElement->find($this->addToCart, Locator::SELECTOR_CSS)->isVisible(); - } - /** * Click link * @@ -289,32 +266,6 @@ class View extends Block return $this->_rootElement->find($this->productSku, Locator::SELECTOR_CSS)->getText(); } - /** - * This method returns the price box block. - * - * @return Price - */ - public function getProductPriceBlock() - { - return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\Price', - ['element' => $this->_rootElement->find($this->priceBlockClass, Locator::SELECTOR_CLASS_NAME)] - ); - } - - /** - * This method returns the custom options block. - * - * @return \Magento\Catalog\Test\Block\Product\View\CustomOptions - */ - public function getCustomOptionsBlock() - { - return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\View\CustomOptions', - ['element' => $this->_rootElement->find($this->customOptionsSelector)] - ); - } - /** * Return product price displayed on page * @@ -352,26 +303,29 @@ class View extends Block } /** - * Return configurable product options + * Return product options * + * @param FixtureInterface $product [optional] * @return array */ - public function getProductOptions() + public function getOptions(FixtureInterface $product = null) { - $options = []; - for ($i = 2; $i <= 3; $i++) { - $options[] = $this->_rootElement->find(".super-attribute-select option:nth-child({$i})")->getText(); - } - return $options; + /** @var CatalogProductSimple $product */ + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + + return $this->hasRender($typeId) + ? $this->callRender($typeId, 'getOptions', ['product' => $product]) + : $this->getCustomOptionsBlock()->getOptions($product); } /** - * Verify configurable product options + * Verify product options * - * @param ConfigurableProduct $product + * @param FixtureInterface $product * @return bool */ - public function verifyProductOptions(ConfigurableProduct $product) + public function verifyProductOptions(FixtureInterface $product) { $attributes = $product->getConfigurableOptions(); foreach ($attributes as $attributeName => $attribute) { @@ -400,18 +354,60 @@ class View extends Block */ public function fillOptions(FixtureInterface $product) { - $configureButton = $this->_rootElement->find($this->customizeButton); - $configureSection = $this->_rootElement->find('.product-options-wrapper'); + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + + /** @var CatalogProductSimple $product */ + if ($this->hasRender($typeId)) { + $this->callRender($typeId, 'fillOptions', ['product' => $product]); + } else { + $optionsCheckoutData = []; + + if ($product instanceof InjectableFixture) { + /** @var CatalogProductSimple $product */ + $customOptions = $product->hasData('custom_options') + ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() + : []; + $checkoutData = $product->getCheckoutData(); + $productCheckoutData = isset($checkoutData['custom_options']) + ? $checkoutData['custom_options'] + : []; + $optionsCheckoutData = $this->prepareCheckoutData($customOptions, $productCheckoutData); + } - if ($configureButton->isVisible()) { - $configureButton->click(); - $bundleOptions = $product->getSelectionData(); - $this->getBundleBlock()->fillBundleOptions($bundleOptions); + $this->getCustomOptionsBlock()->fillCustomOptions($optionsCheckoutData); } - if ($configureSection->isVisible()) { - $productOptions = $product->getProductOptions(); - $this->getCustomOptionsBlock()->fillProductOptions($productOptions); + } + + /** + * Replace index fields to name fields in checkout data + * + * @param array $options + * @param array $checkoutData + * @return array + */ + protected function prepareCheckoutData(array $options, array $checkoutData) + { + $result = []; + + foreach ($checkoutData as $checkoutOption) { + $attributeKey = $checkoutOption['title']; + $optionKey = $checkoutOption['value']; + + if (isset($options[$attributeKey])) { + $result[] = [ + 'type' => strtolower(preg_replace('/[^a-z]/i', '', $options[$attributeKey]['type'])), + 'title' => isset($options[$attributeKey]['title']) + ? $options[$attributeKey]['title'] + : $attributeKey, + 'value' => isset($options[$attributeKey]['options'][$optionKey]['title']) + ? $options[$attributeKey]['options'][$optionKey]['title'] + : $optionKey + ]; + } } + + return $result; } /** @@ -428,17 +424,6 @@ class View extends Block )->getText(); } - /** - * Click "Customize and add to cart button" - * - * @return void - */ - public function clickCustomize() - { - $this->_rootElement->find($this->customizeButton)->click(); - $this->waitForElementVisible($this->addToCart); - } - /** * Click "ADD TO CART" button * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php index f46da17bfd143c3561f1f89f5c8d5afc88337007..46ae945653282e5ce47c67899ab5c9e8e0847bc2 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php @@ -28,6 +28,7 @@ use Mtf\Block\Form; use Mtf\Client\Element; use Mtf\Client\Element\Locator; use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; /** * Class Custom Options @@ -129,17 +130,22 @@ class CustomOptions extends Form /** * Get product options * - * @param FixtureInterface|null $product [optional] + * @param FixtureInterface $product * @return array * @throws \Exception */ - public function getOptions(FixtureInterface $product = null) + public function getOptions(FixtureInterface $product) { - $dataOptions = ($product && $product->hasData('custom_options')) - ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() - : []; - $listCustomOptions = $this->getListCustomOptions(); - $readyOptions = []; + if ($product instanceof InjectableFixture) { + $dataOptions = $product->hasData('custom_options') + ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() + : []; + } else { + // TODO: Removed after refactoring(removed) old product fixture. + $dataOptions = $product->getData('fields/custom_options/value'); + $dataOptions = $dataOptions ? $dataOptions : []; + } + $listCustomOptions = $this->getListOptions(); $result = []; foreach ($dataOptions as $option) { @@ -160,17 +166,10 @@ class CustomOptions extends Form ? 'Yes' : 'No'; - $readyOptions[] = $title; $result[$title] = $optionData; } - $unreadyCustomOptions = array_diff_key($listCustomOptions, array_flip($readyOptions)); - foreach ($unreadyCustomOptions as $optionElement) { - $title = $optionElement->find($this->title, Locator::SELECTOR_XPATH)->getText(); - $result[$title] = ['title' => $title]; - } - - return $result; + return ['custom_options' => $result]; } /** @@ -178,7 +177,7 @@ class CustomOptions extends Form * * @return array */ - protected function getListCustomOptions() + protected function getListOptions() { $customOptions = []; $context = $this->_rootElement->find($this->optionsContext); @@ -418,169 +417,90 @@ class CustomOptions extends Form ]; } - /** - * Fill configurable product options - * - * @param array $productOptions - * @return void - */ - public function fillProductOptions(array $productOptions) - { - foreach ($productOptions as $attributeLabel => $attributeValue) { - $select = $this->_rootElement->find( - sprintf($this->selectByTitleLocator, $attributeLabel), - Locator::SELECTOR_XPATH, - 'select' - ); - $select->setValue($attributeValue); - } - } - /** * Fill custom options * - * @param FixtureInterface $product - * @param array $customOptions + * @param array $checkoutData * @return void */ - public function fillCustomOptions(FixtureInterface $product, array $customOptions) + public function fillCustomOptions(array $checkoutData) { - $customOptions = $this->prepareCustomOptions($product, $customOptions); - foreach ($customOptions as $option) { - $this->fillOption($option); - } + $checkoutOptions = $this->prepareOptions($checkoutData); + $this->fillOptions($checkoutOptions); } /** - * Prepare custom options for fill + * Prepare composite fields in checkout options data * - * @param FixtureInterface $product - * @param array $customOptions + * @param array $options * @return array */ - protected function prepareCustomOptions(FixtureInterface $product, array $customOptions) + protected function prepareOptions(array $options) { - $options = []; - $productCustomOptions = $product->hasData('custom_options') - ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() - : null; - - if ($productCustomOptions !== null) { - foreach ($customOptions as $key => $option) { - $type = $productCustomOptions[$option['option'] - 1]['type']; - $title = $productCustomOptions[$option['option'] - 1]['title']; - $titleOption = []; - foreach ($option['value'] as $value) { - $titleOption[] = is_numeric($value) - ? $productCustomOptions[$option['option'] - 1]['options'][$value - 1]['title'] - : null; - } - - $options[$key] = $this->dataMapping([$option, $type, $title, $titleOption]); - } - } + $result = []; - return $options; - } + foreach ($options as $key => $option) { + switch ($option['type']) { + case 'datetime': + list($day, $month, $year, $hour, $minute, $dayPart) = explode('/', $option['value']); + $option['value'] = [ + 'day' => $day, + 'month' => $month, + 'year' => $year, + 'hour' => $hour, + 'minute' => $minute, + 'day_part' => $dayPart + ]; + break; + case 'date': + list($day, $month, $year) = explode('/', $option['value']); + $option['value'] = [ + 'day' => $day, + 'month' => $month, + 'year' => $year, + ]; + break; + case 'time': + list($hour, $minute, $dayPart) = explode('/', $option['value']); + $option['value'] = [ + 'hour' => $hour, + 'minute' => $minute, + 'day_part' => $dayPart + ]; + break; + } - /** - * Custom options mapping - * - * @param array|null $fields - * @param string|null $parent - * @return array - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - protected function dataMapping(array $fields = null, $parent = null) - { - list($option, $type, $title, $titleOption) = $fields; - - $isDate = $type == 'Date' || $type == 'Time' || $type == 'Date & Time'; - $isChecked = $type == 'Checkbox' || $type == 'Radio Buttons'; - $isField = $type == 'Field' || $type == 'Area'; - - $optionName = strtolower(preg_replace('/[^a-zA-Z]/', '', $type)); - $option += parent::dataMapping([$optionName => []]); - $selector = [$option[$optionName]['selector']]; - - if ($isDate) { - $value = explode('/', $option['value'][0]); - $selector = $this->setDateTypeSelector(count($value), $selector[0]); - } elseif ($isChecked) { - $selector[0] = str_replace('%option_name%', $titleOption[0], $selector[0]); - $value = ['Yes']; - } elseif ($isField) { - $value = $option['value']; - } else { - $value = $titleOption; + $result[$key] = $option; } - return [ - 'title' => $title, - 'value' => $value, - 'selector' => $selector, - 'input' => $option[$optionName]['input'] - ]; + return $result; } /** - * Fill custom option + * Fill product options * - * @param array $customOption + * @param array $options * @return void */ - public function fillOption(array $customOption) + protected function fillOptions(array $options) { - foreach ($customOption['value'] as $key => $attributeValue) { - $select = $this->_rootElement->find( - sprintf($this->optionByName, $customOption['title']) . $customOption['selector'][$key], - Locator::SELECTOR_XPATH, - $customOption['input'] + foreach ($options as $option) { + $optionBlock = $this->_rootElement->find( + sprintf($this->optionByName, $option['title']), + Locator::SELECTOR_XPATH ); - $select->setValue($attributeValue); - } - } - - /** - * Set item data type selector - * - * @param int $count - * @param string $selector [optional] - * @return array - */ - protected function setDateTypeSelector($count, $selector = '') - { - $result = []; - $parent = ''; - for ($i = 0; $i < $count; $i++) { - if (!(($i + 1) % 4)) { - $parent = '//span'; + $type = $option['type']; + $mapping = $this->dataMapping([$type => $option['value']]); + + if ('radiobuttons' == $type || 'checkbox' == $type) { + $mapping[$type]['selector'] = str_replace( + '%option_name%', + $mapping[$type]['value'], + $mapping[$type]['selector'] + ); + $mapping[$type]['value'] = 'Yes'; } - $result[$i] = $selector . $parent . '//select[' . ($i % 3 + 1) . ']'; - } - - return $result; - } - - /** - * Choose custom option in a drop down - * - * @param string $title - * @param string|null $value [optional] - * @return void - */ - public function selectProductCustomOption($title, $value = null) - { - $select = $this->_rootElement->find( - sprintf($this->selectByTitleLocator, $title), - Locator::SELECTOR_XPATH, - 'select' - ); - - if (null === $value) { - $value = $select->find('.//option[@value != ""][1]', Locator::SELECTOR_XPATH)->getText(); + $this->_fill($mapping, $optionBlock); } - $select->setValue($value); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.xml index af94825cc498b8f986ac87f933755f63d27d6b27..e4de24ff1b993bd6224c7a466f7e33349550ec39 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.xml @@ -26,41 +26,90 @@ <mapping strict="0"> <fields> <dropdown> - <selector>//select</selector> + <selector>.//select</selector> <input>select</input> + <strategy>xpath</strategy> </dropdown> <multipleselect> - <selector>//select</selector> + <selector>.//select</selector> <input>multiselect</input> + <strategy>xpath</strategy> </multipleselect> <checkbox> - <selector>//div[label[span[contains(text(), "%option_name%")]]]/input</selector> + <selector>.//div[label[span[contains(text(), "%option_name%")]]]/input</selector> <input>checkbox</input> + <strategy>xpath</strategy> </checkbox> <radiobuttons> - <selector>//div[label[span[contains(text(), "%option_name%")]]]/input</selector> + <selector>.//div[label[span[contains(text(), "%option_name%")]]]/input</selector> <input>checkbox</input> + <strategy>xpath</strategy> </radiobuttons> - <date> - <selector /> - <input>select</input> + <date composite="1"> + <month> + <selector>[name$="[month]"]</selector> + <input>select</input> + </month> + <day> + <selector>[name$="[day]"]</selector> + <input>select</input> + </day> + <year> + <selector>[name$="[year]"]</selector> + <input>select</input> + </year> </date> - <datetime> - <selector /> - <input>select</input> + <datetime composite="1"> + <month> + <selector>[name$="[month]"]</selector> + <input>select</input> + </month> + <day> + <selector>[name$="[day]"]</selector> + <input>select</input> + </day> + <year> + <selector>[name$="[year]"]</selector> + <input>select</input> + </year> + <hour> + <selector>[name$="[hour]"]</selector> + <input>select</input> + </hour> + <minute> + <selector>[name$="[minute]"]</selector> + <input>select</input> + </minute> + <day_part> + <selector>[name$="[day_part]"]</selector> + <input>select</input> + </day_part> </datetime> - <time> - <selector /> - <input>select</input> + <time composite="1"> + <hour> + <selector>[name$="[hour]"]</selector> + <input>select</input> + </hour> + <minute> + <selector>[name$="[minute]"]</selector> + <input>select</input> + </minute> + <day_part> + <selector>[name$="[day_part]"]</selector> + <input>select</input> + </day_part> </time> <area> - <selector>//textarea</selector> + <selector>.//textarea</selector> + <strategy>xpath</strategy> </area> <file> - <selector>//input</selector> + <selector>.//input</selector> + <strategy>xpath</strategy> </file> <field> - <selector>//input</selector> + <selector>.//input</selector> + <strategy>xpath</strategy> </field> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php index 7e74999942884d3130887dcb37aeb351b481a6a5..7544902d30fc1e6813e0271e9dd27c64ed9bfd01 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php @@ -107,7 +107,7 @@ class AssertAddedProductAttributeOnProductForm extends AbstractConstraint : $productAttribute->getData(); \PHPUnit_Framework_Assert::assertTrue( - $productEdit->getForm()->checkAttributeLabel($catalogProductAttribute), + $productEdit->getProductForm()->checkAttributeLabel($catalogProductAttribute), "Product Attribute is absent on Product form." ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php index a7e5badc39e76834509232d0f671c15cca0df64a..47e5c403b5c41b5fc4ed5df3019db8e716390768 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php @@ -107,7 +107,7 @@ class AssertCategoryPage extends AbstractConstraint if (isset($categoryData['default_sort_by'])) { $sortBy = strtolower($categoryData['default_sort_by']); - $sortType = $categoryView->getToolbar()->getSelectSortType(); + $sortType = $categoryView->getTopToolbar()->getSelectSortType(); \PHPUnit_Framework_Assert::assertEquals( $sortBy, $sortType, @@ -126,7 +126,7 @@ class AssertCategoryPage extends AbstractConstraint ); if ($availableSortType) { $availableSortType = array_values($availableSortType); - $availableSortTypeOnPage = $categoryView->getToolbar()->getSortType(); + $availableSortTypeOnPage = $categoryView->getTopToolbar()->getSortType(); \PHPUnit_Framework_Assert::assertEquals( $availableSortType, $availableSortTypeOnPage, diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInSearchOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInSearchOnProductForm.php index d7a7209b8e2ce384ed622aa3bbd2562e57ba5d7c..0d780437103713ca9242dd88d625a7004fd3682b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInSearchOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInSearchOnProductForm.php @@ -28,7 +28,6 @@ use Mtf\Constraint\AbstractConstraint; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; /** * Class AssertAbsenceInAddAttributeSearch @@ -60,7 +59,7 @@ class AssertProductAttributeAbsenceInSearchOnProductForm extends AbstractConstra $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); \PHPUnit_Framework_Assert::assertFalse( - $newProductPage->getForm()->checkAttributeInSearchAttributeForm($productAttribute), + $newProductPage->getProductForm()->checkAttributeInSearchAttributeForm($productAttribute), "Product attribute found in Attribute Search form." ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeDisplayingOnFrontend.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeDisplayingOnFrontend.php old mode 100644 new mode 100755 diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php index c4473c4a49860f03b7de0afda5f2219a5363e807..eb8c9a4e873072ce181b04ca115b55c5c6a52f9d 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php @@ -24,6 +24,7 @@ namespace Magento\Catalog\Test\Constraint; +use Mtf\ObjectManager; use Mtf\Client\Browser; use Mtf\Fixture\FixtureInterface; use Mtf\Constraint\AbstractAssertForm; @@ -106,46 +107,22 @@ class AssertProductCustomOptionsOnProductPage extends AbstractAssertForm */ public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product, Browser $browser) { - $this->openProductPage($product, $browser); - // Prepare data - $formCustomOptions = $catalogProductView->getCustomOptionsBlock()->getOptions($product); - $actualPrice = $this->isPrice ? $this->getProductPrice($catalogProductView) : null; + $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + + $actualPrice = null; + if ($this->isPrice) { + $prices = $catalogProductView->getViewBlock()->getPriceBlock()->getPrice(); + $actualPrice = isset($prices['price_special_price']) + ? $prices['price_special_price'] + : $prices['price_regular_price']; + } $fixtureCustomOptions = $this->prepareOptions($product, $actualPrice); + $formCustomOptions = $catalogProductView->getViewBlock()->getOptions($product)['custom_options']; $error = $this->verifyData($fixtureCustomOptions, $formCustomOptions); \PHPUnit_Framework_Assert::assertEmpty($error, $error); } - /** - * Get price from product page - * - * @param CatalogProductView $catalogProductView - * @return string - */ - protected function getProductPrice(CatalogProductView $catalogProductView) - { - $prices = $catalogProductView->getViewBlock()->getProductPriceBlock()->getPrice(); - $actualPrice = isset($prices['price_special_price']) - ? $prices['price_special_price'] - : $prices['price_regular_price']; - - return $actualPrice; - } - - /** - * Open product view page - * - * @param FixtureInterface $product - * @param Browser $browser - * @return void - */ - protected function openProductPage( - FixtureInterface $product, - Browser $browser - ) { - $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - } - /** * Preparation options before comparing * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php index 93defce60ad9fa1bdb255d042ffa89431b7f5609..db4d8cb3ce5dceb6f7a786f9bbbf89060f0632c4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php @@ -79,8 +79,8 @@ class AssertProductDuplicateForm extends AssertProductForm $filter = ['sku' => $product->getSku() . '-1']; $productGrid->open()->getProductGrid()->searchAndOpen($filter); - $formData = $productPage->getForm()->getData($product); - $fixtureData = $this->prepareFixtureData($product->getData(), $product); + $formData = $productPage->getProductForm()->getData($product); + $fixtureData = $this->prepareFixtureData($product->getData()); $errors = $this->verifyData($fixtureData, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); @@ -90,11 +90,10 @@ class AssertProductDuplicateForm extends AssertProductForm * Prepares fixture data for comparison * * @param array $data - * @param FixtureInterface $product * @param array $sortFields [optional] * @return array */ - protected function prepareFixtureData(array $data, FixtureInterface $product, array $sortFields = []) + protected function prepareFixtureData(array $data, array $sortFields = []) { $compareData = array_filter($data); @@ -117,16 +116,14 @@ class AssertProductDuplicateForm extends AssertProductForm $compareData['status'] = 'Product offline'; } if (isset($compareData['quantity_and_stock_status']['qty'])) { - $compareData['quantity_and_stock_status']['qty'] = ''; + $compareData['quantity_and_stock_status']['qty'] = 0; } if (isset($compareData['special_price'])) { $compareData['special_price'] = ['special_price' => $compareData['special_price']]; } $compareData['sku'] .= '-1'; - $compareData['quantity_and_stock_status']['is_in_stock'] = 'Out of Stock'; - unset($compareData['category_ids'], $compareData['id']); - return $compareData; + return parent::prepareFixtureData($compareData, $sortFields); } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php index 46d4fe28d6fce5b0b853d81c0585f7fa2b34f2e4..37c0fa1307864fec409b347272259037edd72d4c 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php @@ -34,6 +34,16 @@ use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; */ class AssertProductForm extends AbstractAssertForm { + /** + * List skipped fixture fields in verify + * + * @var array + */ + protected $skippedFixtureFields = [ + 'id', + 'checkout_data' + ]; + /** * Sort fields for fixture and form data * @@ -74,8 +84,13 @@ class AssertProductForm extends AbstractAssertForm $productGrid->open(); $productGrid->getProductGrid()->searchAndOpen($filter); - $fixtureData = $this->prepareFixtureData($product->getData(), $product, $this->sortFields); - $formData = $this->prepareFormData($productPage->getForm()->getData($product), $this->sortFields); + $productData = $product->getData(); + if ($product->hasData('custom_options')) { + $customOptionsSource = $product->getDataFieldConfig('custom_options')['source']; + $productData['custom_options'] = $customOptionsSource->getCustomOptions(); + } + $fixtureData = $this->prepareFixtureData($productData, $this->sortFields); + $formData = $this->prepareFormData($productPage->getProductForm()->getData($product), $this->sortFields); $error = $this->verifyData($fixtureData, $formData); \PHPUnit_Framework_Assert::assertTrue(empty($error), $error); } @@ -84,18 +99,16 @@ class AssertProductForm extends AbstractAssertForm * Prepares fixture data for comparison * * @param array $data - * @param FixtureInterface $product * @param array $sortFields [optional] * @return array */ - protected function prepareFixtureData(array $data, FixtureInterface $product, array $sortFields = []) + protected function prepareFixtureData(array $data, array $sortFields = []) { + $data = array_diff_key($data, array_flip($this->skippedFixtureFields)); + if (isset($data['website_ids']) && !is_array($data['website_ids'])) { $data['website_ids'] = [$data['website_ids']]; } - if (isset($data['custom_options'])) { - $data['custom_options'] = $product->getDataFieldConfig('custom_options')['source']->getCustomOptions(); - } if (!empty($this->specialArray)) { $data = $this->prepareSpecialPriceArray($data); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php index 66096b71f5a2d0ea5127ad6225bf6880eae10bc7..a50c602cee51b3dd7ea65f2034ac12bab8ebd577 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php @@ -32,6 +32,7 @@ use Magento\Catalog\Test\Page\Product\CatalogProductView; /** * Class AssertProductInCart + * Assertion that the product is correctly displayed in cart */ class AssertProductInCart extends AbstractConstraint { @@ -59,13 +60,7 @@ class AssertProductInCart extends AbstractConstraint ) { // Add product to cart $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $productOptions = $product->getCustomOptions(); - if ($productOptions) { - $customOption = $catalogProductView->getCustomOptionsBlock(); - $options = $customOption->getOptions(); - $key = $productOptions[0]['title']; - $customOption->selectProductCustomOption($options[$key]['title']); - } + $catalogProductView->getViewBlock()->fillOptions($product); $catalogProductView->getViewBlock()->clickAddToCart(); // Check price @@ -81,43 +76,39 @@ class AssertProductInCart extends AbstractConstraint */ protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart) { - $cartBlock = $checkoutCart->getCartBlock(); - $productName = $product->getName(); - $productOptions = $product->getCustomOptions(); - $priceComparing = $product->getPrice(); + $customOptions = $product->getCustomOptions(); + $checkoutData = $product->getCheckoutData(); + $checkoutCustomOptions = isset($checkoutData['custom_options']) ? $checkoutData['custom_options'] : []; + $fixturePrice = $product->getPrice(); + $groupPrice = $product->getGroupPrice(); + $specialPrice = $product->getSpecialPrice(); + $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); + $formPrice = $cartItem->getPrice(); - if ($groupPrice = $product->getGroupPrice()) { + if ($groupPrice) { $groupPrice = reset($groupPrice); - $priceComparing = $groupPrice['price']; + $fixturePrice = $groupPrice['price']; } - - if ($specialPrice = $product->getSpecialPrice()) { - $priceComparing = $specialPrice; + if ($specialPrice) { + $fixturePrice = $specialPrice; } + $fixtureActualPrice = $fixturePrice; - if (!empty($productOptions)) { - $productOption = reset($productOptions); - $optionsData = reset($productOption['options']); - $optionName = $cartBlock->getCartItemOptionsNameByProductName($productName); - $optionValue = $cartBlock->getCartItemOptionsValueByProductName($productName); - - \PHPUnit_Framework_Assert::assertTrue( - trim($optionName) === $productOption['title'] - && trim($optionValue) === $optionsData['title'], - 'In the cart wrong option product.' - ); + foreach ($checkoutCustomOptions as $checkoutOption) { + $attributeKey = $checkoutOption['title']; + $optionKey = $checkoutOption['value']; + $option = $customOptions[$attributeKey]['options'][$optionKey]; - if ($optionsData['price_type'] === 'Percent') { - $priceComparing = $priceComparing * (1 + $optionsData['price'] / 100); + if ('Fixed' == $option['price_type']) { + $fixtureActualPrice += $option['price']; } else { - $priceComparing += $optionsData['price']; + $fixtureActualPrice += ($fixturePrice / 100) * $option['price']; } } - $price = $checkoutCart->getCartBlock()->getProductPriceByName($productName); \PHPUnit_Framework_Assert::assertEquals( - number_format($priceComparing, 2), - $price, + number_format($fixtureActualPrice, 2), + $formPrice, 'Product price in shopping cart is not correct.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCategory.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCategory.php index 4490968398655e8019f8c8634cb5aca2ba87bab8..9f352c5ce2e717aba10d3d4bb12b2b0db6029041 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCategory.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCategory.php @@ -67,7 +67,7 @@ class AssertProductInCategory extends AbstractConstraint $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) { + while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInStock.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInStock.php index b42fbe7453eaa05f66f83d44b5c2401ae5eaee96..aa94f596bdb6088299aff0d2d169b7bc11504f77 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInStock.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInStock.php @@ -61,7 +61,7 @@ class AssertProductInStock extends AbstractConstraint \PHPUnit_Framework_Assert::assertEquals( self::STOCK_AVAILABILITY, $catalogProductView->getViewBlock()->stockAvailability(), - 'Control \'' . self::STOCK_AVAILABILITY . '\' is not visible.' + 'Control "' . self::STOCK_AVAILABILITY . '" is not visible.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductIsNotDisplayingOnFrontend.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductIsNotDisplayingOnFrontend.php index a309cce59663e66d8545f16c319b46a3a1868eba..fab93fbed78322f2b1267a482a32e52338a2e76e 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductIsNotDisplayingOnFrontend.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductIsNotDisplayingOnFrontend.php @@ -162,7 +162,7 @@ class AssertProductIsNotDisplayingOnFrontend extends AbstractConstraint $this->cmsIndex->open(); $this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $this->catalogCategoryView->getToolbar()->nextPage()) { + while (!$isProductVisible && $this->catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $this->catalogCategoryView->getListProductBlock() ->isProductVisible($product->getName()); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductNotVisibleInCategory.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductNotVisibleInCategory.php index e8a88c5ae6b75e55f0bbef75c60bf5781f5e3e2f..a79bdd640603969b7373d47ce9a57d0ae83af4e9 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductNotVisibleInCategory.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductNotVisibleInCategory.php @@ -64,7 +64,7 @@ class AssertProductNotVisibleInCategory extends AbstractConstraint $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) { + while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); } \PHPUnit_Framework_Assert::assertFalse( diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php index 1958984f661fb3104553f0a45d1a2f076129e6d3..9ea6b1e13d3d1c03737711316838fa882e739d3f 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php @@ -24,145 +24,191 @@ namespace Magento\Catalog\Test\Constraint; +use Mtf\ObjectManager; use Mtf\Client\Browser; -use Mtf\Fixture\FixtureInterface; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Mtf\Fixture\FixtureInterface; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; /** * Class AssertProductPage + * Assert that displayed product data on product page(front-end) equals passed from fixture. */ -class AssertProductPage extends AbstractConstraint +class AssertProductPage extends AbstractAssertForm { /** - * Product fixture + * Product view block on frontend page * - * @var FixtureInterface + * @var \Magento\ConfigurableProduct\Test\Block\Product\View */ - protected $product; + protected $productView; /** - * Constraint severeness + * Product fixture * - * @var string + * @var ConfigurableProductInjectable */ - protected $severeness = 'low'; + protected $product; /** - * Error messages + * Constraint severeness * - * @var array + * @var string */ - protected $errorsMessages = [ - 'name' => '- product name on product view page is not correct.', - 'sku' => '- product sku on product view page is not correct.', - 'regular_price' => '- product regular price on product view page is not correct.', - 'short_description' => '- product short description on product view page is not correct.', - 'description' => '- product description on product view page is not correct.' - ]; + protected $severeness = 'middle'; /** - * Assertion that the product page is displayed correctly + * Assert that displayed product data on product page(front-end) equals passed from fixture: + * 1. Product Name + * 2. Price + * 3. Special price + * 4. SKU + * 5. Description + * 6. Short Description * - * @param CatalogProductView $catalogProductView * @param Browser $browser + * @param CatalogProductView $catalogProductView * @param FixtureInterface $product * @return void */ - public function processAssert(CatalogProductView $catalogProductView, Browser $browser, FixtureInterface $product) + public function processAssert(Browser $browser, CatalogProductView $catalogProductView, FixtureInterface $product) { - $this->product = $product; - // TODO fix initialization url for frontend page - //Open product view page $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $data = $this->prepareData($catalogProductView); - $badValues = array_diff($data['onPage'], $data['fixture']); - $errors = array_intersect_key($this->errorsMessages, array_keys($badValues)); - $errors += $this->verifySpecialPrice($catalogProductView); + $this->product = $product; + $this->productView = $catalogProductView->getViewBlock(); + + $errors = $this->verify(); \PHPUnit_Framework_Assert::assertEmpty( $errors, - PHP_EOL . 'Found the following errors:' . PHP_EOL . implode(' ' . PHP_EOL, $this->errorsMessages) + "\nFound the following errors:\n" . implode(" \n", $errors) ); } /** - * Prepare array for assert + * Verify displayed product data on product page(front-end) equals passed from fixture * - * @param CatalogProductView $catalogProductView * @return array */ - protected function prepareData(CatalogProductView $catalogProductView) + protected function verify() { - $viewBlock = $catalogProductView->getViewBlock(); - $price = $viewBlock->getProductPriceBlock()->getPrice(); - $data = [ - 'onPage' => [ - 'name' => $viewBlock->getProductName(), - 'sku' => $viewBlock->getProductSku(), - ], - 'fixture' => [ - 'name' => $this->product->getName(), - 'sku' => $this->product->getSku(), - ] - ]; - - list($priceOnPage, $priceFixture) = $this->preparePrice($price); - $data['onPage'] += $priceOnPage; - $data['fixture'] += $priceFixture; - - if ($productShortDescription = $this->product->getShortDescription()) { - $data['fixture']['short_description'] = $productShortDescription; - $data['onPage']['short_description'] = $viewBlock->getProductShortDescription(); - } - if ($productDescription = $this->product->getDescription()) { - $data['fixture']['description'] = $productDescription; - $data['onPage']['description'] = $viewBlock->getProductDescription(); - } + $errors = []; - return $data; + $errors[] = $this->verifyName(); + $errors[] = $this->verifyPrice(); + $errors[] = $this->verifySpecialPrice(); + $errors[] = $this->verifySku(); + $errors[] = $this->verifyDescription(); + $errors[] = $this->verifyShortDescription(); + + return array_filter($errors); } /** - * Prepare Price data + * Verify displayed product name on product page(front-end) equals passed from fixture * - * @param array $price - * @return array + * @return string|null */ - protected function preparePrice($price) + protected function verifyName() { - return [ - ['regular_price' => $price['price_regular_price']], - ['regular_price' => number_format($this->product->getPrice(), 2)] - ]; + $fixtureProductName = $this->product->getName(); + $formProductName = $this->productView->getProductName(); + + if ($fixtureProductName == $formProductName) { + return null; + } + return "Displayed product name on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductName}, expected: {$fixtureProductName}."; } /** - * Checking the special product price + * Verify displayed product price on product page(front-end) equals passed from fixture * - * @param CatalogProductView $catalogProductView - * @return array + * @return string|null + */ + protected function verifyPrice() + { + $fixtureProductPrice = number_format($this->product->getPrice(), 2); + $formProductPrice = $this->productView->getPriceBlock()->getRegularPrice(); + + if ($fixtureProductPrice == $formProductPrice) { + return null; + } + return "Displayed product price on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductPrice}, expected: {$fixtureProductPrice}."; + } + + /** + * Verify displayed product special price on product page(front-end) equals passed from fixture + * + * @return string|null */ - protected function verifySpecialPrice(CatalogProductView $catalogProductView) + protected function verifySpecialPrice() { - $priceBlock = $catalogProductView->getViewBlock()->getProductPriceBlock(); - $price = $priceBlock->isVisible() ? $priceBlock->getPrice() : ['price_special_price' => null]; - $priceComparing = false; + $fixtureProductSpecialPrice = $this->product->getSpecialPrice(); + if (!$fixtureProductSpecialPrice) { + return null; + } - if ($specialPrice = $this->product->getSpecialPrice()) { - $priceComparing = $specialPrice; + $fixtureProductSpecialPrice = number_format($fixtureProductSpecialPrice, 2); + $formProductSpecialPrice = $this->productView->getPriceBlock()->getSpecialPrice(); + if ($fixtureProductSpecialPrice == $formProductSpecialPrice) { + return null; } - if ($groupPrice = $this->product->getGroupPrice()) { - $groupPrice = reset($groupPrice); - $priceComparing = $groupPrice['price']; + return "Displayed product special price on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductSpecialPrice}, expected: {$fixtureProductSpecialPrice}."; + } + + /** + * Verify displayed product sku on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifySku() + { + $fixtureProductSku = $this->product->getSku(); + $formProductSku = $this->productView->getProductSku(); + + if ($fixtureProductSku == $formProductSku) { + return null; } - if ($priceComparing && isset($price['price_special_price']) - && number_format($priceComparing, 2) !== $price['price_special_price'] - ) { - return ['special_price' => '- product special price on product view page is not correct.']; + return "Displayed product sku on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductSku}, expected: {$fixtureProductSku}."; + } + + /** + * Verify displayed product description on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifyDescription() + { + $fixtureProductDescription = $this->product->getDescription(); + $formProductDescription = $this->productView->getProductDescription(); + + if ($fixtureProductDescription == $formProductDescription) { + return null; } + return "Displayed product description on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductDescription}, expected: {$fixtureProductDescription}."; + } - return []; + /** + * Verify displayed product short description on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifyShortDescription() + { + $fixtureProductShortDescription = $this->product->getShortDescription(); + $formProductShortDescription = $this->productView->getProductShortDescription(); + + if ($fixtureProductShortDescription == $formProductShortDescription) { + return null; + } + return "Displayed product short description on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductShortDescription}, expected: {$fixtureProductShortDescription}."; } /** @@ -172,6 +218,6 @@ class AssertProductPage extends AbstractConstraint */ public function toString() { - return 'Product on product view page is not correct.'; + return 'Product on product view page is correct.'; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSearchableBySku.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSearchableBySku.php index db48a737ccb5304039e03ac5201328fc3d4b061c..d12d85f57d7655b9c44931d85f89dc0f9da36d1e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSearchableBySku.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSearchableBySku.php @@ -80,7 +80,7 @@ class AssertProductSearchableBySku extends AbstractConstraint : null; $isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); - while (!$isVisible && $catalogSearchResult->getToolbar()->nextPage()) { + while (!$isVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) { $isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateGroupOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateGroupOnProductForm.php index 492294e88edf27cb4b8ed7106fa138b355cb0e4b..690e7d2045ae92992840239cdfc7fbe74c3c7114 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateGroupOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateGroupOnProductForm.php @@ -72,7 +72,7 @@ class AssertProductTemplateGroupOnProductForm extends AbstractConstraint $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); - $productBlockForm = $newProductPage->getForm(); + $productBlockForm = $newProductPage->getProductForm(); /**@var CatalogProductSimple $catalogProductSimple */ $productSimple = $fixtureFactory->createByCode( @@ -87,13 +87,13 @@ class AssertProductTemplateGroupOnProductForm extends AbstractConstraint $productBlockForm->fill($productSimple); \PHPUnit_Framework_Assert::assertTrue( - $productEdit->getForm()->isTabVisible($attributeSet->getGroup()), + $productEdit->getProductForm()->isTabVisible($attributeSet->getGroup()), "Product Group is absent on Product form tabs." ); - $productEdit->getForm()->openCustomTab($attributeSet->getGroup()); + $productEdit->getProductForm()->openCustomTab($attributeSet->getGroup()); \PHPUnit_Framework_Assert::assertTrue( - $productEdit->getForm()->checkAttributeLabel($productAttributeOriginal), + $productEdit->getProductForm()->checkAttributeLabel($productAttributeOriginal), "Product Attribute is absent on Product form." ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateOnProductForm.php index c0b365a1e1f37069ca6d93c4523cc086d5f134f8..3c902550d6d1bb91f6670eb22a098262ef3ee672 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateOnProductForm.php @@ -73,7 +73,7 @@ class AssertProductTemplateOnProductForm extends AbstractConstraint $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); - $productBlockForm = $newProductPage->getForm(); + $productBlockForm = $newProductPage->getProductForm(); /**@var CatalogProductSimple $catalogProductSimple */ $productSimple = $fixtureFactory->createByCode( @@ -86,9 +86,9 @@ class AssertProductTemplateOnProductForm extends AbstractConstraint ] ); $productBlockForm->fill($productSimple); - $newProductPage->getFormAction()->save(); + $newProductPage->getFormPageActions()->save(); - $formData = $productEdit->getForm()->getData($productSimple); + $formData = $productEdit->getProductForm()->getData($productSimple); $formAttributeSet = $formData['attribute_set_id']; \PHPUnit_Framework_Assert::assertEquals( $attributeSet->getAttributeSetName(), @@ -99,10 +99,10 @@ class AssertProductTemplateOnProductForm extends AbstractConstraint ); if ($attributeSetOriginal === null) { - $productEdit->getForm()->openTab('product-details'); + $productEdit->getProductForm()->openTab('product-details'); \PHPUnit_Framework_Assert::assertTrue( - $productEdit->getForm()->checkAttributeLabel($productAttribute), + $productEdit->getProductForm()->checkAttributeLabel($productAttribute), "Product Attribute is absent on Product form." ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductView.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductView.php index 8927be881d642fb25a57560ee475ec8782ecb5e9..5037a3c3be13971448bf238f1ece96c4d91236ed 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductView.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductView.php @@ -71,7 +71,7 @@ class AssertProductView extends AbstractConstraint protected function assertOnProductView(CatalogProductSimple $product, CatalogProductView $catalogProductView) { $viewBlock = $catalogProductView->getViewBlock(); - $price = $viewBlock->getProductPriceBlock()->getPrice(); + $price = $viewBlock->getPriceBlock()->getPrice(); $name = $viewBlock->getProductName(); $sku = $viewBlock->getProductSku(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductVisibleInCategory.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductVisibleInCategory.php index da0b9f38421d5ba5bd128b865cb63868f9c89fb0..64f8ccfd36304523541ecad41776b168accee2c6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductVisibleInCategory.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductVisibleInCategory.php @@ -78,7 +78,7 @@ class AssertProductVisibleInCategory extends AbstractConstraint $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) { + while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php old mode 100644 new mode 100755 index 49576b99733f8c4fa70549d36c255d4e5a7e2899..52dad8b9bb52437ca3bfde1df810485403bfc4a0 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php @@ -33,6 +33,7 @@ use Magento\Catalog\Test\Fixture\CatalogProductAttribute; * * Data keys: * - presets + * - attributes */ class AssignedAttributes implements FixtureInterface { @@ -66,13 +67,19 @@ class AssignedAttributes implements FixtureInterface public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) { $this->params = $params; - if (isset($data['presets']) && $data['presets'] !== '-') { + if (isset($data['presets']) && is_string($data['presets'])) { $presets = explode(',', $data['presets']); foreach ($presets as $preset) { /** @var CatalogProductAttribute $attribute */ $attribute = $fixtureFactory->createByCode('catalogProductAttribute', ['dataSet' => $preset]); $attribute->persist(); + $this->data[] = $attribute->getAttributeCode(); + $this->attributes[] = $attribute; + } + } elseif (isset($data['attributes']) && is_array($data['attributes'])) { + foreach ($data['attributes'] as $attribute) { + /** @var CatalogProductAttribute $attribute */ $this->data[] = $attribute->getAttributeCode(); $this->attributes[] = $attribute; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.php index bb614003f836a7a854d9e2449c3ce37111777a47..ec87b10f0428961c895eb5a58e78500c669957ef 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.php @@ -560,4 +560,9 @@ class CatalogProductAttribute extends InjectableFixture { return $this->getData('search_weight'); } + + public function getOptions() + { + return $this->getData('options'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml index 8a6905704118bb1ffc5f41b43b14480870cc72b0..d4ae55aa0281dd7de217282bd22aa7d8a1d2b632 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml @@ -287,6 +287,15 @@ <default_value>1</default_value> <input></input> </search_weight> + <options> + <attribute_code>options</attribute_code> + <backend_type>smallint</backend_type> + <is_required></is_required> + <default_value></default_value> + <input></input> + <source>\Magento\Catalog\Test\Fixture\CatalogProductAttribute\Options</source> + <group>manage-options</group> + </options> </fields> <repository_class>Magento\Catalog\Test\Repository\CatalogProductAttribute</repository_class> <handler_interface>Magento\Catalog\Test\Handler\CatalogProductAttribute\CatalogAttributeEntityInterface</handler_interface> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.php index f029c62865b7fcbe8ba589c8b433204e52fc6cb4..cc5c4476db5700ba76a70e5ea793dd0cad81ad46 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.php @@ -89,6 +89,7 @@ class CatalogProductSimple extends InjectableFixture } protected $dataConfig = [ + 'type_id' => 'simple', 'create_url_params' => [ 'type' => 'simple', 'set' => '4', @@ -549,6 +550,12 @@ class CatalogProductSimple extends InjectableFixture 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\AttributeSetId', ]; + protected $attributes = [ + 'attribute_code' => 'attributes', + 'backend_type' => 'virtual', + 'group' => 'product-details', + ]; + protected $custom_options = [ 'attribute_code' => 'custom_options', 'backend_type' => 'virtual', @@ -597,6 +604,13 @@ class CatalogProductSimple extends InjectableFixture 'group' => 'advanced-inventory' ]; + protected $checkout_data = [ + 'attribute_code' => 'checkout_data', + 'backend_type' => 'virtual', + 'group' => null, + 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData' + ]; + public function getCategoryIds() { return $this->getData('category_ids'); @@ -862,6 +876,11 @@ class CatalogProductSimple extends InjectableFixture return $this->getData('attribute_set_id'); } + public function getAttribute() + { + return $this->getData('attributes'); + } + public function getCustomOptions() { return $this->getData('custom_options'); @@ -887,8 +906,13 @@ class CatalogProductSimple extends InjectableFixture return $this->getData('news_to_date'); } - public function getStockDate() + public function getStockData() { return $this->getData('stock_data'); } + + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml index 8f88072b9836d6c9af8b0c81c472d0628ff4cace..659821b132bb26dbd45be0f82b58bc726029ff1b 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml @@ -432,6 +432,11 @@ <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\AttributeSetId</source> <group>product-details</group> </attribute_set_id> + <attributes> + <attribute_code>attributes</attribute_code> + <backend_type>virtual</backend_type> + <group>product-details</group> + </attributes> <custom_options> <attribute_code>custom_options</attribute_code> <backend_type>virtual</backend_type> @@ -459,6 +464,12 @@ <backend_type>virtual</backend_type> <group>advanced-inventory</group> </stock_data> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData</source> + </checkout_data> </fields> <data_set> <sku></sku> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php index 884b098f388339b01048445c9194face0437b60d..8780e106d913a5a0779189e1d5f754899c80fe8c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php @@ -28,17 +28,26 @@ use Mtf\Fixture\FixtureInterface; /** * Class CheckoutData + * Data for fill product form on frontend + * * Data keys: * - preset (Checkout data verification preset name) */ class CheckoutData implements FixtureInterface { /** - * Current preset + * Data set configuration settings * - * @var string + * @var array */ - protected $currentPreset; + protected $params; + + /** + * Prepared dataSet data + * + * @var array + */ + protected $data; /** * @constructor @@ -48,9 +57,10 @@ class CheckoutData implements FixtureInterface public function __construct(array $params, array $data = []) { $this->params = $params; - $this->data = (isset($data['value']) && $data['value'] != '-') ? $data['value'] : null; - if (isset($data['preset'])) { - $this->currentPreset = $data['preset']; + $this->data = isset($data['preset']) ? $this->getPreset($data['preset']) : []; + + if (isset($data['value'])) { + $this->data = array_replace_recursive($this->data, $data['value']); } } @@ -90,14 +100,52 @@ class CheckoutData implements FixtureInterface /** * Return array preset * + * @param string $name * @return array|null */ - public function getPreset() + protected function getPreset($name) { - $presets = []; - if (!isset($presets[$this->currentPreset])) { - return null; - } - return $presets[$this->currentPreset]; + $presets = [ + 'MAGETWO-23062' => [ + 'custom_options' => [ + [ + 'title' => 0, + 'value' => 0 + ] + ] + ], + 'MAGETWO-23063' => [ + 'custom_options' => [ + [ + 'title' => 0, + 'value' => 0 + ] + ] + ], + 'options-suite' => [ + 'custom_options' => [ + [ + 'title' => 0, + 'value' => 'Field value 1 %isolation%' + ], + [ + 'title' => 1, + 'value' => 'Field value 2 %isolation%' + ], + [ + 'title' => 2, + 'value' => 1 + ], + [ + 'title' => 3, + 'value' => 0 + ] + ] + ], + 'order_default' => [ + 'qty' => 2 + ] + ]; + return isset($presets[$name]) ? $presets[$name] : null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php index 44b724c213585652e6bd59073c4e0dfb5674260d..041ae5ba6797562331dc3ddca0824b67cf715b88 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php @@ -72,6 +72,9 @@ class CatalogProductVirtual extends InjectableFixture $dataSet = '', $persist = false ) { + if (!isset($data['url_key']) && isset($data['name'])) { + $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); + } parent::__construct( $configuration, $repositoryFactory, @@ -82,10 +85,6 @@ class CatalogProductVirtual extends InjectableFixture $dataSet, $persist ); - - if (!isset($this->data['url_key']) && isset($this->data['name'])) { - $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); - } } protected $dataConfig = [ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CrosssellProducts.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CrosssellProducts.php index 54a9275c6b659f8d75c323e59b5822ac2912a736..94d0b6b3cafc785566641b5f40a25b82203494c5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CrosssellProducts.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CrosssellProducts.php @@ -24,9 +24,10 @@ namespace Magento\Catalog\Test\Fixture; -use Mtf\System\Config; use Mtf\Factory\Factory; use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Crosssell; +use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Related; +use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Upsell; class CrosssellProducts extends AssignProducts { diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php index a74300f52ce976db7e3150b1cc01531873a5e00b..daa44f210226cc50f772091fdba806218150103b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php @@ -162,7 +162,7 @@ class Product extends DataFixture ->getMagentoDownloadableDownloadableProductLinksNotPurchasedSeparately(); break; case 'configurable': - $product = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $product = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); break; default: throw new \InvalidArgumentException( diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ProductAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ProductAttribute.php index 96c3edb4b729505735394513710ddadae264ac11..a191a6283df6f4619284f3723347955af76a542e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ProductAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ProductAttribute.php @@ -45,9 +45,9 @@ class ProductAttribute extends DataFixture * * @return string */ - public function getAttributeLabel() + public function getFrontendLabel() { - return $this->getData('fields/attribute_label/value'); + return $this->getData('fields/frontend_label/value'); } /** @@ -131,7 +131,7 @@ class ProductAttribute extends DataFixture 'value' => 'attribute_code_%isolation%', 'group' => self::GROUP_PRODUCT_ATTRIBUTE_MAIN, ), - 'attribute_label' => array( + 'frontend_label' => array( 'value' => 'Attribute %isolation%', 'input_name' => 'frontend_label[0]', 'group' => self::GROUP_PRODUCT_ATTRIBUTE_MAIN diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/SimpleProduct.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/SimpleProduct.php index 5731eaf803a2bb2e370e22f2bd1f40a538d03749..040cce24086269c0df3fc366f32e397b4fbb480f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/SimpleProduct.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/SimpleProduct.php @@ -26,6 +26,10 @@ namespace Magento\Catalog\Test\Fixture; use Mtf\Factory\Factory; use Mtf\System\Config; +/** + * Class SimpleProduct + * Fixture simple product + */ class SimpleProduct extends Product { const PRICE_VALUE = 'price.value'; @@ -36,7 +40,7 @@ class SimpleProduct extends Product * @param Config $configuration * @param array $placeholders */ - public function __construct(Config $configuration, $placeholders = array()) + public function __construct(Config $configuration, $placeholders = []) { $this->_placeholders[self::PRICE_VALUE] = 10; @@ -49,12 +53,12 @@ class SimpleProduct extends Product protected function _initData() { parent::_initData(); - $this->_dataConfig = array( + $this->_dataConfig = [ 'constraint' => 'Success', - 'grid_filter' => array('name'), - 'create_url_params' => array('type' => 'simple', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID), + 'grid_filter' => ['name'], + 'create_url_params' => ['type' => 'simple', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID], 'input_prefix' => 'product' - ); + ]; $data = $this->_getPreparedData(); $this->_data['fields'] = array_merge($this->_data['fields'], $data); @@ -72,43 +76,43 @@ class SimpleProduct extends Product */ protected function _getPreparedData() { - return array( - 'price' => array( + return [ + 'price' => [ 'value' => '%' . self::PRICE_VALUE . '%', 'group' => static::GROUP_PRODUCT_DETAILS - ), - 'tax_class_id' => array( + ], + 'tax_class_id' => [ 'value' => 'Taxable Goods', 'input_value' => '2', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select' - ), - 'qty' => array( + ], + 'qty' => [ 'value' => 1000, 'group' => static::GROUP_PRODUCT_DETAILS, 'input_name' => 'product[quantity_and_stock_status][qty]' - ), - 'quantity_and_stock_status' => array( + ], + 'quantity_and_stock_status' => [ 'value' => 'In Stock', 'input_value' => 1, 'group' => static::GROUP_PRODUCT_DETAILS, 'input_name' => 'product[quantity_and_stock_status][is_in_stock]' - ), - 'weight' => array('value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS), - 'product_website_1' => array( + ], + 'weight' => ['value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS], + 'product_website_1' => [ 'value' => 'Yes', 'input_value' => 1, 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'product[website_ids][]' - ), - 'inventory_manage_stock' => array( + ], + 'inventory_manage_stock' => [ 'value' => 'No', 'input_value' => '0', 'group' => static::GROUP_PRODUCT_INVENTORY, 'input' => 'select', 'input_name' => 'product[stock_data][manage_stock]' - ), - ); + ], + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php index f2d5662eb7f4d4ae781c9f2c8aa8d1e7ada633ec..afd59f648f0f6ee40d71b6d64d2657cb5fe0edc2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php @@ -58,7 +58,10 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface 'Yes' => 1, 'No' => 0, ], - + 'is_configurable' => [ + 'Yes' => 1, + 'No' => 0, + ], ]; /** @@ -70,7 +73,6 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface */ public function persist(FixtureInterface $fixture = null) { - $data = $this->replaceMappingData($fixture->getData()); $data['frontend_label'] = [0 => $data['frontend_label']]; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php old mode 100644 new mode 100755 index 82523cf8cec15ed17936e1e1686b1de18d63a59e..b50bb378285d9dc85df40ae841cfda075146b6bf --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php @@ -161,6 +161,7 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface protected function prepareData(FixtureInterface $fixture, $prefix = null) { $fields = $this->replaceMappingData($fixture->getData()); + // Getting Tax class id if ($fixture->hasData('tax_class_id')) { $fields['tax_class_id'] = $fixture->getDataFieldConfig('tax_class_id')['source']->getTaxClassId(); @@ -201,6 +202,12 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface $fields['attribute_set_id'] = $attributeSetId; } + // Prepare assigned attribute + if (isset($fields['attributes'])) { + $fields += $fields['attributes']; + unset($fields['attributes']); + } + $fields = $this->prepareStockData($fields); $fields = $prefix ? [$prefix => $fields] : $fields; if ($isCustomOptions) { diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Ui.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Ui.php index 8d0d5918fcae5832c96a149de6bdf582af0ce350..386e930188124c081b516e28c997ed0eb8b48762 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Ui.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Ui.php @@ -50,9 +50,8 @@ class Ui extends AbstractUi implements CatalogProductSimpleInterface 'set' => $fixture->getDataConfig()['create_url_params']['set'] ]); - $productForm = $createProductPage->getProductForm(); - $productForm->fill($fixture); - $createProductPage->getFormAction()->save(); + $createProductPage->getProductForm()->fill($fixture); + $createProductPage->getFormPageActions()->save(); $createProductPage->getMessagesBlock()->assertSuccessMessage(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateProduct.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateProduct.php index 727d560c875f467a8904f705f89228eb5c514c4a..1552bdb046f15d7981a1eb21bf1f61a43f13f1f8 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateProduct.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateProduct.php @@ -50,9 +50,8 @@ class CreateProduct extends Ui 'set' => $fixture->getDataConfig()['create_url_params']['set'] ]); - $productForm = $createProductPage->getProductForm(); - $productForm->fill($fixture); - $createProductPage->getFormAction()->save(); + $createProductPage->getProductForm()->fill($fixture); + $createProductPage->getFormPageActions()->save(); $createProductPage->getMessagesBlock()->assertSuccessMessage(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductEdit.xml index f07500d222d36880d79462ca5949ebd63f8c5c6d..9cb150f6ab4f8932f303fe9d76a28827f055b232 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductEdit.xml @@ -25,30 +25,20 @@ --> <page mca="catalog/product/edit" module="Magento_Catalog"> <blocks> - <form> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </form> - <productForm> - <class>Magento\Catalog\Test\Block\Backend\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </productForm> - <configurableProductForm> - <class>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </configurableProductForm> - <formAction> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions</class> - <locator>.page-main-actions</locator> - <strategy>css selector</strategy> - </formAction> <messagesBlock> <class>Magento\Core\Test\Block\Messages</class> <locator>#messages .messages</locator> <strategy>css selector</strategy> </messagesBlock> + <formPageActions> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <productForm> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm</class> + <locator>[id="page:main-container"]</locator> + <strategy>css selector</strategy> + </productForm> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductNew.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductNew.xml index 3aed3088b939797eb75e775477a80dd7bb89b8d8..a56bb9d53594fcfb1c697f5af7850b58f612c982 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductNew.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductNew.xml @@ -25,35 +25,20 @@ --> <page mca="catalog/product/new" module="Magento_Catalog"> <blocks> - <form> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </form> - <productForm> - <class>Magento\Catalog\Test\Block\Backend\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </productForm> - <configurableProductForm> - <class>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </configurableProductForm> - <formAction> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions</class> - <locator>.page-main-actions</locator> - <strategy>css selector</strategy> - </formAction> - <affectedAttributeSetForm> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\AffectedAttributeSetForm</class> - <locator>#affected-attribute-set-form</locator> - <strategy>css selector</strategy> - </affectedAttributeSetForm> <messagesBlock> <class>Magento\Core\Test\Block\Messages</class> <locator>#messages .messages</locator> <strategy>css selector</strategy> </messagesBlock> + <formPageActions> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <productForm> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm</class> + <locator>[id="page:main-container"]</locator> + <strategy>css selector</strategy> + </productForm> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetAdd.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetAdd.xml index 611c03b7e9b9ad78e6ae2322bf434732f2154fe9..c569c0952f5d231c003222f5e94e3e60e587198c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetAdd.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetAdd.xml @@ -26,7 +26,7 @@ <page mca="catalog/product_set/add" module="Magento_Catalog"> <blocks> <pageActions> - <class>Magento\Backend\Test\Block\FormPageActions</class> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\FormPageActions</class> <locator>.page-main-actions</locator> <strategy>css selector</strategy> </pageActions> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml index e41ef0bf1858411493361cebcc4b23a81a298eb9..99e2db0b472d6301bf1dda57c3add6ac7ff629bd 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml @@ -32,7 +32,7 @@ </pageActions> <attributeSetEditBlock> <class>Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\Main</class> - <locator>#tree-div2</locator> + <locator>.attribute-set</locator> <strategy>css selector</strategy> </attributeSetEditBlock> <attributeSetEditForm> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetIndex.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetIndex.xml index d11ced488d653ca68882714b1d510577d79c94a6..3ae56b702733a5cbd14515b71892c33be0a97324 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetIndex.xml @@ -31,7 +31,7 @@ <strategy>css selector</strategy> </messagesBlock> <pageActionsBlock> - <class>Magento\Backend\Test\Block\GridPageActions</class> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\GridPageActions</class> <locator>.page-main-actions</locator> <strategy>css selector</strategy> </pageActionsBlock> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml index cefcabc57abcf5873a8e188c0c9cf8240ccf09ca..6fea5f301b14eb3a3404f0d8ea7defb851b6a83a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml @@ -40,11 +40,16 @@ <locator>.block.filter</locator> <strategy>css selector</strategy> </layeredNavigationBlock> - <toolbar> - <class>Magento\Catalog\Test\Block\Product\ProductList\Toolbar</class> - <locator>.toolbar-products</locator> - <strategy>css selector</strategy> - </toolbar> + <topToolbar> + <class>Magento\Catalog\Test\Block\Product\ProductList\TopToolbar</class> + <locator>.//*[contains(@class,"toolbar-products")][1]</locator> + <strategy>xpath</strategy> + </topToolbar> + <bottomToolbar> + <class>Magento\Catalog\Test\Block\Product\ProductList\BottomToolbar</class> + <locator>.//*[contains(@class,"toolbar-products")][2]</locator> + <strategy>xpath</strategy> + </bottomToolbar> <titleBlock> <class>Magento\Theme\Test\Block\Html\Title</class> <locator>.page-title h1.title .base</locator> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php old mode 100644 new mode 100755 index fd546ebee5d46f198345ad0893f35a68beb393cc..7c79a7148b445116aaa15358d307109cb85aae03 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php @@ -54,6 +54,7 @@ class CatalogProductAttribute extends AbstractRepository 'attribute_code' => 'attribute_dropdown%isolation%', 'frontend_input' => 'Dropdown', 'is_required' => 'No', + 'is_configurable' => 'Yes', 'options' => [ [ 'is_default' => 'Yes', @@ -72,5 +73,40 @@ class CatalogProductAttribute extends AbstractRepository ] ] ]; + + $this->_data['attribute_type_dropdown_two_options'] = [ + 'frontend_label' => 'attribute_dropdown%isolation%', + 'attribute_code' => 'attribute_dropdown%isolation%', + 'frontend_input' => 'Dropdown', + 'is_required' => 'No', + 'is_configurable' => 'Yes', + 'options' => [ + [ + 'is_default' => 'Yes', + 'admin' => 'black', + 'view' => 'option_0_%isolation%', + ], + [ + 'is_default' => 'No', + 'admin' => 'white', + 'view' => 'option_1_%isolation%', + ] + ] + ]; + + $this->_data['attribute_type_dropdown_one_option'] = [ + 'frontend_label' => 'attribute_dropdown%isolation%', + 'attribute_code' => 'attribute_dropdown%isolation%', + 'frontend_input' => 'Dropdown', + 'is_required' => 'No', + 'is_configurable' => 'Yes', + 'options' => [ + [ + 'is_default' => 'Yes', + 'admin' => 'black', + 'view' => 'option_0_%isolation%', + ], + ] + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php index b770f0bbc7370559c8a1706e0cb46db8e4d6399a..e115de5eaf6ca16e40175866209d6ea05643dbd5 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php @@ -56,6 +56,7 @@ class CatalogProductSimple extends AbstractRepository 'tax_class_id' => ['dataSet' => 'Taxable Goods'], 'website_ids' => ['Main Website'], 'visibility' => 'Catalog, Search', + 'checkout_data' => ['preset' => 'order_default'], ]; $this->_data['100_dollar_product'] = [ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/SimpleProduct.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/SimpleProduct.php index c3095b53af84106b483853bbf2d997e8d02415ed..b9766e52dae3bc53edb9c7121207bb2623c4e9c5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/SimpleProduct.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/SimpleProduct.php @@ -28,6 +28,7 @@ use Magento\Catalog\Test\Fixture; /** * Class Product Repository * + * Data for create simple product */ class SimpleProduct extends Product { @@ -48,14 +49,14 @@ class SimpleProduct extends Product /** * {inheritdoc} */ - public function __construct(array $defaultConfig = array(), array $defaultData = array()) + public function __construct(array $defaultConfig = [], array $defaultData = []) { parent::__construct($defaultConfig, $defaultData); $this->_data[self::ADVANCED_INVENTORY] = $this->getSimpleAdvancedInventory(); - $this->_data[self::NEW_CATEGORY] = array( + $this->_data[self::NEW_CATEGORY] = [ 'config' => $defaultConfig, 'data' => $this->buildSimpleWithNewCategoryData($defaultData) - ); + ]; $this->_data[self::ADVANCED_PRICING] = $this->getSimpleAdvancedPricing(); $this->_data[self::CUSTOM_OPTIONS] = $this->getSimpleCustomOption(); $this->_data[self::SIMPLE_WITH_MAP] = $this->getSimpleAppliedMap($defaultData); @@ -70,18 +71,18 @@ class SimpleProduct extends Product */ protected function buildSimpleWithNewCategoryData($defaultData) { - return array( - 'category_new' => array( - 'category_name' => array('value' => 'New category %isolation%'), - 'parent_category' => array('value' => 'Default') - ), + return [ + 'category_new' => [ + 'category_name' => ['value' => 'New category %isolation%'], + 'parent_category' => ['value' => 'Default'] + ], 'category_name' => '%category::getCategoryName%', 'category_id' => '%category::getCategoryId%', 'fields' => array_intersect_key( $defaultData['fields'], - array_flip(array('name', 'sku', 'price', 'weight', 'product_website_1')) + array_flip(['name', 'sku', 'price', 'weight', 'product_website_1']) ) - ); + ]; } /** @@ -91,14 +92,14 @@ class SimpleProduct extends Product */ protected function getSimpleAdvancedInventory() { - $inventory = array( - 'data' => array( - 'fields' => array( - 'inventory_manage_stock' => array('value' => 'Yes', 'input_value' => '1'), - 'inventory_qty' => array('value' => 1, 'group' => Fixture\Product::GROUP_PRODUCT_INVENTORY) - ) - ) - ); + $inventory = [ + 'data' => [ + 'fields' => [ + 'inventory_manage_stock' => ['value' => 'Yes', 'input_value' => '1'], + 'inventory_qty' => ['value' => 1, 'group' => Fixture\Product::GROUP_PRODUCT_INVENTORY] + ] + ] + ]; $product = array_replace_recursive($this->_data['simple'], $inventory); unset($product['data']['fields']['qty']); @@ -112,13 +113,13 @@ class SimpleProduct extends Product */ protected function getSimpleAdvancedPricing() { - $pricing = array( - 'data' => array( - 'fields' => array( - 'special_price' => array('value' => '9', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING) - ) - ) - ); + $pricing = [ + 'data' => [ + 'fields' => [ + 'special_price' => ['value' => '9', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING] + ] + ] + ]; $product = array_replace_recursive($this->_data['simple'], $pricing); return $product; @@ -132,13 +133,13 @@ class SimpleProduct extends Product { return array_replace_recursive( parent::resetRequiredFields($productType), - array( - 'data' => array( - 'fields' => array( - 'price' => array('value' => '1.99', 'group' => Fixture\Product::GROUP_PRODUCT_DETAILS) - ) - ) - ) + [ + 'data' => [ + 'fields' => [ + 'price' => ['value' => '1.99', 'group' => Fixture\Product::GROUP_PRODUCT_DETAILS] + ] + ] + ] ); } @@ -149,30 +150,30 @@ class SimpleProduct extends Product { return array_merge_recursive( $this->_data['simple'], - array( - 'data' => array( - 'fields' => array( - 'custom_options' => array( - 'value' => array( - array( + [ + 'data' => [ + 'fields' => [ + 'custom_options' => [ + 'value' => [ + [ 'title' => 'custom option drop down', 'is_require' => true, 'type' => 'Drop-down', - 'options' => array( - array( + 'options' => [ + [ 'title' => 'Title Drop - down 1', 'price' => 2.56, 'price_type' => 'Fixed', 'sku' => 'sku_drop_down_row_1' - ) - ) - ) - ), + ] + ] + ] + ], 'group' => Fixture\Product::GROUP_CUSTOM_OPTIONS - ) - ) - ) - ) + ] + ] + ] + ] ); } @@ -183,28 +184,28 @@ class SimpleProduct extends Product */ protected function getSimpleAppliedMap() { - $pricing = array( - 'data' => array( - 'fields' => array( - 'msrp_enabled' => array( + $pricing = [ + 'data' => [ + 'fields' => [ + 'msrp_enabled' => [ 'value' => 'Yes', 'input_value' => '1', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING, 'input' => 'select' - ), - 'msrp_display_actual_price_type' => array( + ], + 'msrp_display_actual_price_type' => [ 'value' => 'On Gesture', 'input_value' => '1', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING, 'input' => 'select' - ), - 'msrp' => array( + ], + 'msrp' => [ 'value' => '15', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING - ) - ) - ) - ); + ] + ] + ] + ]; $product = array_replace_recursive($this->_data['simple'], $pricing); return $product; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/AssignProductTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/AssignProductTest.php index 7e1fdc7b308b3a247eccdb54d7ef0d36954e1624..c3d8aae6597337160beaf4e11ef9801e853a1956 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/AssignProductTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/AssignProductTest.php @@ -44,7 +44,7 @@ class AssignProductTest extends Functional $simple = Factory::getFixtureFactory()->getMagentoCatalogSimpleProduct(); $simple->switchData('simple_required'); $simple->persist(); - $configurable = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $configurable = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $configurable->switchData('configurable_required'); $configurable->persist(); $bundle = Factory::getFixtureFactory()->getMagentoBundleBundleFixed(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php index b23622a1eedf002f3095dee160553626f13b2bad..08d3bfb537aee3fece265e111016c97e87e00619 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php @@ -64,7 +64,7 @@ class CreateGroupedTest extends Functional $manageProductsGrid->open(); $manageProductsGrid->getGridPageActionBlock()->addProduct('grouped'); $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php index fb8b7e41f1b1e3bbc0cee3e6338881e234400a2a..de826502d30a63d067371a569742d47dcdf2df40 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php @@ -60,7 +60,7 @@ class CreateProductTest extends Functional //Steps $createProductPage->open(['type' => 'simple', 'set' => 4]); $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache $cachePage = Factory::getPageFactory()->getAdminCache(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php index 5e9f56d36349a0e07b03852b8ee67d18cbed852a..d9f0e01a9dacc9e0fe8cb497ab70a0184babfe0b 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php @@ -112,8 +112,7 @@ class CreateSimpleProductEntityTest extends Injectable // Steps $this->productGrid->open(); $this->productGrid->getGridPageActionBlock()->addProduct('simple'); - $productBlockForm = $this->newProductPage->getForm(); - $productBlockForm->fill($product, null, $category); - $this->newProductPage->getFormAction()->save(); + $this->newProductPage->getProductForm()->fill($product, null, $category); + $this->newProductPage->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv index 2741e51bef7c09d7f87f9805a49b6a33f9392eea..ea731e709c5b8aa89794b9e17ae7a93eb5a579be 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv @@ -1,19 +1,19 @@ -"product/data/name";"product/data/sku";"product/data/tax_class_id/dataSet";"product/data/price/value";"product/data/special_price";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/qty";"product/data/quantity_and_stock_status/is_in_stock";"product/data/visibility";"product/data/custom_options/preset";"product/data/custom_options/import_products";"product/data/price/preset";"product/data/group_price/preset";"product/data/tier_price/preset";"constraint";"issue" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10000";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"50";"657";"-";"-";"MAGETWO-23062";"-";"MAGETWO-23062";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10001";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"51";"658";"-";"-";"MAGETWO-23063";"-";"MAGETWO-23063";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10002";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"52";"659";"-";"-";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10003";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"53";"660";"-";"-";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10004";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"54";"661";"-";"-";"MAGETWO-23063";"-";"MAGETWO-23030";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10005";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"55";"662";"-";"-";"MAGETWO-23062";"-";"MAGETWO-23029";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10006";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"56";"663";"-";"-";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10007";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"57";"664";"-";"-";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10008";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"58";"665";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductVisibleInCategory, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10009";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"59";"75";"In Stock";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInStock";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10010";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"60";"0";"Out of Stock";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductOutOfStock";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10011";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"61";"138";"-";"Search";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductSearchableBySku";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10012";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"62";"139";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductSearchableBySku, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10013";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"63";"140";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10014";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"64";"141";"-";"-";"-";"-";"-";"default";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductGroupedPriceOnProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10015";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"65";"142";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductSpecialPriceOnProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"None";"10016";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"66";"143";"-";"-";"-";"-";"-";"-";"default";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductTierPriceOnProductPage";"Bug: MAGETWO-26853" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10017";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"67";"144";"-";"-";"options-suite";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductCustomOptionsOnProductPage";"" +"product/data/name";"product/data/sku";"product/data/tax_class_id/dataSet";"product/data/price/value";"product/data/special_price";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/qty";"product/data/quantity_and_stock_status/is_in_stock";"product/data/visibility";"product/data/custom_options/preset";"product/data/checkout_data/preset";"product/data/custom_options/import_products";"product/data/price/preset";"product/data/group_price/preset";"product/data/tier_price/preset";"constraint";"issue" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10000";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"50";"657";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23062";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10001";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"51";"658";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23063";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10002";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"52";"659";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10003";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"53";"660";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10004";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"54";"661";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10005";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"55";"662";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10006";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"56";"663";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10007";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"57";"664";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10008";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"58";"665";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductVisibleInCategory, assertProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10009";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"59";"75";"In Stock";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInStock";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10010";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"60";"0";"Out of Stock";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductOutOfStock";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10011";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"61";"138";"-";"Search";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductSearchableBySku";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10012";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"62";"139";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductSearchableBySku, assertProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10013";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"63";"140";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10014";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"64";"141";"-";"-";"-";"-";"-";"-";"default";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductGroupedPriceOnProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10015";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"65";"142";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductSpecialPriceOnProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"None";"10016";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"66";"143";"-";"-";"-";"-";"-";"-";"-";"default";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductTierPriceOnProductPage";"Bug: MAGETWO-26853" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10017";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"67";"144";"-";"-";"options-suite";"options-suite";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductCustomOptionsOnProductPage";"" diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php index 6b011703794e1f68ced48372dc5b8ea28dc1ec6d..cd9e03f0bc6fdbfb2927137548f589e2aab6e1e8 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php @@ -65,9 +65,9 @@ class CreateSimpleWithCategoryTest extends Functional //Steps $productListPage->open(); $addProductBlock->addProduct(); - $productForm->addNewCategory($product); $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $productForm->addNewCategory($product); + $createProductPage->getFormPageActions()->save(); //Verifying $this->assertSuccessMessage("You saved the product."); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php index fc94695b1dc1855cc79e95635ceb7d80e297c4ef..9ec55181111651c0a29c2f695c27d05680c6fd52 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php @@ -56,7 +56,7 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional $product->switchData('simple_custom_options'); //Data $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); - $productForm = $createProductPage->getForm(); + $productForm = $createProductPage->getProductForm(); //Steps $createProductPage->open([ 'type' => $product->getDataConfig()['create_url_params']['type'], @@ -64,7 +64,7 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional ]); $category = $product->getCategories()['category']; $productForm->fill($product, null, $category); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache @@ -88,7 +88,7 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional $productGridPage->open(); /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Grid $gridBlock */ $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** @@ -116,11 +116,11 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional $price = $productViewBlock->getProductPrice(); $this->assertEquals(number_format($product->getProductPrice(), 2), $price['price_regular_price']); - $productOptionsBlock = $productPage->getCustomOptionsBlock(); + $productOptionsBlock = $productPage->getViewBlock()->getCustomOptionsBlock(); $fixture = $product->getData('fields/custom_options/value'); - $actualOptions = $productOptionsBlock->getOptions(); + $actualOptions = $productOptionsBlock->getOptions($product); $this->assertCount(count($fixture), $actualOptions); - $this->assertTrue(isset($actualOptions[$fixture[0]['title']]['title'])); - $this->assertEquals($fixture[0]['title'], $actualOptions[$fixture[0]['title']]['title']); + $this->assertTrue(isset($actualOptions['custom_options'][$fixture[0]['title']]['options'][0]['title'])); + $this->assertEquals($fixture[0]['title'], $actualOptions['custom_options'][$fixture[0]['title']]['title']); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php index f13d99a5e02e9cd4c0d0d1b9791243a2964cf22b..3af413238f310c887153bbd9d0ac5cc9c63aa173 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php @@ -63,7 +63,7 @@ class CreateTest extends Functional 'set' => $product->getDataConfig()['create_url_params']['set'] ]); $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache @@ -88,7 +88,7 @@ class CreateTest extends Functional $productGridPage->open(); /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Grid $gridBlock */ $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.php index 74c3de8495496efa10b70991194314a3be334aeb..238d9c95d817fa6ee55ec2135320bd6dcd1e9bae 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.php @@ -106,8 +106,7 @@ class CreateVirtualProductEntityTest extends Injectable // Steps $this->productGrid->open(); $this->productGrid->getGridPageActionBlock()->addProduct('virtual'); - $productBlockForm = $this->newProductPage->getForm(); - $productBlockForm->fill($product, null, $category); - $this->newProductPage->getFormAction()->save(); + $this->newProductPage->getProductForm()->fill($product, null, $category); + $this->newProductPage->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php index aba1a617e0aa68f384e0a86c01de2856ea4b2421..1c85047b1ee25100ea29e6f946962b0d80ddc332 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php @@ -60,7 +60,7 @@ class CreateVirtualTest extends Functional $productForm = $createProductPage->getProductForm(); //Steps $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php index 48e0e1ff1e73e184ed1527756a58ea24e817cf18..b2fd0411a4312f80d37ab42133f692265ed1e8b0 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php @@ -66,14 +66,9 @@ class EditSimpleProductTest extends Functional $cachePage = Factory::getPageFactory()->getAdminCache(); $productGridPage->open(); - $gridBlock->searchAndOpen( - [ - 'sku' => $product->getProductSku(), - 'type' => 'Simple Product' - ] - ); + $gridBlock->searchAndOpen(['sku' => $product->getProductSku(), 'type' => 'Simple Product']); $productForm->fill($editProduct); - $editProductPage->getFormAction()->save(); + $editProductPage->getFormPageActions()->save(); //Verifying $editProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UnassignCategoryTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UnassignCategoryTest.php index c6cf9dbd5790b42c91893e84433470d5aecc36c7..89ad44368f8394ee5ef177081ddb054b12fa5339 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UnassignCategoryTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UnassignCategoryTest.php @@ -61,7 +61,7 @@ class UnassignCategoryTest extends Functional $editProductPage->open(['id' => $simple->getProductId()]); $productForm = $editProductPage->getProductForm(); $productForm->clearCategorySelect(); - $editProductPage->getFormAction()->save(); + $editProductPage->getFormPageActions()->save(); //Verifying $editProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php index 2bf01a6dd0ec276adc58d0326695ba986199cd30..bdd824444589e662407e7f3aae6f116a82d50cb9 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php @@ -130,8 +130,7 @@ class UpdateSimpleProductEntityTest extends Injectable { $filter = ['sku' => $this->product->getSku()]; $this->productGrid->open()->getProductGrid()->searchAndOpen($filter); - $productBlockForm = $this->editProductPage->getForm(); - $productBlockForm->fill($product); - $this->editProductPage->getFormAction()->save(); + $this->editProductPage->getProductForm()->fill($product); + $this->editProductPage->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.php index 1d3781e35c6d6800bbe96bdad3bff939ef76acec..80f780cd37c26f9456cdf9fb6e11e64524cf27d1 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.php @@ -131,7 +131,7 @@ class UpdateVirtualProductEntityTest extends Injectable // Steps $this->productGrid->open(); $this->productGrid->getProductGrid()->searchAndOpen(['sku' => $this->product->getSku()]); - $this->editProductPage->getForm()->fill($product); - $this->editProductPage->getFormAction()->save(); + $this->editProductPage->getProductForm()->fill($product); + $this->editProductPage->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php index d434beda7b641e7a53d5004ee3d20c0ed2aa393d..601cec2327ffb9327c8d66ccda6c703b840fb06e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php @@ -28,7 +28,7 @@ use Mtf\TestCase\Injectable; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeNew; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeIndex; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; /** * Test Creation for Delete Used in Configurable ProductAttribute @@ -81,16 +81,16 @@ class DeleteUsedInConfigurableProductAttributeTest extends Injectable /** * Run Delete used in configurable product attribute test * - * @param CatalogProductConfigurable $product + * @param ConfigurableProductInjectable $product * @return array */ - public function test(CatalogProductConfigurable $product) + public function test(ConfigurableProductInjectable $product) { // Precondition $product->persist(); /** @var CatalogProductAttribute $attribute */ - $attribute = $product->getConfigurableAttributesData()['attributes'][0]; - + $attribute = $product->getDataFieldConfig('configurable_attributes_data')['source'] + ->getAttributes()['attribute_0']; // Steps $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen(['attribute_code' => $attribute->getAttributeCode()]); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest/test.csv b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest/test.csv index 0641a3d880d3d3b5e32e32fc1947b9691985edf0..161f8dc55635f2130b133b2ecf1ffbf33ae4afea 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest/test.csv +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest/test.csv @@ -1,2 +1,2 @@ "product/dataSet";"constraint" -"default_one_variation";"assertUsedSuperAttributeImpossibleDeleteMessages, assertProductAttributeInGrid, assertConfigurableProductForm" +"one_variation";"assertUsedSuperAttributeImpossibleDeleteMessages, assertProductAttributeInGrid, assertConfigurableProductForm" diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/constraint.xml index b709c5df439c1379af6f21c8d7e6d9046c0ac68f..25e94d915d6ea38b50473d69c70b2d97ef91a1f8 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/constraint.xml @@ -95,7 +95,7 @@ </require> </assertProductInCart> <assertProductPage module="Magento_Catalog"> - <severeness>low</severeness> + <severeness>middle</severeness> <require> <catalogProductView class="Magento\Catalog\Test\Page\Product\CatalogProductView" /> <product class="Mtf\Fixture\FixtureInterface" /> @@ -403,9 +403,6 @@ <assertProductAttributeAbsenceInUnassignedAttributes module="Magento_Catalog"> <severeness>low</severeness> </assertProductAttributeAbsenceInUnassignedAttributes> - <assertProductAttributeAbsenceInVariationsSearch module="Magento_Catalog"> - <severeness>low</severeness> - </assertProductAttributeAbsenceInVariationsSearch> <assertProductDuplicateMessage module="Magento_Catalog"> <severeness>high</severeness> <require> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml index 5a98b6e360203f9043e20308a8d3158c8afd922c..42c47d2b968c7c5265888d0f985515dbcdcfc61b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml @@ -59,41 +59,6 @@ <input_prefix>product</input_prefix> </data_config> </catalogProductSimple> - <catalogProductConfigurable module="Magento_Catalog"> - <type>eav</type> - <entity_type>catalog_product</entity_type> - <product_type>configurable</product_type> - <collection>Magento\Catalog\Model\Resource\Product\Collection</collection> - <identifier>sku</identifier> - <fields> - <id> - <attribute_code>id</attribute_code> - <backend_type>virtual</backend_type> - </id> - <type_id> - <attribute_code>type_id</attribute_code> - <backend_type>virtual</backend_type> - </type_id> - <attribute_set_id> - <attribute_code>attribute_set_id</attribute_code> - <backend_type>virtual</backend_type> - </attribute_set_id> - </fields> - <data_set> - <sku /> - <name /> - <short_description /> - <description /> - <tax_class_id /> - </data_set> - <data_config> - <create_url_params> - <type>configurable</type> - <set>4</set> - </create_url_params> - <input_prefix>product</input_prefix> - </data_config> - </catalogProductConfigurable> <catalogProductVirtual module="Magento_Catalog"> <type>eav</type> <entity_type>catalog_product</entity_type> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductsResult.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductsResult.php index d5659735afbb84e8fbeef6f8270e86f52e772e86..5f451dac7eee3caa39bb7686ebc220b914f7cb91 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductsResult.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductsResult.php @@ -95,7 +95,7 @@ class AssertAdvancedSearchProductsResult extends AbstractConstraint /** @var CatalogProductSimple $product */ $name = $product->getName(); $isProductVisible = $resultPage->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $resultPage->getToolbar()->nextPage()) { + while (!$isProductVisible && $resultPage->getBottomToolbar()->nextPage()) { $isProductVisible = $resultPage->getListProductBlock()->isProductVisible($product->getName()); } if (!$isProductVisible) { diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertCatalogSearchResult.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertCatalogSearchResult.php index cb4b1d9a82254316d0639d779fbc55e4fd3284f0..96486d72dc026c5ce8241a723326b5a25bfbfeb9 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertCatalogSearchResult.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertCatalogSearchResult.php @@ -53,7 +53,7 @@ class AssertCatalogSearchResult extends AbstractConstraint foreach ($products as $product) { $name = $product->getName(); $isProductVisible = $resultPage->getListProductBlock()->isProductVisible($name); - while (!$isProductVisible && $resultPage->getToolbar()->nextPage()) { + while (!$isProductVisible && $resultPage->getBottomToolbar()->nextPage()) { $isProductVisible = $resultPage->getListProductBlock()->isProductVisible($name); } diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedResult.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedResult.xml index 043d2ac4954883c9af692cced43a22a0d86c0e52..1595b810500688a76c5456a042c5656ab96bbe6d 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedResult.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedResult.xml @@ -30,11 +30,11 @@ <locator>.column.main</locator> <strategy>css selector</strategy> </searchResultBlock> - <toolbar> - <class>Magento\Catalog\Test\Block\Product\ProductList\Toolbar</class> + <bottomToolbar> + <class>Magento\Catalog\Test\Block\Product\ProductList\BottomToolbar</class> <locator>.column.main</locator> <strategy>css selector</strategy> - </toolbar> + </bottomToolbar> <listProductBlock> <class>Magento\Catalog\Test\Block\Product\ListProduct</class> <locator>.search.results</locator> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/CatalogsearchResult.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/CatalogsearchResult.xml index efc42a591f70d14c8f35f0804844369dc3ccb526..4e639b2039ec1dd477dd908aacd94646feb897b5 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/CatalogsearchResult.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/CatalogsearchResult.xml @@ -30,10 +30,10 @@ <locator>.search.results</locator> <strategy>css selector</strategy> </listProductBlock> - <toolbar> - <class>Magento\Catalog\Test\Block\Product\ProductList\Toolbar</class> - <locator>.toolbar.products</locator> - <strategy>css selector</strategy> - </toolbar> + <bottomToolbar> + <class>Magento\Catalog\Test\Block\Product\ProductList\BottomToolbar</class> + <locator>.//*[contains(@class,"toolbar-products")][2]</locator> + <strategy>xpath</strategy> + </bottomToolbar> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchTest.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchTest.php index 7c5c437ef25f71ee70344460f144fd0bd146f31b..b91c88f1ed0c90737d0c4df0b714a69ae54fc419 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchTest.php @@ -30,7 +30,6 @@ use Mtf\TestCase\Functional; /** * Class AdvancedSearchTest * Searching product in the Frontend via advanced search - * */ class AdvancedSearchTest extends Functional { @@ -41,6 +40,7 @@ class AdvancedSearchTest extends Functional */ public function testProductSearch() { + $this->markTestIncomplete('MAGETWO-27664'); //Data $productFixture = Factory::getFixtureFactory()->getMagentoCatalogSimpleProduct(); $productFixture->switchData('simple'); diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php index fdf1e8c4aa5159fcd9936af03f05cd0a5a0a2167..22278d1c4aa259c8da4e0d30302f61f095884249 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php @@ -21,15 +21,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + namespace Magento\Checkout\Test\Block; use Exception; use Mtf\Block\Block; use Mtf\Factory\Factory; use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Fixture\Product; -use Magento\Catalog\Test\Fixture\SimpleProduct; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; use Magento\Checkout\Test\Block\Onepage\Link; use Mtf\Fixture\FixtureInterface; @@ -39,40 +37,28 @@ use Mtf\Fixture\FixtureInterface; */ class Cart extends Block { + // @codingStandardsIgnoreStart /** - * Proceed to checkout block - * - * @var string - */ - protected $onepageLinkBlock = '.action.primary.checkout'; - - /** - * 'Clear Shopping Cart' button - * - * @var string - */ - protected $clearShoppingCart = '#empty_cart_button'; - - /** - * Cart item sub-total xpath selector + * Selector for cart item block * * @var string */ - protected $itemSubTotalSelector = '//td[@class="col subtotal"]//*[@class="excl tax"]//span[@class="price"]'; + protected $cartItemByProductName = './/tr[contains(@class,"item-info") and (.//*[contains(@class,"product-item-name")]/a[.="%s"])]'; + // @codingStandardsIgnoreEnd /** - * Cart item unit price xpath selector + * Proceed to checkout block * * @var string */ - protected $itemUnitPriceSelector = '//td[@class="col price"]//*[@class="excl tax"]//span[@class="price"]'; + protected $onepageLinkBlock = '.action.primary.checkout'; /** - * Unit Price value + * 'Clear Shopping Cart' button * * @var string */ - protected $cartProductPrice = '//tr[string(td/div/strong/a)="%s"]/td[@class="col price"]/*[@class="excl tax"]/span'; + protected $clearShoppingCart = '#empty_cart_button'; /** * 'Update Shopping Cart' button @@ -82,115 +68,21 @@ class Cart extends Block protected $updateShoppingCart = '[name="update_cart_action"]'; /** - * Quantity input selector - * - * @var string - */ - protected $productQty = '//input[@type="number" and @title="Qty"]'; - - /** - * Cart item selector - * - * @var string - */ - protected $cartItem = './/tr[td//*[contains(.,"%s")]]'; - - /** - * Get bundle options - * - * @var string - */ - protected $bundleOptions = './/dl[contains(@class, "cart-item-options")]/dd[%d]/span[@class="price"][%d]'; - - /** - * Get sub-total for the specified item in the cart - * - * @param SimpleProduct $product - * @return string - */ - public function getCartItemSubTotal($product) - { - $selector = sprintf($this->cartItem, $this->getProductName($product)) . $this->itemSubTotalSelector; - return $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText(); - } - - /** - * Get sub-total for the specified item in the cart by product name - * - * @param string $productName - * @return string - */ - public function getCartItemSubTotalByProductName($productName) - { - $selector = sprintf($this->cartItem, $productName) . $this->itemSubTotalSelector; - $itemSubtotal = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($itemSubtotal); - } - - /** - * Get unit price for the specified item in the cart + * Get cart item block * * @param FixtureInterface $product - * @param string $currency - * @return float + * @return \Magento\Checkout\Test\Block\Cart\CartItem */ - public function getCartItemUnitPrice($product, $currency = '$') + public function getCartItem(FixtureInterface $product) { - $selector = sprintf($this->cartItem, $this->getProductName($product)) . $this->itemUnitPriceSelector; - $prices = explode("\n", trim($this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText())); - return floatval(trim($prices[0], $currency)); - } - - /** - * Get product options in the cart - * - * @param Product $product - * @return string - */ - public function getCartItemOptions($product) - { - $selector = '//tr[string(td/div/strong/a)="' . $this->getProductName($product) - . '"]//dl[@class="cart item options"]'; - - $optionsBlock = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH); - if (!$optionsBlock->isVisible()) { - return ''; - } - return $optionsBlock->getText(); - } - - /** - * Get product options value in the cart by product name - * - * @param string $productName - * @return string - */ - public function getCartItemOptionsNameByProductName($productName) - { - $selector = '//tr[string(td/div/strong/a)="' . $productName . '"]//dl[@class="cart-item-options"]//dt'; - - $optionsBlock = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH); - if (!$optionsBlock->isVisible()) { - return ''; - } - return $optionsBlock->getText(); - } - - /** - * Get product options value in the cart by product name - * - * @param string $productName - * @return string - */ - public function getCartItemOptionsValueByProductName($productName) - { - $selector = '//tr[string(td/div/strong/a)="' . $productName . '"]//dl[@class="cart-item-options"]//dd'; - - $optionsBlock = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH); - if (!$optionsBlock->isVisible()) { - return ''; - } - return $optionsBlock->getText(); + $cartItem = $this->_rootElement->find( + sprintf($this->cartItemByProductName, $product->getName()), + Locator::SELECTOR_XPATH + ); + return $this->blockFactory->create( + 'Magento\Checkout\Test\Block\Cart\CartItem', + ['element' => $cartItem] + ); } /** @@ -218,7 +110,6 @@ class Cart extends Block /** * Returns the total discount price * - * @var string * @return string * @throws Exception */ @@ -252,46 +143,12 @@ class Cart extends Block /** * Check if a product has been successfully added to the cart * - * @param Product $product - * @return boolean - */ - public function isProductInShoppingCart($product) - { - return $this->_rootElement->find( - sprintf($this->cartItem, $this->getProductName($product)), - Locator::SELECTOR_XPATH - )->isVisible(); - } - - /** - * Return the name of the specified product. - * * @param FixtureInterface $product - * @return string - */ - private function getProductName($product) - { - $productName = $product->getName(); - if ($product instanceof ConfigurableProduct) { - $productOptions = $product->getProductOptions(); - if (!empty($productOptions)) { - $productName = $productName . '")] and *[contains(.,"' . current($productOptions); - } - } - return $productName; - } - - /** - * Get product price "Unit Price" by product name - * - * @param $productName - * @return string + * @return boolean */ - public function getProductPriceByName($productName) + public function isProductInShoppingCart(FixtureInterface $product) { - $priceSelector = sprintf($this->cartProductPrice, $productName); - $cartProductPrice = $this->_rootElement->find($priceSelector, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($cartProductPrice); + return $this->getCartItem($product)->isVisible(); } /** @@ -303,55 +160,4 @@ class Cart extends Block { $this->_rootElement->find($this->updateShoppingCart, Locator::SELECTOR_CSS)->click(); } - - /** - * Set product quantity - * - * @param string $productName - * @param int $qty - * @return void - */ - public function setProductQty($productName, $qty) - { - $productQtySelector = sprintf($this->cartItem, $productName) . $this->productQty; - $this->_rootElement->find($productQtySelector, Locator::SELECTOR_XPATH)->setValue($qty); - } - - /** - * Get product quantity - * - * @param string $productName - * @return string - */ - public function getProductQty($productName) - { - $productQtySelector = sprintf($this->cartItem, $productName) . $this->productQty; - return $this->_rootElement->find($productQtySelector, Locator::SELECTOR_XPATH)->getValue(); - } - - /** - * Method that escapes currency symbols - * - * @param string $price - * @return string - */ - protected function escapeCurrency($price) - { - preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); - return (isset($matches[1])) ? $matches[1] : null; - } - - /** - * Get item Bundle options - * - * @param int $index - * @param int $itemIndex - * @param string $currency - * @return string - */ - public function getPriceBundleOptions($index, $itemIndex = 1, $currency = '$') - { - $formatPrice = sprintf($this->bundleOptions, $index, $itemIndex); - return trim($this->_rootElement->find($formatPrice, Locator::SELECTOR_XPATH)->getText(), $currency); - } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php new file mode 100755 index 0000000000000000000000000000000000000000..6e5090d9e726b72aa1ade6adaa6a839b050c764e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php @@ -0,0 +1,181 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Test\Block\Cart; + +use Mtf\Block\Block; +use Mtf\Client\Element\Locator; + +/** + * Class CartItem + * Product item block on checkout page + */ +class CartItem extends Block +{ + /** + * Selector for options block + * + * @var string + */ + protected $optionsBlock = './/dl[@class="cart-item-options"]'; + + /** + * Selector for unit price + * + * @var string + */ + protected $price = './/td[@class="col price"]/*[@class="excl tax"]/span'; + + /** + * Quantity input selector + * + * @var string + */ + protected $qty = './/input[@type="number" and @title="Qty"]'; + + /** + * Cart item sub-total xpath selector + * + * @var string + */ + protected $subtotalPrice = './/td[@class="col subtotal"]//*[@class="excl tax"]//span[@class="price"]'; + + /** + * Get bundle options + * + * @var string + */ + protected $bundleOptions = './/dl[contains(@class, "cart-item-options")]/dd[%d]/span[@class="price"][%d]'; + + /** + * Get product price + * + * @return string + */ + public function getPrice() + { + $cartProductPrice = $this->_rootElement->find($this->price, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($cartProductPrice); + } + + /** + * Set product quantity + * + * @param int $qty + * @return void + */ + public function setQty($qty) + { + $this->_rootElement->find($this->qty, Locator::SELECTOR_XPATH)->setValue($qty); + } + + /** + * Get product quantity + * + * @return string + */ + public function getQty() + { + return $this->_rootElement->find($this->qty, Locator::SELECTOR_XPATH)->getValue(); + } + + /** + * Get sub-total for the specified item in the cart + * + * @return string + */ + public function getSubtotalPrice() + { + $price = $this->_rootElement->find($this->subtotalPrice, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($price); + } + + /** + * Method that escapes currency symbols + * + * @param string $price + * @return string + */ + protected function escapeCurrency($price) + { + preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); + return (isset($matches[1])) ? $matches[1] : null; + } + + /** + * Get product options in the cart + * + * @return string + */ + public function getOptions() + { + $optionsBlock = $this->_rootElement->find($this->optionsBlock, Locator::SELECTOR_XPATH); + if (!$optionsBlock->isVisible()) { + return ''; + } + return $optionsBlock->getText(); + } + + /** + * Get product options name in the cart + * + * @return string + */ + public function getOptionsName() + { + $optionsName = $this->_rootElement->find($this->optionsBlock . '//dt', Locator::SELECTOR_XPATH); + if (!$optionsName->isVisible()) { + return ''; + } + return $optionsName->getText(); + } + + /** + * Get product options value in the cart + * + * @return string + */ + public function getOptionsValue() + { + $optionsValue = $this->_rootElement->find($this->optionsBlock . '//dd', Locator::SELECTOR_XPATH); + if (!$optionsValue->isVisible()) { + return ''; + } + return $optionsValue->getText(); + } + + /** + * Get item Bundle options + * + * @param int $index + * @param int $itemIndex [optional] + * @param string $currency [optional] + * @return string + */ + public function getPriceBundleOptions($index, $itemIndex = 1, $currency = '$') + { + $formatPrice = sprintf($this->bundleOptions, $index, $itemIndex); + return trim($this->_rootElement->find($formatPrice, Locator::SELECTOR_XPATH)->getText(), $currency); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php old mode 100644 new mode 100755 index 96949593e8a2f6e800368ee43601409b3e55859d..4dedaae48d82299ec614a9bac557e28504117a02 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php @@ -54,7 +54,8 @@ class AssertPriceInShoppingCart extends AbstractConstraint Cart $cart, CatalogProductSimple $product ) { - $cartProductPrice = $checkoutCart->open()->getCartBlock()->getProductPriceByName($product->getName()); + $checkoutCart->open(); + $cartProductPrice = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); \PHPUnit_Framework_Assert::assertEquals( $cartProductPrice, $cart->getPrice(), diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php old mode 100644 new mode 100755 index fa27cfce7b78115ef2a39c2a2be782eb5d2230d0..a2c800226f26c8a8ab9624fd94ad00e939602a85 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php @@ -54,7 +54,8 @@ class AssertProductQtyInShoppingCart extends AbstractConstraint Cart $cart, CatalogProductSimple $product ) { - $cartProductQty = $checkoutCart->open()->getCartBlock()->getProductQty($product->getName()); + $checkoutCart->open(); + $cartProductQty = $checkoutCart->getCartBlock()->getCartItem($product)->getQty(); \PHPUnit_Framework_Assert::assertEquals( $cartProductQty, $cart->getQty(), diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php old mode 100644 new mode 100755 index c788bc26dcb83d757f0033698828771be13a2918..ceb3b5f45f13908cf38c7ae4c5bd2d16523335ee --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php @@ -54,8 +54,8 @@ class AssertSubtotalInShoppingCart extends AbstractConstraint Cart $cart, CatalogProductSimple $product ) { - $cartProductSubtotal = $checkoutCart->open()->getCartBlock() - ->getCartItemSubTotalByProductName($product->getName()); + $checkoutCart->open(); + $cartProductSubtotal = $checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPrice(); \PHPUnit_Framework_Assert::assertEquals( $cartProductSubtotal, $cart->getRowTotal(), diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Handler/CmsPage/Curl.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Handler/CmsPage/Curl.php index c348ea65ba8750bb0d50c3724313baea58369f55..24505b7d5c72680f7d27f4ed701d6d377e593b28 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Handler/CmsPage/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Handler/CmsPage/Curl.php @@ -67,7 +67,7 @@ class Curl extends Conditions implements CmsPageInterface * * @var string */ - protected $url = 'admin/cms_page/save/back/edit/active_tab/content_section/'; + protected $url = 'cms/page/save/back/edit/active_tab/content_section/'; /** * Post request for creating a cms page diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php old mode 100644 new mode 100755 similarity index 69% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php index 97788285960a6d41744368818b8ae9ecc189e873..db163a29a8f30283045dbea3e80b67c3225ecf54 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Block\Adminhtml\Product; +namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product; use Mtf\Client\Element; use Mtf\Client\Element\Locator; @@ -33,15 +33,8 @@ use Magento\Backend\Test\Block\Widget\Form as ParentForm; * Class AffectedAttributeSet * Choose affected attribute set dialog popup window */ -class AffectedAttributeSetForm extends ParentForm +class AffectedAttributeSet extends ParentForm { - /** - * 'Confirm' button container locator - * - * @var string - */ - protected $confirmButtonContainer = '//parent::div[div[@id="affected-attribute-set-form"]]'; - /** * 'Confirm' button locator * @@ -60,18 +53,21 @@ class AffectedAttributeSetForm extends ParentForm * Fill popup form * * @param FixtureInterface $product - * @param Element|null $element + * @param Element|null $element [optional] * @return $this */ public function fill(FixtureInterface $product, Element $element = null) { - $data = $product->getData('affect_configurable_product_attributes'); - if (!empty($data)) { - $this->_rootElement->find($this->affectedAttributeSetNew)->click(); - $fields = ['new_attribute_set_name' => strval($data)]; + $affectedAttributeSet = $product->getData('affected_attribute_set'); + + if ($affectedAttributeSet) { + $fields = ['new_attribute_set_name' => $affectedAttributeSet]; $mapping = $this->dataMapping($fields); + + $this->_rootElement->find($this->affectedAttributeSetNew)->click(); $this->_fill($mapping, $element); } + return $this; } @@ -82,16 +78,6 @@ class AffectedAttributeSetForm extends ParentForm */ public function confirm() { - $isVisible = $this->_rootElement->find( - $this->confirmButtonContainer . $this->confirmButton, - Locator::SELECTOR_XPATH - )->isVisible(); - - if ($isVisible) { - $this->_rootElement->find( - $this->confirmButtonContainer . $this->confirmButton, - Locator::SELECTOR_XPATH - )->click(); - } + $this->_rootElement->find($this->confirmButton, Locator::SELECTOR_XPATH)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.xml old mode 100644 new mode 100755 similarity index 100% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.xml rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.xml diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php deleted file mode 100644 index 2dba0bd3cbe63eda09e5b3e5d73170906931de21..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Block\Block; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; - -/** - * Class Attribute - * Attribute block in Variation section - */ -class Attribute extends Block -{ - /** - * Attribute option pricing value - * - * @var string - */ - protected $pricingValue = '[name*=pricing_value]'; - - /** - * Attribute option price type button - * - * @var string - */ - protected $priceTypeButton = '[data-toggle=dropdown]'; - - /** - * Attribute option price type value - * - * @var string - */ - protected $priceTypeValue = '//*[@data-role="dropdown-menu"]'; - - /** - * Attribute option Include checkbox - * - * @var string - */ - protected $include = '[data-column=include ] [type=checkbox]'; - - /** - * Attribute option Label - * - * @var string - */ - protected $labelValue = 'input[class=required-entry][name*=value]'; - - /** - * Attribute option row - * - * @var string - */ - protected $attributeRow = '//*[@data-role="options"]/tr[%row%]'; - - /** - * Add option selector - * - * @var string - */ - protected $addOption = '[data-action="add-option"]'; - - /** - * Fill in data to attribute options - * - * @param array $fields - */ - public function fillAttributeOptions(array $fields) - { - $row = 0; - foreach ($fields['options'] as $option) { - if (!empty($option['name'])) { - $optionRow = $this->getOptionRow($option['name']); - if (!$optionRow->isVisible()) { - $this->_rootElement->find($this->addOption)->click(); - $optionRow = $this->getOptionNewRow($row); - if (isset($option['name'])) { - $optionRow->find($this->labelValue)->setValue($option['name']); - } - } - if (isset($option['pricing_value'])) { - $optionRow->find($this->pricingValue, Locator::SELECTOR_CSS) - ->setValue($option['pricing_value']); - } - if (isset($option['is_percent']) && $option['is_percent'] == 'Yes') { - $optionRow->find($this->priceTypeButton, Locator::SELECTOR_CSS)->click(); - $optionRow->find($this->priceTypeValue . '//a[text()="%"]', Locator::SELECTOR_XPATH)->click(); - } - $optionRow->find($this->include, Locator::SELECTOR_CSS, 'checkbox') - ->setValue($option['include']); - } - ++$row; - } - } - - /** - * Get option row - * - * @param string $optionLabel - * @return Element - */ - protected function getOptionRow($optionLabel) - { - return $this->_rootElement->find('//tr[td="' . $optionLabel . '"]', Locator::SELECTOR_XPATH); - } - - /** - * Get option new row - * - * @param int $row - * @return Element - */ - protected function getOptionNewRow($row) - { - return $this->_rootElement->find(str_replace('%row%', $row, $this->attributeRow), Locator::SELECTOR_XPATH); - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php old mode 100644 new mode 100755 index ebf6a8a5209755a01d1d2b1d4056049a356d2ad0..dbaf43e4e35ab35a7577a1260791c237433ca69d --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php @@ -24,131 +24,43 @@ namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super; -use Mtf\Client\Element; -use Mtf\Factory\Factory; -use Mtf\Client\Element\Locator; use Magento\Backend\Test\Block\Widget\Tab; +use Mtf\Client\Element; +use Magento\Catalog\Test\Fixture\CatalogCategory; /** - * Class Variations + * Class Config * Adminhtml catalog super product configurable tab */ class Config extends Tab { /** - * 'Generate Variations' button - * - * @var string - */ - protected $generateVariations = '[data-ui-id=product-variations-generator-generate]'; - - /** - * Product variations matrix block - * - * @var string - */ - protected $matrixBlock = '[data-role=product-variations-matrix] table'; - - /** - * Product attribute block selector by attribute name + * Selector for trigger show/hide "Variations" tab * * @var string */ - protected $attribute = '//div[*/*/span[contains(text(), "%s")]]'; + protected $variationsTabTrigger = '[data-panel="product-variations"] .title'; /** - * Magento loader + * Selector for content "Variations" tab * * @var string */ - protected $loader = './ancestor::body//*[contains(@data-role,"loader")]'; + protected $variationsTabContent = '#super_config-content'; /** - * Attribute Opened + * Selector for button "Generate Variations" * * @var string */ - protected $attributeOpen = './/*[@class = "title active"]/span[text()="%attributeLabel%"]'; + protected $generateVariations = '[data-ui-id="product-variations-generator-generate"]'; /** - * Attribute tab + * Selector for variations matrix * * @var string */ - protected $attributeTab = './/*[@data-role="configurable-attribute"]//*[text()="%attributeTab%"]'; - - /** - * XPath Selector attribute variations row content - * - * @var string - */ - protected $activeButtonSelector = '//*[contains(@class,"fieldset-wrapper-title")]//*[@class="title"]'; - - /** - * XPath Selector attribute variations row - * - * @var string - */ - protected $rowSelector = '//div[contains(@data-role,"configurable-attribute") and position()=%d]'; - - /** - * XPath Selector attribute options row - * - * @var string - */ - protected $rowOptions = './/tbody/tr[contains(@data-role,"option-container") and position()=%d]'; - - /** - * XPath Selector attribute options row - * - * @var string - */ - protected $rowMatrix = './/tbody/tr[contains(@data-role,"row") and position()=%d]'; - - /** - * CSS selector variations label - * - * @var string - */ - protected $labelSelector = '.store-label'; - - /** - * Get attribute block - * - * @param string $attributeName - * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Attribute - */ - public function getAttributeBlock($attributeName) - { - $attributeSelector = sprintf($this->attribute, $attributeName); - $this->waitForElementVisible($attributeSelector, Locator::SELECTOR_XPATH); - return Factory::getBlockFactory()->getMagentoConfigurableProductAdminhtmlProductEditTabSuperAttribute( - $this->_rootElement->find($attributeSelector, Locator::SELECTOR_XPATH) - ); - } - - /** - * Get product variations matrix block - * - * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix - */ - protected function getMatrixBlock() - { - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlProductEditTabSuperConfigMatrix( - $this->_rootElement->find($this->matrixBlock, Locator::SELECTOR_CSS) - ); - } - - /** - * Press 'Generate Variations' button - * - * @return void - */ - public function generateVariations() - { - $this->_rootElement->find($this->generateVariations, Locator::SELECTOR_CSS)->click(); - $this->waitForElementVisible($this->matrixBlock, Locator::SELECTOR_CSS); - } + protected $variationsMatrix = '[data-role="product-variations-matrix"]'; /** * Fill variations fieldset @@ -159,146 +71,89 @@ class Config extends Tab */ public function fillFormTab(array $fields, Element $element = null) { - if (!isset($fields['configurable_attributes_data'])) { - return $this; - } - $attributes = $fields['configurable_attributes_data']['value']; - foreach ($attributes['attributes_data'] as $attribute) { - $this->selectAttribute($attribute['title']); + $attributes = isset($fields['configurable_attributes_data']['value']) + ? $fields['configurable_attributes_data']['value'] + : []; + + $this->showContent(); + + if (!empty($attributes['attributes_data'])) { + $this->getAttributeBlock()->fillAttributes($attributes['attributes_data']); } - $this->fillAttributeOptions($attributes); - $this->generateVariations(); if (!empty($attributes['matrix'])) { - $this->fillVariationsMatrix($attributes['matrix']); + $this->generateVariations(); + $this->getVariationsBlock()->fillVariations($attributes['matrix']); } return $this; } /** - * Fill variations matrix + * Show "Variations" tab content * - * @param array $fields * @return void */ - public function fillVariationsMatrix(array $fields) + public function showContent() { - $this->getMatrixBlock()->fillVariation($fields); + $content = $this->_rootElement->find($this->variationsTabContent); + if (!$content->isVisible()) { + $this->_rootElement->find($this->variationsTabTrigger)->click(); + $this->waitForElementVisible($this->variationsTabContent); + } } /** - * Fill attribute options + * Generate variations * - * @param array $attributes * @return void */ - public function fillAttributeOptions(array $attributes) + public function generateVariations() { - foreach ($attributes['attributes_data'] as $attribute) { - $this->getAttributeBlock($attribute['title'])->fillAttributeOptions($attribute); - } + $this->_rootElement->find($this->generateVariations)->click(); + $this->waitForElementVisible($this->variationsMatrix); } /** - * Select attribute for variations + * Get block of attributes * - * @param string $attributeName - * @return void + * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute */ - private function selectAttribute($attributeName) + public function getAttributeBlock() { - // TODO should be removed after suggest widget implementation as typified element - $attributeFieldSet = $this->_rootElement - ->find(str_replace('%attributeLabel%', $attributeName, $this->attributeOpen), Locator::SELECTOR_XPATH); - $attributeVisible = $this->_rootElement - ->find(str_replace('%attributeTab%', $attributeName, $this->attributeTab), Locator::SELECTOR_XPATH); - if ($attributeVisible->isVisible()) { - if (!$attributeFieldSet->isVisible()) { - $attributeVisible->click(); - } - } else { - $this->_rootElement->find('#configurable-attribute-selector')->setValue($attributeName); - $attributeListLocation = '#variations-search-field .mage-suggest-dropdown'; - $this->waitForElementVisible($attributeListLocation, Locator::SELECTOR_CSS); - $attribute = $this->_rootElement->find( - "//div[@class='mage-suggest-dropdown']//a[text()='$attributeName']", - Locator::SELECTOR_XPATH - ); - $attribute->waitUntil( - function () use ($attribute) { - return $attribute->isVisible() ? true : null; - } - ); - $attribute->click(); - } + return $this->blockFactory->create( + '\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute', + ['element' => $this->_rootElement] + ); } /** - * Get data of tab + * Get block of variations * - * @param array|null $fields [optional] - * @param Element|null $element [optional] - * @return array + * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix */ - public function getDataFormTab($fields = null, Element $element = null) + public function getVariationsBlock() { - $dataResult = []; - if (isset($fields['configurable_attributes_data']['value']['attributes_data'])) { - $field['attributes_data']['value'] = $fields['configurable_attributes_data']['value']['attributes_data']; - $data = $this->dataMapping($field)['attributes_data']; - $variationsBlock = $this->_rootElement->find($data['selector']); - - foreach ($data['value'] as $key => $value) { - ++$key; - $this->openVariation($key, $variationsBlock); - $row = $variationsBlock->find(sprintf($this->rowSelector, $key), Locator::SELECTOR_XPATH); - --$key; - $dataResult['attributes_data'][$key]['title'] = $row->find($this->labelSelector)->getValue(); - $dataResult['attributes_data'][$key]['options'] = []; - foreach ($value['options'] as $optionKey => $option) { - ++$optionKey; - $optionsForm = $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Options', - ['element' => $row->find(sprintf($this->rowOptions, $optionKey), Locator::SELECTOR_XPATH)] - ); - $dataResult['attributes_data'][$key]['options'][] = $optionsForm->getDataOptions($option); - } - } - } - if (isset($fields['configurable_attributes_data']['value']['matrix'])) { - $field['matrix']['value'] = $fields['configurable_attributes_data']['value']['matrix']; - $data = $this->dataMapping($field)['matrix']; - $matrixBlock = $this->_rootElement->find($data['selector']); - - $index = 1; - foreach ($data['value'] as $key => $value) { - $matrixCell = $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Matrix', - ['element' => $matrixBlock->find(sprintf($this->rowMatrix, $index), Locator::SELECTOR_XPATH)] - ); - $dataResult['matrix'][$key] = $matrixCell->getDataOptions(); - ++$index; - } - } - - return ['configurable_attributes_data' => $dataResult]; + return $this->blockFactory->create( + '\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix', + ['element' => $this->_rootElement->find($this->variationsMatrix)] + ); } /** - * Active variation tab + * Get data of tab * - * @param int $row - * @param Element $variationsBlock - * @return void + * @param array|null $fields + * @param Element|null $element + * @return array */ - protected function openVariation($row, Element $variationsBlock) + public function getDataFormTab($fields = null, Element $element = null) { - $element = $variationsBlock->find( - sprintf($this->rowSelector, $row) . $this->activeButtonSelector, - Locator::SELECTOR_XPATH - ); - if ($element->isVisible()) { - $element->click(); - } + $data = []; + + $this->showContent(); + $data['attributes_data'] = $this->getAttributeBlock()->getAttributesData(); + $data['matrix'] = $this->getVariationsBlock()->getVariationsData(); + + return ['configurable_attributes_data' => $data]; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php new file mode 100755 index 0000000000000000000000000000000000000000..5dce160b4ccb247efacdbc952f96a2eac3d41e55 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php @@ -0,0 +1,381 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config; + +use Mtf\Client\Element\Locator; +use Mtf\Client\Driver\Selenium\Element; +use Magento\Backend\Test\Block\Widget\Form; +use Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute\AttributeSelector; + +/** + * Class Attribute + * Attribute block in Variation section + */ +class Attribute extends Form +{ + /** + * Mapping fields for get values of form + * + * @var array + */ + protected $mappingGetFields = [ + 'label' => [ + 'selector' => 'td[data-column="name"]', + 'strategy' => Locator::SELECTOR_CSS + ] + ]; + + /** + * Variation search block + * + * @var string + */ + protected $variationSearchBlock = '#variations-search-field'; + + /** + * Selector for "Create New Variations Set" + * + * @var string + */ + protected $createNewVariationSet = '[data-ui-id$="add-attribute"]'; + + /** + * New attribute frame selector + * + * @var string + */ + protected $newAttributeFrame = '#create_new_attribute_container'; + + /** + * Selector for "New Attribute" block + * + * @var string + */ + protected $newAttribute = 'body'; + + /** + * Selector for "Save Attribute" button on "New Attribute" dialog window + * + * @var string + */ + protected $saveAttribute = '[data-ui-id="attribute-edit-content-save-button"]'; + + /** + * Selector attribute block by label + * + * @var string + */ + protected $attributeBlockByName = './/*[*/strong[contains(@class,"title") and contains(.,"%s")]]'; + + /** + * Selector for attribute block + * + * @var string + */ + protected $attributeBlock = '//div[@id="configurable-attributes-container"]/div[contains(@class,"entry-edit")][%d]'; + + /** + * Selector for "Add Option" button + * + * @var string + */ + protected $addOption = '[role="button"]'; + + /** + * Selector for option container + * + * @var string + */ + protected $optionContainer = './/tr[@data-role="option-container"]'; + + /** + * Selector for option container(row) by number + * + * @var string + */ + protected $optionContainerByNumber = './/tr[@data-role="option-container"][%d]'; + + /** + * Selector for attribute title + * + * @var string + */ + protected $attributeTitle = '.title > span'; + + /** + * Selector for attribute content + * + * @var string + */ + protected $attributeContent = '[id$="-content"]'; + + /** + * Selector for attribute label + * + * @var string + */ + protected $attributeLabel = '[name$="[label]"]'; + + /** + * Fill attributes + * + * @param array $attributes + * @return void + */ + public function fillAttributes(array $attributes) + { + foreach ($attributes as $attribute) { + $isExistAttribute = $this->isExistAttribute($attribute['frontend_label']); + + if (!$isExistAttribute && empty($attribute['attribute_id'])) { + $this->createNewVariationSet($attribute); + $this->fillOptions($attribute); + } else { + if (!$isExistAttribute) { + $this->getAttributeSelector()->setValue($attribute['frontend_label']); + } + $this->updateOptions($attribute); + } + } + } + + /** + * Create new variation set + * + * @param array $attribute + * @return void + */ + protected function createNewVariationSet(array $attribute) + { + $this->_rootElement->find($this->createNewVariationSet)->click(); + $this->browser->switchToFrame(new Locator($this->newAttributeFrame)); + + $newAttribute = $this->getEditAttributeForm(); + $newAttribute->getTabElement('properties')->fillFormTab($attribute); + $newAttribute->_rootElement->find($this->saveAttribute)->click(); + + $this->browser->switchToFrame(); + } + + /** + * Fill options + * + * @param array $attribute + * @return void + */ + protected function fillOptions(array $attribute) + { + $attributeBlock = $this->_rootElement->find( + sprintf($this->attributeBlockByName, $attribute['frontend_label']), + Locator::SELECTOR_XPATH + ); + $count = 0; + + $this->showAttributeContent($attributeBlock); + if (isset($attribute['label'])) { + $attributeBlock->find($this->attributeLabel)->setValue($attribute['label']); + } + foreach ($attribute['options'] as $option) { + $attributeBlock->find($this->addOption)->click(); + $count++; + $optionContainer = $attributeBlock->find( + sprintf($this->optionContainerByNumber, $count), + Locator::SELECTOR_XPATH + ); + + $mapping = $this->dataMapping($option); + $this->_fill($mapping, $optionContainer); + } + } + + /** + * Update options + * + * @param array $attribute + * @return void + */ + protected function updateOptions(array $attribute) + { + $attributeBlock = $this->_rootElement->find( + sprintf($this->attributeBlockByName, $attribute['frontend_label']), + Locator::SELECTOR_XPATH + ); + $count = 0; + + $this->showAttributeContent($attributeBlock); + if (isset($attribute['label'])) { + $attributeBlock->find($this->attributeLabel)->setValue($attribute['label']); + } + foreach ($attribute['options'] as $option) { + $count++; + $optionContainer = $attributeBlock->find( + sprintf($this->optionContainerByNumber, $count), + Locator::SELECTOR_XPATH + ); + + if (!$optionContainer->isVisible() && $this->isVisibleOption($attributeBlock, $count-1)) { + $attributeBlock->find($this->addOption)->click(); + } + $mapping = $this->dataMapping($option); + $this->_fill($mapping, $optionContainer); + } + } + + /** + * Check is visible option + * + * @param Element $attributeBlock + * @param int $number + * @return bool + */ + protected function isVisibleOption(Element $attributeBlock, $number) + { + return $attributeBlock->find( + sprintf($this->optionContainerByNumber, $number), + Locator::SELECTOR_XPATH + )->isVisible(); + } + + /** + * Get attribute form block + * + * @return \Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\AttributeForm + */ + protected function getEditAttributeForm() + { + return $this->blockFactory->create( + 'Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\AttributeForm', + ['element' => $this->browser->find($this->newAttribute)] + ); + } + + /** + * Get attribute selector element + * + * @return AttributeSelector + */ + public function getAttributeSelector() + { + return $this->_rootElement->find( + $this->variationSearchBlock, + Locator::SELECTOR_CSS, + 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute\AttributeSelector' + ); + } + + /** + * Get attributes data + * + * @return array + */ + public function getAttributesData() + { + $data = []; + $optionMapping = $this->dataMapping(); + + $count = 1; + $attributeBlock = $this->_rootElement->find(sprintf($this->attributeBlock, $count), Locator::SELECTOR_XPATH); + while ($attributeBlock->isVisible()) { + $attribute = [ + 'frontend_label' => $attributeBlock->find($this->attributeTitle)->getText(), + 'label' => $attributeBlock->find($this->attributeLabel)->getValue(), + 'options' => [] + ]; + + /** @var Element $attributeBlock */ + $this->showAttributeContent($attributeBlock); + $options = $attributeBlock->find($this->optionContainer, Locator::SELECTOR_XPATH)->getElements(); + foreach ($options as $optionKey => $option) { + /** @var Element $option */ + if ($option->isVisible()) { + $attribute['options'][$optionKey] = $this->_getData($optionMapping, $option); + $attribute['options'][$optionKey] += $this->getOptionalFields($option); + } + } + $data[] = $attribute; + + ++$count; + $attributeBlock = $this->_rootElement->find( + sprintf($this->attributeBlock, $count), + Locator::SELECTOR_XPATH + ); + } + + return $data; + } + + /** + * Show attribute content + * + * @param Element $attribute + * @return void + */ + protected function showAttributeContent(Element $attribute) + { + if (!$attribute->find($this->attributeContent)->isVisible()) { + $attribute->find($this->attributeTitle)->click(); + + $browser = $attribute; + $selector = $this->attributeContent; + $browser->waitUntil( + function () use ($browser, $selector) { + return $browser->find($selector)->isVisible() ? true : null; + } + ); + } + } + + /** + * Check exist attribute by label + * + * @param string $label + * @return bool + */ + protected function isExistAttribute($label) + { + return $this->_rootElement->find( + sprintf($this->attributeBlockByName, $label), + Locator::SELECTOR_XPATH + )->isVisible(); + } + + /** + * Get optional fields + * + * @param Element $context + * @param array $fields + * @return array + */ + protected function getOptionalFields(Element $context, array $fields = []) + { + $data = []; + + $fields = empty($fields) ? $this->mappingGetFields : $fields; + foreach ($fields as $name => $params) { + $data[$name] = $context->find($params['selector'], $params['strategy'])->getText(); + } + return $data; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.xml old mode 100644 new mode 100755 similarity index 60% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.xml index 67da2d5734e18fd67fad26f4c1db1bf548fed0cd..8c369a076a4374bed0209b3b71de32c7e804ded9 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.xml @@ -25,26 +25,19 @@ --> <mapping strict="0"> <fields> - <display> - <selector>//*[@data-column='display']/input</selector> - <strategy>xpath</strategy> + <label> + <selector>[name$="[label]"]</selector> + </label> + <pricing_value> + <selector>[name$="[pricing_value]"]</selector> + </pricing_value> + <is_percent> + <selector>.field-pricing-measure</selector> + <input>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute\ToggleDropdown</input> + </is_percent> + <include> + <selector>.include[name$="[include]"]</selector> <input>checkbox</input> - </display> - <name> - <selector>//*[@data-column='name']/input</selector> - <strategy>xpath</strategy> - </name> - <sku> - <selector>//*[@data-column='sku']/input</selector> - <strategy>xpath</strategy> - </sku> - <qty> - <selector>//*[@data-column='qty']/input</selector> - <strategy>xpath</strategy> - </qty> - <weight> - <selector>//*[@data-column='weight']/input</selector> - <strategy>xpath</strategy> - </weight> + </include> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php new file mode 100755 index 0000000000000000000000000000000000000000..98c68ebb230d85c1c7df5ae5cbc72a7bd2bd3ca5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php @@ -0,0 +1,47 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute; + +use Mtf\Client\Element; +use Mtf\Client\Driver\Selenium\Element\SuggestElement; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; + +/** + * Class AttributeSelector + * Form Attribute Search on Product page + */ +class AttributeSelector extends SuggestElement +{ + /** + * Checking exist configurable attribute in search result + * + * @param CatalogProductAttribute $productAttribute + * @return bool + */ + public function isExistAttributeInSearchResult(CatalogProductAttribute $productAttribute) + { + return $this->isExistValueInSearchResult($productAttribute->getFrontendLabel()); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/ToggleDropdown.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/ToggleDropdown.php new file mode 100755 index 0000000000000000000000000000000000000000..f7c5def04962d883e7fb48ee9d13c0b34616dcda --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/ToggleDropdown.php @@ -0,0 +1,104 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute; + +use Mtf\Client\Element\Locator; +use Mtf\Client\Driver\Selenium\Element; + +/** + * Class ToggleDropdown + * Class for toggle dropdown elements. + */ +class ToggleDropdown extends Element +{ + /** + * Selector for field value + * + * @var string + */ + protected $field = './/button/span'; + + /** + * Selector for list options + * + * @var string + */ + protected $listOptions = './/ul[@data-role="dropdown-menu"]'; + + /** + * Selector for search option by text + * + * @var string + */ + protected $optionByText = './/ul[@data-role="dropdown-menu"]/li/a[.="%s"]'; + + /** + * Set value + * + * @param string $value + * @return void + */ + public function setValue($value) + { + $this->_eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]); + + if ($value != $this->getValue()) { + $value = ('Yes' == $value) ? '%' : '$'; + + $this->find($this->field, Locator::SELECTOR_XPATH)->click(); + $this->waitListOptionsVisible(); + $this->find(sprintf($this->optionByText, $value), Locator::SELECTOR_XPATH)->click(); + } + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + $this->_eventManager->dispatchEvent(['get_value'], [(string)$this->_locator]); + + $value = $this->find($this->field, Locator::SELECTOR_XPATH)->getText(); + return ('%' == $value) ? 'Yes' : 'No'; + } + + /** + * Wait visible list options + * + * @return void + */ + protected function waitListOptionsVisible() + { + $browser = $this; + $selector = $this->listOptions; + $browser->waitUntil( + function () use ($browser, $selector) { + return $browser->find($selector, Locator::SELECTOR_XPATH)->isVisible() ? true : null; + } + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php old mode 100644 new mode 100755 index 60f6e94fbde699b37a61612effb813bfcb3ba91e..9892a82c76352362fa2a6f3cf9c4f28c3e5b4499 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php @@ -24,51 +24,155 @@ namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config; -use Mtf\Block\Form; -use Mtf\Client\Element; +use Mtf\Client\Driver\Selenium\Element; use Mtf\Client\Element\Locator; +use Magento\Backend\Test\Block\Widget\Form; /** * Class Matrix - * Product variations matrix block + * Matrix row form */ class Matrix extends Form { /** - * Fill qty to current variations + * Mapping for get optional fields * - * @param array $variations + * @var array + */ + protected $mappingGetFields = [ + 'name' => [ + 'selector' => 'td[data-column="name"] > a', + 'strategy' => Locator::SELECTOR_CSS + ], + 'sku' => [ + 'selector' => 'td[data-column="sku"] > span', + 'strategy' => Locator::SELECTOR_CSS + ], + 'quantity_and_stock_status' => [ + 'composite' => 1, + 'fields' => [ + 'qty' => [ + 'selector' => 'td[data-column="qty"]', + 'strategy' => Locator::SELECTOR_CSS + ] + ] + ], + 'weight' => [ + 'selector' => 'td[data-column="weight"]', + 'strategy' => Locator::SELECTOR_CSS + ], + ]; + + /** + * Selector for variation row by number + * + * @var string + */ + protected $variationRowByNumber = './/tr[@data-role="row"][%d]'; + + /** + * Selector for variation row + * + * @var string + */ + protected $variationRow = './/tr[@data-role="row"]'; + + /** + * Button for assign product to variation + * + * @var string + */ + protected $configurableAttribute = 'td[data-column="name"] button.action-choose'; + + // @codingStandardsIgnoreStart + /** + * Selector for row on product grid by product id + * + * @var string + */ + protected $selectAssociatedProduct = '//ancestor::div[*[@id="associated-products-container"]]//td[@data-column="entity_id" and (contains(text(),"%s"))]'; + // @codingStandardsIgnoreEnd + + /** + * Fill variations + * + * @param array $matrix * @return void */ - public function fillVariation(array $variations) + public function fillVariations(array $matrix) { - foreach ($variations as $variation) { - $variationRow = $this->getVariationRow($variation['configurable_attribute']); - foreach ($variation['value'] as $key => $field) { - if (!empty($this->mapping[$key])) { - $this->_rootElement->find( - $variationRow . $this->mapping[$key]['selector'], - Locator::SELECTOR_XPATH, - isset($this->mapping[$key]['input']) ? $this->mapping[$key]['input'] : null - )->setValue($field['value']); - } + $count = 1; + foreach ($matrix as $variation) { + $variationRow = $this->_rootElement->find( + sprintf($this->variationRowByNumber, $count), + Locator::SELECTOR_XPATH + ); + $mapping = $this->dataMapping($variation); + + $this->_fill($mapping, $variationRow); + if (isset($variation['configurable_attribute'])) { + $this->assignProduct($variationRow, $variation['configurable_attribute']); } + + ++$count; } } /** - * Define row that clarifies which line in Current Variations grid will be used + * Assign product to variation matrix + * + * @param Element $variationRow + * @param int $productId + * @return void + */ + protected function assignProduct(Element $variationRow, $productId) + { + $variationRow->find($this->configurableAttribute)->click(); + $this->_rootElement->find( + sprintf($this->selectAssociatedProduct, $productId), + Locator::SELECTOR_XPATH + )->click(); + } + + /** + * Get variations data * - * @param array $variationData - * @return string + * @return array */ - private function getVariationRow(array $variationData) + public function getVariationsData() { - $options = array(); - foreach ($variationData as $attributeData) { - $options[] = 'td[text()="' . $attributeData['attribute_option'] . '"]'; + $data = []; + $variationRows = $this->_rootElement->find($this->variationRow, Locator::SELECTOR_XPATH)->getElements(); + + foreach ($variationRows as $key => $variationRow) { + /** @var Element $variationRow */ + if ($variationRow->isVisible()) { + $data[$key] = $this->_getData($this->dataMapping(), $variationRow); + $data[$key] += $this->getOptionalFields($variationRow, $this->mappingGetFields); + } } - return '//tr[' . implode(' and ', $options) . ']'; + return $data; + } + + /** + * Get optional fields + * + * @param Element $context + * @param array $fields + * @return array + */ + protected function getOptionalFields(Element $context, array $fields) + { + $data = []; + + foreach ($fields as $name => $params) { + if (isset($params['composite']) && $params['composite']) { + $data[$name] = $this->getOptionalFields($context, $params['fields']); + } else { + $data[$name] = $context->find($params['selector'], $params['strategy'])->getText(); + } + } + return $data; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml old mode 100644 new mode 100755 index 67da2d5734e18fd67fad26f4c1db1bf548fed0cd..c4989e4edc6e6a9c263e4a5096db362456f518d8 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml @@ -26,25 +26,23 @@ <mapping strict="0"> <fields> <display> - <selector>//*[@data-column='display']/input</selector> - <strategy>xpath</strategy> + <selector>[name="associated_product_ids[]"]</selector> <input>checkbox</input> </display> <name> - <selector>//*[@data-column='name']/input</selector> - <strategy>xpath</strategy> + <selector>[name$="[name]"]</selector> </name> <sku> - <selector>//*[@data-column='sku']/input</selector> - <strategy>xpath</strategy> + <selector>[name$="[sku]"]</selector> </sku> - <qty> - <selector>//*[@data-column='qty']/input</selector> - <strategy>xpath</strategy> - </qty> + <quantity_and_stock_status composite="1"> + <qty> + <selector>[name$="[quantity_and_stock_status][qty]"]</selector> + </qty> + </quantity_and_stock_status> <weight> - <selector>//*[@data-column='weight']/input</selector> - <strategy>xpath</strategy> + <selector>[name$="[weight]"]</selector> </weight> </fields> </mapping> + diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.php deleted file mode 100644 index c0aecc288f0885727a0d27d2c829f57085326cbc..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Client\Element; -use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options as CatalogOptions; - -/** - * Class Matrix - * Matrix row form - */ -class Matrix extends CatalogOptions -{ - /** - * CSS selector data cell - * - * @var string - */ - protected $cellSelector = 'td:nth-child(%d)'; - - /** - * Field name mapping - * - * @var array - */ - protected $fieldNameMapping = [ - 3 => 'name', - 4 => 'sku', - 5 => 'price', - 6 => 'qty', - 7 => 'weight' - ]; - - /** - * Getting product matrix data form on the product form - * - * @param array|null $fields [optional] - * @param Element|null $element [optional] - * @return array - */ - public function getDataOptions(array $fields = null, Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - $mapping = $this->dataMapping($fields); - $data = $this->_getData($mapping, $element); - - $column = 3; - $cell = $element->find(sprintf($this->cellSelector, $column)); - $data['options_names'] = []; - while ($cell->isVisible()) { - if (isset($this->fieldNameMapping[$column])) { - $data[$this->fieldNameMapping[$column]] = $cell->getText(); - } else { - $data['options_names'][] = $cell->getText(); - } - $cell = $element->find(sprintf($this->cellSelector, ++$column)); - } - - return $data; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.php deleted file mode 100644 index 3749a1d246b9d071bc2f11b338f78f63786607b1..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options as CatalogOptions; - -/** - * Class Options - * Attribute options row form - */ -class Options extends CatalogOptions -{ - /** - * CSS selector name item - * - * @var string - */ - protected $nameSelector = 'td[data-column="name"]'; - - /** - * XPath selector percent label - * - * @var string - */ - protected $percentSelector = '//button[span[contains(text(),"%")]]'; - - /** - * Getting options data form on the product form - * - * @param array|null $fields [optional] - * @param Element|null $element [optional] - * @return array - */ - public function getDataOptions(array $fields = null, Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - $mapping = $this->dataMapping($fields); - $data = $this->_getData($mapping, $element); - - $data['is_percent'] = 'No'; - $percentElement = $element->find($this->percentSelector, Locator::SELECTOR_XPATH); - if ($percentElement->isVisible()) { - $data['is_percent'] = 'Yes'; - } - - $nameElement = $element->find($this->nameSelector); - if ($nameElement->isVisible()) { - $data['name'] = $nameElement->getText(); - } - - return $data; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php new file mode 100755 index 0000000000000000000000000000000000000000..95a8f41fd8d2be13d1870a7f0cb6a03e0f45ec5e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product; + +use Mtf\Client\Element\Locator; +use Mtf\Fixture\FixtureInterface; + +/** + * Class FormPageActions + * Page actions block on page + */ +class FormPageActions extends \Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions +{ + /** + * Selector for "Affected Attribute Set" popup form + * + * @var string + */ + protected $affectedAttributeSetForm = '//ancestor::body//div[div[@id="affected-attribute-set-form"]]'; + + /** + * Click on "Save" button + * + * @param FixtureInterface|null $product [optional] + * @return void + */ + public function save(FixtureInterface $product = null) + { + parent::save(); + $affectedAttributeSetForm = $this->getAffectedAttributeSetForm(); + if ($affectedAttributeSetForm->isVisible()) { + $affectedAttributeSetForm->fill($product)->confirm(); + } + } + + /** + * Get "Choose Affected Attribute Set" form + * + * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AffectedAttributeSet + */ + protected function getAffectedAttributeSetForm() + { + return $this->blockFactory->create( + '\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AffectedAttributeSet', + ['element' => $this->_rootElement->find($this->affectedAttributeSetForm, Locator::SELECTOR_XPATH)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php index 91238c1a29594ee759249ded3a33193688ecc8e0..278f35f2e4ae64cf360ec89f3425f418078d4f74 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php @@ -24,166 +24,102 @@ namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product; -use Mtf\Block\Mapper; use Mtf\Client\Element; -use Mtf\Client\Browser; -use Mtf\Factory\Factory; +use Magento\Backend\Test\Block\Widget\FormTabs; +use Mtf\Fixture\DataFixture; use Mtf\Fixture\FixtureInterface; -use Mtf\Util\XmlConverter; -use Mtf\Block\BlockFactory; -use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm as ParentForm; +use Mtf\Fixture\InjectableFixture; /** * Class ProductForm * Product creation form */ -class ProductForm extends ParentForm +class ProductForm extends \Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm { /** - * New attribute selector + * Fill the product form * - * @var string + * @param FixtureInterface $product + * @param Element|null $element [optional] + * @param FixtureInterface|null $category [optional] + * @return FormTabs */ - protected $newAttribute = 'body'; - - /** - * New attribute frame selector - * - * @var string - */ - protected $newAttributeFrame = '#create_new_attribute_container'; - - /** - * New variation set button selector - * - * @var string - */ - protected $newVariationSet = '[data-ui-id="admin-product-edit-tab-super-config-grid-container-add-attribute"]'; - - /** - * Variations tab selector - * - * @var string - */ - protected $productDetailsTab = '#product_info_tabs_product-details'; - - /** - * Choose affected attribute set dialog popup window - * - * @var string - */ - protected $affectedAttributeSet = "//div[div/@data-id='affected-attribute-set-selector']"; + public function fill(FixtureInterface $product, Element $element = null, FixtureInterface $category = null) + { + $tabs = $this->getFieldsByTabs($product); + ksort($tabs); - /** - * Variations tab selector - * - * @var string - */ - protected $variationsTab = '#product_info_tabs_super_config_content .title'; + if ($product instanceof DataFixture) { + $tabs = $this->normalizeDeprecateData($tabs); + $category = ($category === null) ? $product->getCategories()['category'] : $category; + } - /** - * Variations wrapper selector - * - * @var string - */ - protected $variationsWrapper = '#product_info_tabs_super_config_content'; + if ($category) { + $tabs['product-details']['category_ids']['value'] = ($category instanceof InjectableFixture ) + ? $category->getName() + : $category->getCategoryName(); + } - /** - * Get choose affected attribute set dialog popup window - * - * @return \Magento\ConfigurableProduct\Test\Block\Backend\Product\AffectedAttributeSet - */ - protected function getAffectedAttributeSetBlock() - { - return Factory::getBlockFactory()->getMagentoConfigurableProductBackendProductAffectedAttributeSet( - $this->_rootElement->find($this->affectedAttributeSet, Locator::SELECTOR_XPATH) - ); + $this->showAdvancedSettings(); + return $this->fillTabs($tabs, $element); } /** - * Get attribute edit block + * Normalize data in DataFixture * - * @return \Magento\ConfigurableProduct\Test\Block\Backend\Product\Attribute\Edit + * @param array $tabs + * @return array */ - public function getConfigurableAttributeEditBlock() + protected function normalizeDeprecateData(array $tabs) { - $this->browser->switchToFrame(new Locator($this->newAttributeFrame)); - return Factory::getBlockFactory()->getMagentoConfigurableProductBackendProductAttributeEdit( - $this->browser->find($this->newAttribute, Locator::SELECTOR_TAG_NAME) - ); - } - - /** - * Save product - * - * @param FixtureInterface $fixture - * @return \Magento\Backend\Test\Block\Widget\Form|void - */ - public function save(FixtureInterface $fixture = null) - { - parent::save($fixture); - if ($this->getAffectedAttributeSetBlock()->isVisible()) { - $this->getAffectedAttributeSetBlock()->chooseAttributeSet($fixture); + if (!isset($tabs['variations'])) { + return $tabs; } - } - /** - * Get variations block - * - * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config - */ - protected function getVariationsBlock() - { - return Factory::getBlockFactory()->getMagentoConfigurableProductAdminhtmlProductEditTabSuperConfig( - $this->browser->find($this->variationsWrapper) - ); - } + $variations = $tabs['variations']; - /** - * Fill product variations - * - * @param array $variations - * @return void - */ - public function variationsFill(array $variations) - { - $variationsBlock = $this->getVariationsBlock(); - $variationsBlock->fillAttributeOptions($variations); - $variationsBlock->generateVariations(); - } + $attributesData = []; + if (isset($variations['configurable_attributes_data']['value'])) { + foreach ($variations['configurable_attributes_data']['value'] as $key => $attribute) { + $attributesData[$key] = [ + 'frontend_label' => $attribute['label']['value'] + ]; + unset($attribute['label']); - /** - * Open variations tab - * - * @return void - */ - public function openVariationsTab() - { - $this->_rootElement->find($this->variationsTab)->click(); - } + foreach ($attribute as $optionKey => $option) { + foreach ($option as $name => $field) { + $option[$name] = $field['value']; + } - /** - * Click on 'Create New Variation Set' button - * - * @return void - */ - public function clickCreateNewVariationSet() - { - $this->_rootElement->find($this->newVariationSet)->click(); - } + $option['label'] = $option['option_label']; + unset($option['option_label']); - /** - * Find Attribute on Product page - * - * @param string $attributeName - * @return bool - */ - public function findAttribute($attributeName) - { - $this->openTab('product-details'); + $attribute[$optionKey] = $option; + } + + + $attributesData[$key]['options'] = $attribute; + } + } + + $matrix = []; + if (isset($variations['variations-matrix'])) { + foreach ($variations['variations-matrix']['value'] as $key => $variation) { + foreach ($variation['value'] as $name => $field) { + $matrix[$key][$name] = $field['value']; + } + } + } - return $this->getVariationsBlock()->getAttributeBlock($attributeName)->isVisible(); + $tabs['variations'] = [ + 'configurable_attributes_data' => [ + 'value' => [ + 'attributes_data' => $attributesData, + 'matrix' => $matrix + ] + ] + ]; + unset($tabs['variations']['variations-matrix']); + return $tabs; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml old mode 100644 new mode 100755 index 68c9e8a73eb224bf7b1a9c92747e05252d04b0d6..90b68453348d3bba5efa6db0d1428e30bb5ac838 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml @@ -24,46 +24,6 @@ */ --> <tabs> - <product-details> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <tax_class_id> - <input>select</input> - </tax_class_id> - <is_virtual> - <input>checkbox</input> - </is_virtual> - <quantity_and_stock_status composite="1"> - <qty> - <selector>#qty</selector> - </qty> - <is_in_stock> - <selector>#quantity_and_stock_status</selector> - <input>select</input> - </is_in_stock> - </quantity_and_stock_status> - </fields> - </product-details> - <advanced-pricing> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\AdvancedPricingTab</class> - <selector>#product_info_tabs_advanced-pricing</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <special_price> - <selector>[name='product[special_price]']</selector> - </special_price> - <group_price> - <input>select</input> - </group_price> - <tier_price> - <input>select</input> - </tier_price> - </fields> - </advanced-pricing> <variations> <class>\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config</class> <selector>#product_info_tabs_product-details</selector> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/AffectedAttributeSet.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/AffectedAttributeSet.php deleted file mode 100644 index 53fa7fbd1b59222b86f73b29dd2b346694a07765..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/AffectedAttributeSet.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Block\Backend\Product; - -use Mtf\Block\Block; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class AffectedAttributeSet - * Choose affected attribute set dialog popup window - */ -class AffectedAttributeSet extends Block -{ - /** - * Create new attribute set based on default - * - * @var string - */ - protected $affectedAttributeSet = '[name=affected-attribute-set][value=new]'; - - /** - * New attribute set name - * - * @var string - */ - protected $attributeSetName = '[name=new-attribute-set-name]'; - - /** - * 'Confirm' button - * - * @var string - */ - protected $confirmButton = '[id*=confirm-button]'; - - /** - * Choose affected attribute set - * - * @param CatalogProductConfigurable $fixture - */ - public function chooseAttributeSet(CatalogProductConfigurable $fixture) - { - $attributeSetName = $fixture->getAttributeSetName(); - if ($attributeSetName) { - $this->_rootElement->find($this->affectedAttributeSet)->click(); - $this->_rootElement->find($this->attributeSetName)->setValue($attributeSetName); - } - $this->_rootElement->find($this->confirmButton)->click(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.php deleted file mode 100644 index 81a2926052b8fe5679056cd2252d8386d44cdfae..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Block\Backend\Product\Attribute; - -use Mtf\Client\Element; -use Magento\Backend\Test\Block\Widget\Form; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class Edit - * Product attribute edit page - */ -class Edit extends Form -{ - /** - * Frontend properties selector - * - * @var string - */ - protected $frontendProperties = '#front_fieldset-wrapper .title'; - - /** - * Save attribute selector - * - * @var string - */ - protected $saveAttribute = '[data-ui-id="attribute-edit-content-save-button"]'; - - /** - * 'Add new option' button selector - * - * @var string - */ - protected $addNewOption = '#add_new_option_button'; - - /** - * Attribute option row - * - * @var string - */ - protected $optionRow = '//*[@id="manage-options-panel"]//tbody//tr[%row%]'; - - /** - * Open frontend properties - * - * @return void - */ - public function openFrontendProperties() - { - $this->_rootElement->find($this->frontendProperties)->click(); - } - - /** - * Save attribute - * - * @return void - */ - public function saveAttribute() - { - $this->_rootElement->find($this->saveAttribute)->click(); - } - - /** - * Fill attribute options - * - * @param array $data - * @return void - */ - public function fillAttributeOption(array $data) - { - $this->_rootElement->find('#attribute_label') - ->setValue($data['attribute_options']['attribute_label']); - $this->_rootElement->find('#frontend_input', Element\Locator::SELECTOR_CSS, 'select') - ->setValue($data['attribute_options']['frontend_input']); - $this->_rootElement->find('#is_required', Element\Locator::SELECTOR_CSS, 'select') - ->setValue($data['attribute_options']['is_required']); - - $addButton = $this->_rootElement->find('#add_new_option_button'); - $table = $this->_rootElement->find('.data-table'); - foreach ($data['attribute_options']['options'] as $index => $value) { - $addButton->click(); - $table->find('[name="' . $index . '"]')->setValue($value); - } - $this->saveAttribute(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.xml deleted file mode 100644 index d604e00a11d312c9fb974fcef1ebd1d50a88644b..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<mapping strict="0"> - <fields> - <attribute_label> - <selector>[name='frontend_label[0]']</selector> - </attribute_label> - <frontend_input> - <input>select</input> - </frontend_input> - <is_searchable> - <input>select</input> - </is_searchable> - <is_visible_in_advanced_search> - <input>select</input> - </is_visible_in_advanced_search> - <is_comparable> - <input>select</input> - </is_comparable> - <is_filterable> - <input>select</input> - </is_filterable> - <is_visible_on_front> - <input>select</input> - </is_visible_on_front> - <is_filterable_in_search> - <input>select</input> - </is_filterable_in_search> - </fields> -</mapping> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php new file mode 100644 index 0000000000000000000000000000000000000000..4cf100c22af86b15c746698f63623933224ab766 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php @@ -0,0 +1,125 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Block\Product; + +use Magento\ConfigurableProduct\Test\Block\Product\View\ConfigurableOptions; +use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class View + * Product view block on frontend page + */ +class View extends \Magento\Catalog\Test\Block\Product\View +{ + /** + * Get configurable options block + * + * @return ConfigurableOptions + */ + public function getConfigurableOptionsBlock() + { + return $this->blockFactory->create( + 'Magento\ConfigurableProduct\Test\Block\Product\View\ConfigurableOptions', + ['element' => $this->_rootElement] + ); + } + + /** + * Fill in the option specified for the product + * + * @param FixtureInterface $product + * @return void + */ + public function fillOptions(FixtureInterface $product) + { + if ($product instanceof InjectableFixture) { + /** @var ConfigurableProductInjectable $product */ + $attributesData = $product->getConfigurableAttributesData()['attributes_data']; + $checkoutData = $product->getCheckoutData(); + + // Prepare attribute data + foreach ($attributesData as $attributeKey => $attribute) { + $attributesData[$attributeKey] = [ + 'type' => $attribute['frontend_input'], + 'title' => $attribute['label'], + 'options' => [], + ]; + + foreach ($attribute['options'] as $optionKey => $option) { + $attributesData[$attributeKey]['options'][$optionKey] = [ + 'title' => $option['label'] + ]; + } + } + } else { + // TODO: Removed after refactoring(removed) old product fixture. + /** @var ConfigurableProduct $product */ + $attributesData = $product->getConfigurableAttributes(); + $checkoutData = $product->getCheckoutData(); + + // Prepare attributes data + foreach ($attributesData as $attributeKey => $attribute) { + $attributesData[$attributeKey] = [ + 'type' => 'dropdown', + 'title' => $attribute['label']['value'] + ]; + + unset($attribute['label']); + foreach ($attribute as $optionKey => $option) { + $attributesData[$attributeKey]['options'][$optionKey] = [ + 'title' => $option['option_label']['value'] + ]; + } + } + } + + $configurableCheckoutData = isset($checkoutData['configurable_options']) + ? $checkoutData['configurable_options'] + : []; + $checkoutOptionsData = $this->prepareCheckoutData($attributesData, $configurableCheckoutData); + $this->getCustomOptionsBlock()->fillCustomOptions($checkoutOptionsData); + + parent::fillOptions($product); + } + + /** + * Return product options + * + * @param FixtureInterface $product [optional] + * @return array + */ + public function getOptions(FixtureInterface $product = null) + { + $options = [ + 'configurable_options' => $this->getConfigurableOptionsBlock()->getOptions($product) + ]; + $options += parent::getOptions($product); + + return $options; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php new file mode 100644 index 0000000000000000000000000000000000000000..16fe173d132e04859a05c45896674c5beb0c7b6c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Block\Product\View; + +use Mtf\Client\Element; +use Mtf\Client\Element\Locator; +use Magento\Catalog\Test\Block\Product\View\CustomOptions; +use Mtf\Fixture\FixtureInterface; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class ConfigurableOptions + * Form of configurable options product + */ +class ConfigurableOptions extends CustomOptions +{ + /** + * Get configurable product options + * + * @param FixtureInterface|null $product [optional] + * @return array + * @throws \Exception + */ + public function getOptions(FixtureInterface $product) + { + /** @var ConfigurableProductInjectable $product */ + $attributesData = $product->hasData('configurable_attributes_data') + ? $product->getConfigurableAttributesData()['attributes_data'] + : []; + $listOptions = $this->getListOptions(); + $result = []; + + foreach ($attributesData as $option) { + $title = $option['label']; + if (!isset($listOptions[$title])) { + throw new \Exception("Can't find option: \"{$title}\""); + } + + /** @var Element $optionElement */ + $optionElement = $listOptions[$title]; + $typeMethod = preg_replace('/[^a-zA-Z]/', '', $option['frontend_input']); + $getTypeData = 'get' . ucfirst(strtolower($typeMethod)) . 'Data'; + + $optionData = $this->$getTypeData($optionElement); + $optionData['title'] = $title; + $optionData['type'] = $option['frontend_input']; + $optionData['is_require'] = $optionElement->find($this->required, Locator::SELECTOR_XPATH)->isVisible() + ? 'Yes' + : 'No'; + + $result[$title] = $optionData; + } + + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php new file mode 100644 index 0000000000000000000000000000000000000000..4b6ea4327943dce8601d889158947d2fbebf18ce --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php @@ -0,0 +1,89 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\CatalogSearch\Test\Page\CatalogsearchResult; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class AssertChildProductIsNotDisplayedSeparately + * Assert that products generated during configurable product creation - are not visible on frontend(by default). + */ +class AssertChildProductIsNotDisplayedSeparately extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'middle'; + + /** + * Assert that products generated during configurable product creation - are not visible on frontend(by default). + * + * @param CatalogSearchResult $catalogSearchResult + * @param CmsIndex $cmsIndex + * @param ConfigurableProductInjectable $product + * @return void + */ + public function processAssert( + CatalogsearchResult $catalogSearchResult, + CmsIndex $cmsIndex, + ConfigurableProductInjectable $product + ) { + $configurableAttributesData = $product->getConfigurableAttributesData(); + $errors = []; + + $cmsIndex->open(); + foreach ($configurableAttributesData['matrix'] as $variation) { + $cmsIndex->getSearchBlock()->search($variation['sku']); + + $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($variation['name']); + while (!$isVisibleProduct && $catalogSearchResult->getBottomToolbar()->nextPage()) { + $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); + } + if ($isVisibleProduct) { + $errors[] = sprintf( + "\nChild product with sku: \"%s\" is visible on frontend(by default).", + $variation['sku'] + ); + } + } + + \PHPUnit_Framework_Assert::assertEmpty($errors, implode(' ', $errors)); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Child products generated during configurable product creation are not visible on frontend(by default)'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php new file mode 100755 index 0000000000000000000000000000000000000000..9170954eb70e0fac16f392fdadd058227332ed54 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php @@ -0,0 +1,92 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class AssertChildProductsInGrid + * Assert that child products generated during configurable product are present in products grid + */ +class AssertChildProductsInGrid extends AbstractConstraint +{ + /** + * Default status visibility on child products + */ + const NOT_VISIBLE_INDIVIDUALLY = 'Not Visible Individually'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that child products generated during configurable product are present in products grid + * + * @param CatalogProductIndex $productGrid + * @param ConfigurableProductInjectable $product + * @return void + */ + public function processAssert(CatalogProductIndex $productGrid, ConfigurableProductInjectable $product) + { + $configurableAttributesData = $product->getConfigurableAttributesData(); + $productType = $product->getIsVirtual() ? 'Virtual Product' : 'Simple Product'; + $errors = []; + + $productGrid->open(); + foreach ($configurableAttributesData['matrix'] as $variation) { + $filter = [ + 'name' => $variation['name'], + 'type' => $productType, + 'sku' => $variation['sku'], + 'visibility' => self::NOT_VISIBLE_INDIVIDUALLY, + ]; + + if (!$productGrid->getProductGrid()->isRowVisible($filter)) { + $errors[] = sprintf( + 'Child product with name: "%s" and sku:"%s" is absent in grid.', + $filter['name'], + $filter['sku'] + ); + } + } + + \PHPUnit_Framework_Assert::assertEmpty($errors, implode($errors, ' ')); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Child products generated during configurable product are present in products grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCart.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCart.php deleted file mode 100755 index 8d6e2510b0713b4c062ee3a7935cdaa6f2f0a19d..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCart.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Constraint; - -use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; -use Magento\Checkout\Test\Page\CheckoutCart; -use Magento\Catalog\Test\Page\Product\CatalogProductView; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class AssertConfigurableInCart - */ -class AssertConfigurableInCart extends AbstractConstraint -{ - /** - * Constraint severeness - * - * @var string - */ - protected $severeness = 'low'; - - /** - * Assert configurable product, corresponds to the product in the cart - * - * @param CatalogProductView $catalogProductView - * @param CatalogProductConfigurable $configurable - * @param Browser $browser - * @param CheckoutCart $checkoutCart - * @return void - */ - public function processAssert( - CatalogProductView $catalogProductView, - CatalogProductConfigurable $configurable, - Browser $browser, - CheckoutCart $checkoutCart - ) { - //Add product to cart - $browser->open($_ENV['app_frontend_url'] . $configurable->getUrlKey() . '.html'); - $configurableData = $configurable->getConfigurableAttributesData(); - if (!empty($configurableData)) { - $configurableOption = $catalogProductView->getCustomOptionsBlock(); - foreach ($configurableData['attributes_data'] as $attribute) { - $configurableOption->selectProductCustomOption($attribute['title']); - } - } - $catalogProductView->getViewBlock()->clickAddToCart(); - - $this->assertOnShoppingCart($configurable, $checkoutCart); - } - - /** - * Assert prices on the shopping Cart - * - * @param CatalogProductConfigurable $configurable - * @param CheckoutCart $checkoutCart - * @return void - */ - protected function assertOnShoppingCart(CatalogProductConfigurable $configurable, CheckoutCart $checkoutCart) - { - /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ - $priceFixture = $configurable->getDataFieldConfig('price')['source']; - $pricePresetData = $priceFixture->getPreset(); - - $price = $checkoutCart->getCartBlock()->getProductPriceByName($configurable->getName()); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['cart_price'], - $price, - 'Product price in shopping cart is not correct.' - ); - } - - /** - * Text of Visible in category assert - * - * @return string - */ - public function toString() - { - return 'Product price in shopping cart is not correct.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCategory.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCategory.php deleted file mode 100644 index 40389e96bda98cd534118796920c14598f8117aa..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCategory.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Constraint; - -use Magento\Cms\Test\Page\CmsIndex; -use Mtf\Constraint\AbstractConstraint; -use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\Catalog\Test\Page\Category\CatalogCategoryView; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class AssertProductInCategory - */ -class AssertConfigurableInCategory extends AbstractConstraint -{ - /** - * Constraint severeness - * - * @var string - */ - protected $severeness = 'low'; - - /** - * Assert configurable product, corresponds to the category page - * - * @param CatalogCategoryView $catalogCategoryView - * @param CmsIndex $cmsIndex - * @param CatalogProductConfigurable $configurable - * @param CatalogCategory $category - * @return void - */ - public function processAssert( - CatalogCategoryView $catalogCategoryView, - CmsIndex $cmsIndex, - CatalogProductConfigurable $configurable, - CatalogCategory $category - ) { - //Open category view page - $cmsIndex->open(); - $cmsIndex->getTopmenu()->selectCategoryByName($category->getName()); - - //process asserts - $this->assertPrice($configurable, $catalogCategoryView); - } - - /** - * Verify product price on category view page - * - * @param CatalogProductConfigurable $configurable - * @param CatalogCategoryView $catalogCategoryView - * @return void - */ - protected function assertPrice( - CatalogProductConfigurable $configurable, - CatalogCategoryView $catalogCategoryView - ) { - /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ - $priceFixture = $configurable->getDataFieldConfig('price')['source']; - $pricePresetData = $priceFixture->getPreset(); - - //Regular price verification - if (isset($pricePresetData['category_special_price'])) { - $regularPrice = $catalogCategoryView->getListProductBlock() - ->getProductPriceBlock($configurable->getName()) - ->getRegularPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['category_price'], - $regularPrice, - 'Product regular price on category page is not correct.' - ); - //Special price verification - $specialPrice = $catalogCategoryView->getListProductBlock()->getProductPriceBlock( - $configurable->getName() - )->getSpecialPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['category_special_price'], - $specialPrice, - 'Product special price on category page is not correct.' - ); - } else { - //Price verification - $price = $catalogCategoryView->getListProductBlock() - ->getProductPriceBlock($configurable->getName()) - ->getPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $price['price_regular_price'], - $pricePresetData['category_price'], - 'Product price on category page is not correct.' - ); - } - } - - /** - * Text of Visible in category assert - * - * @return string - */ - public function toString() - { - return 'Product price on category page is not correct.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductDuplicateForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductDuplicateForm.php new file mode 100644 index 0000000000000000000000000000000000000000..8e151a7da35dc50c40e65668fd30e43ccfc77000 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductDuplicateForm.php @@ -0,0 +1,80 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Constraint; + +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; +use Mtf\Fixture\FixtureInterface; + +/** + * Class AssertConfigurableProductDuplicateForm + * Assert form data equals duplicate product configurable data + */ +class AssertConfigurableProductDuplicateForm extends AssertConfigurableProductForm +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert form data equals duplicate product configurable data + * + * @param FixtureInterface $product + * @param CatalogProductIndex $productGrid + * @param CatalogProductEdit $productPage + * @return void + */ + public function processAssert( + FixtureInterface $product, + CatalogProductIndex $productGrid, + CatalogProductEdit $productPage + ) { + $duplicateProductSku = $product->getSku() . '-1'; + $filter = ['sku' => $duplicateProductSku]; + $productGrid->open(); + $productGrid->getProductGrid()->searchAndOpen($filter); + + $productData = $product->getData(); + $productData['sku'] = $duplicateProductSku; + $productData['status'] = 'Product offline'; + $fixtureData = $this->prepareFixtureData($productData, $this->sortFields); + $formData = $this->prepareFormData($productPage->getProductForm()->getData($product), $this->sortFields); + $error = $this->verifyData($fixtureData, $formData); + \PHPUnit_Framework_Assert::assertTrue(empty($error), $error); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Form data equals to fixture data of duplicated product.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php old mode 100644 new mode 100755 index dfdb5e157559a73c38a98bf3db60b85789fa64dd..1db4f952d80276ac023be3272941a3982661e2e7 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php @@ -24,99 +24,117 @@ namespace Magento\ConfigurableProduct\Test\Constraint; -use Mtf\Fixture\FixtureInterface; use Magento\Catalog\Test\Constraint\AssertProductForm; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; /** * Class AssertConfigurableProductForm - * Assert that displayed product data on edit page equals passed from fixture + * Assert form data equals fixture data */ class AssertConfigurableProductForm extends AssertProductForm { /** - * Constraint severeness + * List skipped fixture fields in verify * - * @var string + * @var array */ - protected $severeness = 'high'; + protected $skippedFixtureFields = [ + 'id', + 'affected_attribute_set', + 'checkout_data' + ]; /** - * Assert that displayed product data on edit page equals passed from fixture + * List skipped attribute fields in verify * - * @param FixtureInterface $product - * @param CatalogProductIndex $productGrid - * @param CatalogProductEdit $productPage - * @return void + * @var array */ - public function processAssert( - FixtureInterface $product, - CatalogProductIndex $productGrid, - CatalogProductEdit $productPage - ) { - $productGrid->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]); + protected $skippedAttributeFields = [ + 'frontend_input', + 'attribute_code', + 'attribute_id', + 'is_required', + ]; - $form = $productPage->getForm(); - $formData = $form->getData($product); - foreach (array_keys($formData['configurable_attributes_data']['matrix']) as $key) { - unset($formData['configurable_attributes_data']['matrix'][$key]['price']); - } - - $fixtureData = $this->prepareFixtureData($product->getData(), $product); - $attributes = $fixtureData['configurable_attributes_data']['attributes_data']; - $matrix = $fixtureData['configurable_attributes_data']['matrix']; - unset($fixtureData['configurable_attributes_data'], $fixtureData['id']); + /** + * List skipped option fields in verify + * + * @var array + */ + protected $skippedOptionFields = [ + 'id', + 'is_default', + ]; - $fixtureData['configurable_attributes_data']['attributes_data'] = $this->prepareAttributes($attributes); - $fixtureData['configurable_attributes_data']['matrix'] = $this->prepareMatrix($matrix); + protected $skippedVariationMatrixFields = [ + 'configurable_attribute' + ]; - $errors = $this->verifyData($fixtureData, $formData); - \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); - } + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'high'; /** - * Preparing data attributes fixture + * Prepares fixture data for comparison * - * @param array $fixtureAttribute + * @param array $data + * @param array $sortFields [optional] * @return array */ - protected function prepareAttributes(array $fixtureAttribute) + protected function prepareFixtureData(array $data, array $sortFields = []) { - foreach ($fixtureAttribute as &$attribute) { - unset($attribute['id'], $attribute['label'], $attribute['code']); - foreach ($attribute['options'] as &$option) { - $option['pricing_value'] = number_format($option['pricing_value'], 4); - unset($option['id']); + // filter values and reset keys in attributes data + $attributeData = $data['configurable_attributes_data']['attributes_data']; + foreach ($attributeData as $attributeKey => $attribute) { + foreach ($attribute['options'] as $optionKey => $option) { + $attribute['options'][$optionKey] = array_diff_key($option, array_flip($this->skippedOptionFields)); } + $attribute['options'] = $this->sortDataByPath($attribute['options'], '::label'); + $attributeData[$attributeKey] = array_diff_key($attribute, array_flip($this->skippedAttributeFields)); + } + $data['configurable_attributes_data']['attributes_data'] = $this->sortDataByPath($attributeData, '::label'); + + + // prepare and filter values, reset keys in variation matrix + $variationsMatrix = $data['configurable_attributes_data']['matrix']; + foreach ($variationsMatrix as $key => $variationMatrix) { + $variationMatrix['display'] = isset($variationMatrix['display']) ? $variationMatrix['display'] : 'Yes'; + $variationsMatrix[$key] = array_diff_key($variationMatrix, array_flip($this->skippedVariationMatrixFields)); } + $data['configurable_attributes_data']['matrix'] = array_values($variationsMatrix); - return $fixtureAttribute; + return parent::prepareFixtureData($data, $sortFields); } /** - * Preparing data matrix fixture + * Prepares form data for comparison * - * @param array $fixtureMatrix + * @param array $data + * @param array $sortFields [optional] * @return array */ - protected function prepareMatrix(array $fixtureMatrix) + protected function prepareFormData(array $data, array $sortFields = []) { - foreach ($fixtureMatrix as &$matrix) { - $matrix['display'] = 'Yes'; - unset($matrix['configurable_attribute'], $matrix['associated_product_ids']); + // prepare attributes data + $attributeData = $data['configurable_attributes_data']['attributes_data']; + foreach ($attributeData as $attributeKey => $attribute) { + $attribute['options'] = $this->sortDataByPath($attribute['options'], '::label'); + $attributeData[$attributeKey] = $attribute; } + $data['configurable_attributes_data']['attributes_data'] = $this->sortDataByPath($attributeData, '::label'); - return $fixtureMatrix; - } + // filter values and reset keys in variation matrix + $variationsMatrix = $data['configurable_attributes_data']['matrix']; + foreach ($variationsMatrix as $key => $variationMatrix) { + $variationsMatrix[$key] = array_diff_key($variationMatrix, array_flip($this->skippedVariationMatrixFields)); + } + $data['configurable_attributes_data']['matrix'] = array_values($variationsMatrix); - /** - * Returns a string representation of the object - * - * @return string - */ - public function toString() - { - return 'Form data equal the configurable product data.'; + foreach ($sortFields as $path) { + $data = $this->sortDataByPath($data, $path); + } + return $data; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php new file mode 100755 index 0000000000000000000000000000000000000000..95241dc236b6a62cf22cf11e27b256045cde794d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Constraint; + +use Mtf\Client\Browser; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Checkout\Test\Page\CheckoutCart; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertConfigurableProductInCart + * Assertion that the product is correctly displayed in cart + */ +class AssertConfigurableProductInCart extends AbstractConstraint +{ + /** + * Assertion that the product is correctly displayed in cart + * + * @param Browser $browser + * @param CatalogProductView $catalogProductView + * @param CheckoutCart $checkoutCart + * @param ConfigurableProductInjectable $product + * @return void + */ + public function processAssert( + Browser $browser, + CatalogProductView $catalogProductView, + CheckoutCart $checkoutCart, + ConfigurableProductInjectable $product + ) { + $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + + $catalogProductView->getViewBlock()->addToCart($product); + + $checkoutData = $product->getCheckoutData(); + $price = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); + \PHPUnit_Framework_Assert::assertEquals( + $checkoutData['checkoutItemForm']['price'], + $price, + 'Product price in shopping cart is not correct.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Product price in shopping cart is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInItemsOrderedGrid.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInItemsOrderedGrid.php new file mode 100644 index 0000000000000000000000000000000000000000..ae25bd0d715cec7fb596623710bf096ed5b36205 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInItemsOrderedGrid.php @@ -0,0 +1,68 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Constraint; + +use Mtf\Fixture\FixtureInterface; +use Magento\Sales\Test\Constraint\AssertProductInItemsOrderedGrid; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class AssertConfigurableProductInItemsOrderedGrid + * Assert configurable product was added to Items Ordered grid in customer account on Order creation page backend + */ +class AssertConfigurableProductInItemsOrderedGrid extends AssertProductInItemsOrderedGrid +{ + /** + * Get configurable product price + * + * @param FixtureInterface $product + * @throws \Exception + * @return int + */ + protected function getProductPrice(FixtureInterface $product) + { + $price = $product->getPrice(); + if (!$this->productsIsConfigured) { + return $price; + } + if (!$product instanceof ConfigurableProductInjectable) { + throw new \Exception("Product '$product->getName()' is not configurable product."); + } + $checkoutData = $product->getCheckoutData(); + if ($checkoutData === null) { + return 0; + } + $attributesData = $product->getConfigurableAttributesData()['attributes_data']; + foreach ($checkoutData['configurable_options'] as $option) { + $itemOption = $attributesData[$option['title']]['options'][$option['value']]; + $itemPrice = $itemOption['is_percent'] == 'No' + ? $itemOption['pricing_value'] + : $product->getPrice() / 100 * $itemOption['pricing_value']; + $price += $itemPrice; + } + + return $price; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php new file mode 100755 index 0000000000000000000000000000000000000000..0a185d257754405d0234d33ae5497b24618b0766 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php @@ -0,0 +1,99 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Constraint; + +use Magento\Catalog\Test\Constraint\AssertProductPage; + +/** + * Class AssertConfigurableProductPage + * Assert that displayed product data on product page(front-end) equals passed from fixture + */ +class AssertConfigurableProductPage extends AssertProductPage +{ + /** + * Verify displayed product data on product page(front-end) equals passed from fixture: + * 1. Product Name + * 2. Price + * 3. SKU + * 4. Description + * 5. Short Description + * 6. Attributes + * + * @return array + */ + protected function verify() + { + $errors = parent::verify(); + $errors[] = $this->verifyAttributes(); + + return array_filter($errors); + } + + /** + * Verify displayed product attributes on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifyAttributes() + { + $attributesData = $this->product->getConfigurableAttributesData()['attributes_data']; + $configurableOptions = []; + $formOptions = $this->productView->getOptions($this->product)['configurable_options']; + + foreach ($attributesData as $attributeKey => $attributeData) { + $optionData = [ + 'title' => $attributeData['frontend_label'], + 'type' => $attributeData['frontend_input'], + 'is_require' => 'Yes', + ]; + + foreach ($attributeData['options'] as $optionKey => $option) { + $price = ('Yes' == $option['is_percent']) + ? ($this->product->getPrice() * $option['pricing_value']) / 100 + : $option['pricing_value']; + + $optionData['options'][$optionKey] = [ + 'title' => $option['label'], + 'price' => number_format($price, 2) + ]; + } + + $configurableOptions[$attributeKey] = $optionData; + } + + // Sort data for compare + $configurableOptions = $this->sortDataByPath($configurableOptions, '::title'); + foreach ($configurableOptions as $key => $configurableOption) { + $configurableOptions[$key] = $this->sortDataByPath($configurableOption, 'options::title'); + } + $formOptions = $this->sortDataByPath($formOptions, '::title'); + foreach ($formOptions as $key => $formOption) { + $formOptions[$key] = $this->sortDataByPath($formOption, 'options::title'); + } + + $errors = $this->verifyData($configurableOptions, $formOptions, true, false); + return empty($errors) ? null : $this->prepareErrors($errors, 'Error configurable options:'); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableView.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableView.php deleted file mode 100644 index 3daee2a48332f731947212e5a8fa97244fa6033b..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableView.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Constraint; - -use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; -use Magento\Catalog\Test\Page\Product\CatalogProductView; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class AssertConfigurableView - */ -class AssertConfigurableView extends AbstractConstraint -{ - /** - * Constraint severeness - * - * @var string - */ - protected $severeness = 'low'; - - /** - * Assert configurable product, corresponds to the product page - * - * @param CatalogProductView $catalogProductView - * @param Browser $browser - * @param CatalogProductConfigurable $configurable - * @return void - */ - public function processAssert( - CatalogProductView $catalogProductView, - Browser $browser, - CatalogProductConfigurable $configurable - ) { - //Open product view page - $browser->open($_ENV['app_frontend_url'] . $configurable->getUrlKey() . '.html'); - - //Process assertions - $this->assertOnProductView($configurable, $catalogProductView); - } - - /** - * Assert prices on the product view Page - * - * @param CatalogProductConfigurable $configurable - * @param CatalogProductView $catalogProductView - * @return void - */ - protected function assertOnProductView( - CatalogProductConfigurable $configurable, - CatalogProductView $catalogProductView - ) { - /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ - $priceFixture = $configurable->getDataFieldConfig('price')['source']; - $pricePresetData = $priceFixture->getPreset(); - - if (isset($pricePresetData['product_special_price'])) { - $regularPrice = $catalogProductView->getViewBlock()->getProductPriceBlock()->getRegularPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['product_price'], - $regularPrice, - 'Product regular price on product view page is not correct.' - ); - - $specialPrice = $catalogProductView->getViewBlock()->getProductPriceBlock()->getSpecialPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['product_special_price'], - $specialPrice, - 'Product special price on product view page is not correct.' - ); - } else { - //Price verification - $price = $catalogProductView->getViewBlock() - ->getProductPriceBlock($configurable->getName()) - ->getPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $price['price_regular_price'], - $pricePresetData['product_price'], - 'Product price on category page is not correct.' - ); - } - } - - /** - * Text of Visible in category assert - * - * @return string - */ - public function toString() - { - return 'Product price on product view page is not correct.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php similarity index 76% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php index c913d8fc6e602a82813a43d91ce7dd433e52dddd..94a471ebddfda8feb485306c761f28302e70b3df 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php @@ -22,13 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Constraint; +namespace Magento\ConfigurableProduct\Test\Constraint; use Mtf\Constraint\AbstractConstraint; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config as VariationsTab; +use \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute as AttributeBlock; /** * Class AssertProductAttributeAbsenceInVariationsSearch @@ -36,6 +37,11 @@ use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; */ class AssertProductAttributeAbsenceInVariationsSearch extends AbstractConstraint { + /** + * Label "Variations" tab + */ + const TAB_VARIATIONS = 'variations'; + /** * Constraint severeness * @@ -49,21 +55,24 @@ class AssertProductAttributeAbsenceInVariationsSearch extends AbstractConstraint * @param CatalogProductAttribute $productAttribute * @param CatalogProductIndex $productGrid * @param CatalogProductNew $newProductPage - * @param CatalogProductEdit $productEdit * @return void */ public function processAssert ( CatalogProductAttribute $productAttribute, CatalogProductIndex $productGrid, - CatalogProductEdit $productEdit, CatalogProductNew $newProductPage ) { $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); - $productEdit->getForm()->openVariationsTab(); + + /** @var VariationsTab $variationsTab */ + $variationsTab = $newProductPage->getProductForm()->getTabElement(self::TAB_VARIATIONS); + $variationsTab->showContent(); + /** @var AttributeBlock $attributesBlock */ + $attributesBlock = $variationsTab->getAttributeBlock(); \PHPUnit_Framework_Assert::assertFalse( - $newProductPage->getForm()->checkAttributeInVariationsSearchAttributeForm($productAttribute), + $attributesBlock->getAttributeSelector()->isExistAttributeInSearchResult($productAttribute), "Product attribute found in Attribute Search form." ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php old mode 100755 new mode 100644 index 1ba750db88867dbe27e550798ac15d3f1377890c..8396441438055932d365991165d78a86d4f3d517 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php @@ -28,11 +28,11 @@ use Mtf\Fixture\FixtureFactory; use Mtf\Constraint\AbstractConstraint; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; /** * Class AssertProductAttributeIsConfigurable + * Assert check whether the attribute is used to create a configurable products */ class AssertProductAttributeIsConfigurable extends AbstractConstraint { @@ -86,11 +86,11 @@ class AssertProductAttributeIsConfigurable extends AbstractConstraint ] ); - $productBlockForm = $newProductPage->getForm(); + $productBlockForm = $newProductPage->getProductForm(); $productBlockForm->fill($productConfigurable); \PHPUnit_Framework_Assert::assertTrue( - $newProductPage->getForm()->findAttribute($this->attribute->getFrontendLabel()), + $productBlockForm->checkAttributeInSearchAttributeForm($this->attribute), "Product attribute is absent on the product page." ); } @@ -102,6 +102,6 @@ class AssertProductAttributeIsConfigurable extends AbstractConstraint */ public function toString() { - return 'Attribute label, present on the product page in variations section.'; + return 'Attribute label present on the product page in variations section.'; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductConfigurableDuplicateForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductConfigurableDuplicateForm.php deleted file mode 100644 index e666431ea635b3b810bdd8b8915e7591ab95c46c..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductConfigurableDuplicateForm.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Constraint; - -use Mtf\Fixture\FixtureInterface; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\Catalog\Test\Constraint\AssertProductDuplicateForm; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; - -/** - * Class AssertProductConfigurableDuplicateForm - */ -class AssertProductConfigurableDuplicateForm extends AssertProductDuplicateForm -{ - /** - * Constraint severeness - * - * @var string - */ - protected $severeness = 'low'; - - /** - * Assert form data equals duplicate product configurable data - * - * @param FixtureInterface $product - * @param CatalogProductIndex $productGrid - * @param CatalogProductEdit $productPage - * @return void - */ - public function processAssert( - FixtureInterface $product, - CatalogProductIndex $productGrid, - CatalogProductEdit $productPage - ) { - $filter = ['sku' => $product->getSku() . '-1']; - $productGrid->open()->getProductGrid()->searchAndOpen($filter); - - $form = $productPage->getForm(); - $formData = $form->getData($product); - foreach (array_keys($formData['configurable_attributes_data']['matrix']) as $key) { - unset($formData['configurable_attributes_data']['matrix'][$key]['price']); - } - - $fixtureData = $this->prepareFixtureData($product->getData(), $product); - $attributes = $fixtureData['configurable_attributes_data']['attributes_data']; - $matrix = $fixtureData['configurable_attributes_data']['matrix']; - unset($fixtureData['configurable_attributes_data']); - - $fixtureData['configurable_attributes_data']['attributes_data'] = $this->prepareAttributes($attributes); - $fixtureData['configurable_attributes_data']['matrix'] = $this->prepareMatrix($matrix); - - $errors = $this->verifyData($fixtureData, $formData); - \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); - } - - /** - * Preparing data attributes fixture - * - * @param array $fixtureAttribute - * @return array - */ - protected function prepareAttributes(array $fixtureAttribute) - { - foreach ($fixtureAttribute as &$attribute) { - unset($attribute['id'], $attribute['label'], $attribute['code']); - foreach ($attribute['options'] as &$option) { - $option['pricing_value'] = number_format($option['pricing_value'], 4); - unset($option['id']); - } - } - - return $fixtureAttribute; - } - - /** - * Preparing data matrix fixture - * - * @param array $fixtureMatrix - * @return array - */ - protected function prepareMatrix(array $fixtureMatrix) - { - foreach ($fixtureMatrix as &$matrix) { - $matrix['display'] = 'Yes'; - unset($matrix['configurable_attribute'], $matrix['associated_product_ids']); - } - - return $fixtureMatrix; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/ConfigurableAttributesData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/ConfigurableAttributesData.php deleted file mode 100644 index f3914dfe8b3608170389f96adab6d1861614346b..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/ConfigurableAttributesData.php +++ /dev/null @@ -1,581 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -use Mtf\Fixture\FixtureFactory; -use Mtf\Fixture\FixtureInterface; -use Mtf\Fixture\InjectableFixture; - -/** - * Class ConfigurableAttributesData - * Source configurable attributes data of the configurable products - */ -class ConfigurableAttributesData implements FixtureInterface -{ - /** - * Prepared dataSet data - * - * @var array - */ - protected $data = [ - 'products' => [], - 'attributes' => [] - ]; - - /** - * Data set configuration settings - * - * @var array - */ - protected $params; - - /** - * Current preset - * - * @var string - */ - protected $currentPreset; - - /** - * Fixture factory - * - * @var FixtureFactory - */ - protected $fixtureFactory; - - /** - * Source constructor - * - * @param FixtureFactory $fixtureFactory - * @param array $data - * @param array $params [optional] - * - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) - { - $this->fixtureFactory = $fixtureFactory; - $this->params = $params; - $data['products'] = empty($data['products']) ? [] : $data['products']; - $data['attributes'] = empty($data['attributes']) ? [] : $data['attributes']; - - if (isset($data['preset']) && $data['preset'] !== '-') { - $this->currentPreset = $data['preset']; - $this->data = $this->getPreset($this->currentPreset); - unset($data['preset']); - } - - foreach ($data['products'] as $key => $product) { - $this->data['products'][$key] = $product; - } - foreach ($data['attributes'] as $key => $attribute) { - $this->data['attributes'][$key] = $attribute; - } - - $this->prepareProducts(); - $this->prepareAttributes(); - } - - /** - * Persist configurable attribute data - * - * @return void - */ - public function persist() - { - // - } - - /** - * Preparation of products fixture - * - * @return void - */ - protected function prepareProducts() - { - if (!empty($this->data['products'])) { - foreach ($this->data['products'] as $key => $product) { - if (is_string($product)) { - list($fixture, $dataSet) = explode('::', $product); - /** @var $product InjectableFixture */ - $product = $this->fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); - if (!$product->hasData('id')) { - $product->persist(); - } - } - $this->data['products'][$key] = $product; - } - } - } - - /** - * Preparation of attributes fixture - * - * @return void - */ - protected function prepareAttributes() - { - if (!empty($this->data['attributes'])) { - foreach ($this->data['attributes'] as $key => $attribute) { - if (is_string($attribute)) { - list($fixture, $dataSet) = explode('::', $attribute); - /** @var $attribute InjectableFixture */ - $attribute = $this->fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); - if (!$attribute->hasData('id')) { - $attribute->persist(); - } - } - $this->data['attributes'][$key] = $attribute; - } - // Set options used. - $this->setOptions(); - // Initialization data matrix - $this->matrixInit(); - // Assigning products - $this->assigningProducts(); - } - } - - /** - * Set options used - * - * @return void - * - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - protected function setOptions() - { - $fixtures = $this->data['attributes']; - foreach (array_keys($this->data['attributes_data']) as $key) { - $fixtureData = $fixtures[$key]->getData(); - $this->data['attributes_data'][$key]['id'] = isset($fixtureData['attribute_id']) - ? $fixtureData['attribute_id'] - : $key; - $this->data['attributes_data'][$key]['title'] = $fixtureData['frontend_label']; - $this->data['attributes_data'][$key]['code'] = $fixtureData['frontend_label']; - foreach ($this->data['attributes_data'][$key]['options'] as $optionKey => &$value) { - if (!isset($fixtureData['options'][$optionKey])) { - unset($this->data['attributes_data'][$key]['options'][$optionKey]); - continue; - } - $value['id'] = isset($fixtureData['options'][$optionKey]['id']) - ? $fixtureData['options'][$optionKey]['id'] - : $optionKey; - $value['name'] = empty($fixtureData['options'][$optionKey]['view']) - ? $fixtureData['options'][$optionKey]['admin'] - : $fixtureData['options'][$optionKey]['view']; - } - unset($value); - } - } - - /** - * Prepare data for matrix - * - * @return array - */ - protected function prepareDataMatrix() - { - $attributes = []; - foreach ($this->data['attributes_data'] as $attributeKey => $attribute) { - $options = []; - foreach ($attribute['options'] as $optionKey => $option) { - if ($option['include'] === 'Yes') { - $option['key'] = $optionKey; - $options[] = $option; - } - } - $attributes[] = [ - 'key' => $attributeKey, - 'id' => $attribute['id'], - 'code' => $attribute['code'], - 'options' => $options - ]; - } - - return $attributes; - } - - /** - * Generation variants - * - * @return array - */ - protected function generationVariants() - { - $attributes = array_reverse($this->prepareDataMatrix()); - $variations = []; - $attributesCount = count($attributes); - $currentVariation = array_fill(0, $attributesCount, 0); - $lastAttribute = $attributesCount - 1; - do { - for ($attributeIndex = 0; $attributeIndex < $attributesCount - 1; ++$attributeIndex) { - if ($currentVariation[$attributeIndex] >= count($attributes[$attributeIndex]['options'])) { - $currentVariation[$attributeIndex] = 0; - ++$currentVariation[$attributeIndex + 1]; - } - } - if ($currentVariation[$lastAttribute] >= count($attributes[$lastAttribute]['options'])) { - break; - } - - $filledVariation = []; - for ($attributeIndex = $attributesCount; $attributeIndex--;) { - $currentAttribute = $attributes[$attributeIndex]; - $currentVariationValue = $currentVariation[$attributeIndex]; - $filledVariation[$currentAttribute['key']] = $currentAttribute['options'][$currentVariationValue]; - $filledVariation[$currentAttribute['key']]['code'] = $currentAttribute['code']; - } - - $variationsKeys = []; - $placeholder = []; - $optionsNames = []; - foreach ($filledVariation as $key => $option) { - $variationKey = sprintf('%%attribute_%d-option_%d%%', $key, $option['key']); - $variationsKeys[] = $variationKey; - $keyName = sprintf('%%attribute_%d-option_%d_name%%', $key, $option['key']); - $keyId = sprintf('%%attribute_%d-option_%d_id%%', $key, $option['key']); - $attributeCode = sprintf('%%attribute_%d_code%%', $key); - $optionsNames[] = $option['name']; - $placeholder += [ - $keyName => $option['name'], - $keyId => $option['id'], - $variationKey => $option['id'], - $attributeCode => $option['code'] - ]; - } - - $variationsKey = implode('-', $variationsKeys); - $variations[$variationsKey]['placeholder'] = $placeholder; - $variations[$variationsKey]['options_names'] = $optionsNames; - $currentVariation[0]++; - } while (true); - - return $variations; - } - - /** - * Initialization data matrix - * - * @return void - */ - protected function matrixInit() - { - // Generation variants - $variations = $this->generationVariants(); - - foreach (array_keys($this->data['matrix']) as $key) { - if (isset($variations[$key])) { - foreach ($this->data['matrix'][$key] as $innerKey => &$value) { - if ($innerKey === 'configurable_attribute') { - $value = strtr(json_encode($value), $variations[$key]['placeholder']); - } elseif (is_string($value)) { - $value = strtr($value, $variations[$key]['placeholder']); - } - } - unset($value); - $newKey = strtr($key, $variations[$key]['placeholder']); - $this->data['matrix'][$newKey] = $this->data['matrix'][$key]; - $this->data['matrix'][$newKey]['options_names'] = $variations[$key]['options_names']; - unset($this->data['matrix'][$key]); - } - } - } - - /** - * Assigning products - * - * @return void - */ - protected function assigningProducts() - { - foreach ($this->data['products'] as $key => $product) { - foreach ($this->data['matrix'] as &$value) { - if (isset($value['associated_product_ids'][$key])) { - unset($value['associated_product_ids'][$key]); - /** @var $attribute InjectableFixture */ - $value['associated_product_ids'][] = $product->getId(); - $value['name'] = $product->getName(); - $value['sku'] = $product->getSku(); - } - } - unset($value); - } - } - - /** - * Return prepared data set - * - * @param string|null $key - * @return mixed - */ - public function getData($key = null) - { - return isset($this->data[$key]) ? $this->data[$key] : $this->data; - } - - /** - * Return data set configuration settings - * - * @return array - */ - public function getDataConfig() - { - return $this->params; - } - - /** - * Preset array - * - * @param string $name - * @return mixed|null - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function getPreset($name) - { - $presets = [ - 'default' => [ - 'attributes_data' => [ - [ - 'id' => '%id%', - 'title' => '%title%', - 'label' => 'Test variation1 label', - 'options' => [ - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 12.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 20.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 18.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - ] - ], - [ - 'id' => '%id%', - 'title' => '%title%', - 'label' => 'Test variation2 label', - 'options' => [ - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 42.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 40.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 48.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - ] - ] - ], - 'products' => [ - - ], - 'attributes' => [ - 'catalogProductAttribute::attribute_type_dropdown', - 'catalogProductAttribute::attribute_type_dropdown' - ], - 'matrix' => [ - '%attribute_0-option_0%-%attribute_1-option_0%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_0%', - '%attribute_1_code%' => '%attribute_1-option_0%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_0_name% %attribute_1-option_0_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_0_id%_%attribute_1-option_0_id%', - 'qty' => 10, - 'weight' => 1 - ], - '%attribute_0-option_0%-%attribute_1-option_1%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_0%', - '%attribute_1_code%' => '%attribute_1-option_1%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_0_name% %attribute_1-option_1_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_0_id%_%attribute_1-option_1_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_0%-%attribute_1-option_2%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_0%', - '%attribute_1_code%' => '%attribute_1-option_2%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_0_name% %attribute_1-option_2_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_0_id%_%attribute_1-option_2_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_1%-%attribute_1-option_0%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_1%', - '%attribute_1_code%' => '%attribute_1-option_0%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_1_name% %attribute_1-option_0_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_1_id%_%attribute_1-option_0_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_1%-%attribute_1-option_1%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_1%', - '%attribute_1_code%' => '%attribute_1-option_1%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_1_name% %attribute_1-option_1_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_1_id%_%attribute_1-option_1_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_1%-%attribute_1-option_2%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_1%', - '%attribute_1_code%' => '%attribute_1-option_2%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_1_name% %attribute_1-option_2_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_1_id%_%attribute_1-option_2_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_2%-%attribute_1-option_0%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_2%', - '%attribute_1_code%' => '%attribute_1-option_0%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_2_name% %attribute_1-option_0_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_2_id%_%attribute_1-option_0_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_2%-%attribute_1-option_1%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_2%', - '%attribute_1_code%' => '%attribute_1-option_1%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_2_name% %attribute_1-option_1_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_2_id%_%attribute_1-option_1_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_2%-%attribute_1-option_2%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_2%', - '%attribute_1_code%' => '%attribute_1-option_2%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_2_name% %attribute_1-option_2_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_2_id%_%attribute_1-option_2_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ] - ] - ], - 'one_variation' => [ - 'attributes_data' => [ - [ - 'id' => '%id%', - 'title' => '%title%', - 'label' => 'Test variation1 label', - 'options' => [ - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 12.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ] - ] - ] - ], - 'products' => [ - - ], - 'attributes' => [ - 'catalogProductAttribute::attribute_type_dropdown' - ], - 'matrix' => [ - '%attribute_0-option_0%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_0%', - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_0_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_0_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ] - ] - ] - ]; - - if (!isset($presets[$name])) { - return null; - } - - return $presets[$name]; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ConfigurableProduct.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php old mode 100755 new mode 100644 similarity index 59% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ConfigurableProduct.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php index 344edc124ad91ff3ec4bad4064aac4edee0a1c79..fbc37084773eff0dbd2847c296d64de670b5e307 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ConfigurableProduct.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php @@ -21,16 +21,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Fixture; +namespace Magento\ConfigurableProduct\Test\Fixture; + +use Magento\Catalog\Test\Fixture\ProductAttribute; use Mtf\System\Config; use Mtf\Factory\Factory; -use Magento\Catalog\Test\Repository\ConfigurableProduct as Repository; +use Magento\Catalog\Test\Fixture\Product; +use Magento\ConfigurableProduct\Test\Repository\ConfigurableProduct as Repository; /** * Class ConfigurableProduct * Configurable product data - * */ class ConfigurableProduct extends Product { @@ -42,7 +44,7 @@ class ConfigurableProduct extends Product /** * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * Custom constructor to create configurable product with attribute @@ -50,11 +52,11 @@ class ConfigurableProduct extends Product * @param Config $configuration * @param array $placeholders */ - public function __construct(Config $configuration, $placeholders = array()) + public function __construct(Config $configuration, $placeholders = []) { parent::__construct($configuration, $placeholders); - $this->_placeholders['attribute_label_1'] = array($this, 'attributeProvider'); + $this->_placeholders['attribute_label_1'] = [$this, 'attributeProvider']; } /** @@ -66,7 +68,7 @@ class ConfigurableProduct extends Product public function provideNewAttributeData(ProductAttribute $attribute) { $options = $attribute->getOptionLabels(); - $placeholders['new_attribute_label'] = $attribute->getAttributeLabel(); + $placeholders['new_attribute_label'] = $attribute->getFrontendLabel(); $placeholders['new_attribute_option_1_label'] = $options[0]; $placeholders['new_attribute_option_2_label'] = $options[1]; $this->_applyPlaceholders($this->_data, $placeholders); @@ -87,12 +89,12 @@ class ConfigurableProduct extends Product $this->_dataConfig['options'][$attribute->getAttributeId()]['id'] = $attribute->getOptionIds(); $options = $attribute->getOptionLabels(); - $placeholders['attribute_1_name'] = $attribute->getAttributeLabel(); + $placeholders['attribute_1_name'] = $attribute->getFrontendLabel(); $placeholders['attribute_1_option_label_1'] = $options[0]; $placeholders['attribute_1_option_label_2'] = $options[1]; $this->_applyPlaceholders($this->_data, $placeholders); - return $attribute->getAttributeLabel(); + return $attribute->getFrontendLabel(); } /** @@ -103,8 +105,8 @@ class ConfigurableProduct extends Product */ public function getAffectedAttributeSet() { - return $this->getData('affect_configurable_product_attributes') - ? $this->getData('affect_configurable_product_attributes') + return $this->getData('affected_attribute_set') + ? $this->getData('affected_attribute_set') : null; } @@ -117,13 +119,19 @@ class ConfigurableProduct extends Product public function getVariationSku($selectedOption) { $sku = ''; - foreach ($this->getData('fields/variations-matrix/value') as $variation) { - $configurableAttributes = $variation['configurable_attribute']; + $configurableAttributes = $this->getConfigurableAttributes(); + $attributeKey = $selectedOption['title']; + $optionKey = $selectedOption['value']; + $optionValue = $configurableAttributes[$attributeKey][$optionKey]['option_label']['value']; + + foreach ($this->getVariationsMatrix() as $variation) { foreach ($configurableAttributes as $configurableAttribute) { - $attributeOption = $configurableAttribute['attribute_option']; - if ($attributeOption === $selectedOption) { - $sku = $variation['value']['name']['value']; - break 2; + foreach ($configurableAttribute as $option) { + if (isset($option['option_label']['value']) + && $option['option_label']['value'] == $optionValue) { + $sku = $variation['value']['sku']['value']; + break 3; + } } } } @@ -137,9 +145,9 @@ class ConfigurableProduct extends Product */ public function getVariationSkus() { - $variationSkus = array(); + $variationSkus = []; foreach ($this->getVariationsMatrix() as $variation) { - if (is_array($variation)) { + if (is_array($variation) && isset($variation['value']['name']['value'])) { $variationSkus[] = $variation['value']['name']['value']; } } @@ -155,7 +163,7 @@ class ConfigurableProduct extends Product public function getVariationsMatrix() { $variations = $this->getData('fields/variations-matrix/value'); - return is_array($variations) ? $variations : array(); + return is_array($variations) ? $variations : []; } /** @@ -165,7 +173,7 @@ class ConfigurableProduct extends Product */ public function persist() { - $id = Factory::getApp()->magentoCatalogCreateConfigurable($this); + $id = Factory::getApp()->magentoConfigurableProductCreateConfigurable($this); $this->_data['id']['value'] = $id; return $this; @@ -179,7 +187,7 @@ class ConfigurableProduct extends Product public function getConfigurableAttributes() { $attributes = $this->getData('fields/configurable_attributes_data/value'); - return is_array($attributes) ? $attributes : array(); + return is_array($attributes) ? $attributes : []; } /** @@ -189,7 +197,7 @@ class ConfigurableProduct extends Product */ public function getConfigurableOptions() { - $options = array(); + $options = []; foreach ($this->getConfigurableAttributes() as $attribute) { foreach ($attribute as $option) { if (isset($option['option_label']['value'])) { @@ -210,155 +218,150 @@ class ConfigurableProduct extends Product protected function _initData() { parent::_initData(); - $this->_dataConfig = array( + $this->_dataConfig = [ + 'type_id' => 'configurable', 'constraint' => 'Success', - - 'create_url_params' => array( + 'create_url_params' => [ 'type' => Repository::CONFIGURABLE, 'set' => static::DEFAULT_ATTRIBUTE_SET_ID, - ), - ); - $data = array( - 'fields' => array( - 'price' => array( + ], + ]; + $data = [ + 'fields' => [ + 'price' => [ 'value' => '10', 'group' => static::GROUP_PRODUCT_DETAILS - ), - 'tax_class_id' => array( + ], + 'tax_class_id' => [ 'value' => 'Taxable Goods', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select', 'input_value' => '2', - ), - 'weight' => array( + ], + 'weight' => [ 'value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS - ), - 'product_website_1' => array( + ], + 'product_website_1' => [ 'value' => 'Yes', - 'input_value' => array(1), + 'input_value' => [1], 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'website_ids' - ), - 'configurable_attributes_data' => array( - 'value' => array( - '0' => array( - 'label' => array( + ], + 'configurable_attributes_data' => [ + 'value' => [ + '0' => [ + 'label' => [ 'value' => '%attribute_label_1%' - ), - '0' => array( - 'option_label' => array( + ], + '0' => [ + 'option_label' => [ 'value' => '%attribute_1_option_label_1%' - ), - 'pricing_value' => array( + ], + 'pricing_value' => [ 'value' => '1' - ), - 'is_percent' => array( + ], + 'is_percent' => [ 'value' => 'No' - ), - 'include' => array( + ], + 'include' => [ 'value' => 'Yes' - ), - ), - '1' => array( - 'option_label' => array( + ], + ], + '1' => [ + 'option_label' => [ 'value' => '%attribute_1_option_label_2%' - ), - 'pricing_value' => array( + ], + 'pricing_value' => [ 'value' => '2' - ), - 'is_percent' => array( + ], + 'is_percent' => [ 'value' => 'No' - ), - 'include' => array( + ], + 'include' => [ 'value' => 'Yes' - ), - ) - ) - ), + ], + ] + ] + ], 'group' => static::GROUP - ), - 'variations-matrix' => array( - 'value' => array( - '0' => array( - 'configurable_attribute' => array( - '0' => array( + ], + 'variations-matrix' => [ + 'value' => [ + '0' => [ + 'configurable_attribute' => [ + '0' => [ 'attribute_option' => '%attribute_1_option_label_1%' - ) - ), - 'value' => array( - 'display' => array( + ] + ], + 'value' => [ + 'display' => [ 'value' => 'Yes', 'input' => 'checkbox' - ), - 'name' => array( + ], + 'name' => [ 'value' => 'Variation 0-%isolation%' - ), - 'sku' => array( + ], + 'sku' => [ 'value' => 'Variation 0-%isolation%' - ), - 'qty' => array( + ], + 'qty' => [ 'value' => '100' - ) - ) - ), - '1' => array( - 'configurable_attribute' => array( - '0' => array( + ] + ] + ], + '1' => [ + 'configurable_attribute' => [ + '0' => [ 'attribute_option' => '%attribute_1_option_label_2%' - ) - ), - 'value' => array( - 'display' => array( + ] + ], + 'value' => [ + 'display' => [ 'value' => 'Yes', 'input' => 'checkbox' - ), - 'name' => array( + ], + 'name' => [ 'value' => 'Variation 1-%isolation%' - ), - 'sku' => array( + ], + 'sku' => [ 'value' => 'Variation 1-%isolation%' - ), - 'qty' => array( + ], + 'qty' => [ 'value' => '200' - ) - ) - ) - ), + ] + ] + ] + ], 'group' => static::GROUP - ), - ), - 'checkout' => array( - 'selections' => array( - '0' => array( - 'attribute_name' => '%attribute_1_name%', - 'option_name' => '%attribute_1_option_label_1%' - ) - ), + ], + ], + 'checkout_data' => [ + 'configurable_options' => [ + [ + 'title' => '0', + 'value' => '0' + ] + ], 'special_price' => '10' - ) - ); + ] + ]; $this->_data = array_merge_recursive($this->_data, $data); $this->_repository = Factory::getRepositoryFactory() - ->getMagentoCatalogConfigurableProduct($this->_dataConfig, $this->_data); + ->getMagentoConfigurableProductConfigurableProduct($this->_dataConfig, $this->_data); } /** - * Get configurable options + * Get checkout data configurable product * * @return array */ - public function getProductOptions() + public function getCheckoutData() { - $selections = $this->getData('checkout/selections'); - $options = array(); - foreach ($selections as $selection) { - $options[$selection['attribute_name']] = $selection['option_name']; - } - return $options; + return $this->getData('checkout_data'); } /** @@ -369,7 +372,7 @@ class ConfigurableProduct extends Product */ public function getProductSpecialPrice() { - return $this->getData('checkout/special_price'); + return $this->getData('checkout_data/special_price'); } /** @@ -380,19 +383,11 @@ class ConfigurableProduct extends Product public function getProductOptionsPrice() { $price = 0; - $selections = $this->getData('checkout/selections'); - foreach ($selections as $selection) { - $optionName = $selection['option_name']; - $attributes = $this->getData('fields/configurable_attributes_data/value'); - foreach ($attributes as $attribute) { - $optionCount = 0; - while (isset($attribute[$optionCount])) { - if ($attribute[$optionCount]['option_label']['value'] == $optionName) { - $price += $attribute[$optionCount]['pricing_value']['value']; - } - ++$optionCount; - } - } + $configurableOptions = $this->getData('checkout_data/configurable_options'); + $attributes = $this->getData('fields/configurable_attributes_data/value'); + + foreach ($configurableOptions as $option) { + $price += $attributes[$option['title']][$option['value']]['pricing_value']['value']; } return $price; } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.php similarity index 92% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.php index 927a42c2111f2aa1709c0087ddff2598fc8ea2f7..fd65fadaad295332d7f35393c3752cb2b4680119 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.php @@ -32,23 +32,23 @@ use Mtf\Repository\RepositoryFactory; use Mtf\System\Event\EventManagerInterface; /** - * Class CatalogProductConfigurable + * Class ConfigurableProduct * * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.TooManyFields) */ -class CatalogProductConfigurable extends InjectableFixture +class ConfigurableProductInjectable extends InjectableFixture { /** * @var string */ - protected $repositoryClass = 'Magento\ConfigurableProduct\Test\Repository\CatalogProductConfigurable'; + protected $repositoryClass = 'Magento\ConfigurableProduct\Test\Repository\ConfigurableProductInjectable'; // @codingStandardsIgnoreStart /** * @var string */ - protected $handlerInterface = 'Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable\CatalogProductConfigurableInterface'; + protected $handlerInterface = 'Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable\ConfigurableProductInjectableInterface'; // @codingStandardsIgnoreEnd /** @@ -74,6 +74,9 @@ class CatalogProductConfigurable extends InjectableFixture $dataSet = '', $persist = false ) { + if (!isset($data['url_key']) && isset($data['name'])) { + $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); + } parent::__construct( $configuration, $repositoryFactory, @@ -84,13 +87,10 @@ class CatalogProductConfigurable extends InjectableFixture $dataSet, $persist ); - - if (!isset($this->data['url_key']) && isset($this->data['name'])) { - $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); - } } protected $dataConfig = [ + 'type_id' => 'configurable', 'create_url_params' => [ 'type' => 'configurable', 'set' => '4', @@ -100,11 +100,12 @@ class CatalogProductConfigurable extends InjectableFixture protected $defaultDataSet = [ 'type_id' => 'configurable', - 'attribute_set_id' => 'Default', + 'attribute_set_id' => ['dataSet' => 'Default'], 'name' => 'Configurable Product %isolation%', 'sku' => 'sku_configurable_product_%isolation%', 'price' => ['value' => 100.00], 'weight' => 1, + 'url_key' => 'configurable-product-%isolation%', ]; protected $category_ids = [ @@ -113,6 +114,7 @@ class CatalogProductConfigurable extends InjectableFixture 'is_required' => '0', 'default_value' => '', 'input' => 'text', + 'group' => 'product-details', 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\CategoryIds' ]; @@ -178,6 +180,7 @@ class CatalogProductConfigurable extends InjectableFixture 'is_required' => '0', 'default_value' => '', 'input' => 'textarea', + 'group' => 'product-details', ]; protected $enable_googlecheckout = [ @@ -374,7 +377,7 @@ class CatalogProductConfigurable extends InjectableFixture 'default_value' => '', 'input' => 'price', 'group' => 'product-details', - 'source' => 'Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price' + 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\Price', ]; protected $quantity_and_stock_status = [ @@ -408,6 +411,7 @@ class CatalogProductConfigurable extends InjectableFixture 'is_required' => '0', 'default_value' => '', 'input' => 'textarea', + 'group' => 'autosettings', ]; protected $sku = [ @@ -548,6 +552,12 @@ class CatalogProductConfigurable extends InjectableFixture 'group' => 'product-details', ]; + protected $is_virtual = [ + 'attribute_code' => 'is_virtual', + 'backend_type' => 'virtual', + 'group' => 'product-details', + ]; + protected $id = [ 'attribute_code' => 'id', 'backend_type' => 'virtual', @@ -556,6 +566,7 @@ class CatalogProductConfigurable extends InjectableFixture protected $type_id = [ 'attribute_code' => 'type_id', 'backend_type' => 'virtual', + 'group' => null ]; protected $attribute_set_id = [ @@ -571,6 +582,12 @@ class CatalogProductConfigurable extends InjectableFixture 'group' => 'variations' ]; + protected $affected_attribute_set = [ + 'attribute_code' => 'affected_attribute_set', + 'backend_type' => 'virtual', + 'group' => null, + ]; + protected $custom_options = [ 'attribute_code' => 'custom_options', 'backend_type' => 'virtual', @@ -585,7 +602,7 @@ class CatalogProductConfigurable extends InjectableFixture 'is_required' => '0', 'input' => 'variations', 'group' => 'variations', - 'source' => 'Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\ConfigurableAttributesData' + 'source' => 'Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\ConfigurableAttributesData' ]; protected $website_ids = [ @@ -595,6 +612,13 @@ class CatalogProductConfigurable extends InjectableFixture 'group' => 'websites', ]; + protected $checkout_data = [ + 'attribute_code' => 'checkout_data', + 'backend_type' => 'virtual', + 'group' => null, + 'source' => 'Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\CheckoutData', + ]; + public function getCategoryIds() { return $this->getData('category_ids'); @@ -860,6 +884,11 @@ class CatalogProductConfigurable extends InjectableFixture return $this->getData('weight'); } + public function getIsVirtual() + { + return $this->getData('is_virtual'); + } + public function getId() { return $this->getData('id'); @@ -885,6 +914,11 @@ class CatalogProductConfigurable extends InjectableFixture return $this->getData('attribute_set_name'); } + public function getAffectedAttributeSet() + { + return $this->getData('affected_attribute_set'); + } + public function getConfigurableAttributesData() { return $this->getData('configurable_attributes_data'); @@ -894,4 +928,9 @@ class CatalogProductConfigurable extends InjectableFixture { return $this->getData('website_ids'); } + + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.xml similarity index 94% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.xml rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.xml index 8fcbbdc441bacdff88b78a43f3f23b2ed290443e..f778c74eadb1350ce3182b47f329aee4ab7f9d6b 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<fixture class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable"> +<fixture class="Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable"> <module>Magento_ConfigurableProduct</module> <type>eav</type> <entity_type>catalog_product</entity_type> @@ -37,6 +37,8 @@ <is_required>0</is_required> <default_value></default_value> <input>text</input> + <group>product-details</group> + <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\CategoryIds</source> </category_ids> <configurable_attributes_data> <attribute_code>configurable_attributes_data</attribute_code> @@ -44,7 +46,7 @@ <is_required>0</is_required> <input>variations</input> <group>variations</group> - <source>Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\ConfigurableAttributesData</source> + <source>Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\ConfigurableAttributesData</source> </configurable_attributes_data> <color> <attribute_code>color</attribute_code> @@ -101,6 +103,7 @@ <is_required>0</is_required> <default_value></default_value> <input>textarea</input> + <group>product-details</group> </description> <enable_googlecheckout> <attribute_code>enable_googlecheckout</attribute_code> @@ -303,6 +306,7 @@ <is_required>0</is_required> <default_value></default_value> <input>textarea</input> + <group>autosettings</group> </short_description> <sku> <attribute_code>sku</attribute_code> @@ -422,6 +426,10 @@ <input>weight</input> <group>product_info_tabs_product-details</group> </weight> + <is_virtual> + <attribute_code>is_virtual</attribute_code> + <backend_type>virtual</backend_type> + </is_virtual> <id> <attribute_code>id</attribute_code> <backend_type>virtual</backend_type> @@ -429,6 +437,7 @@ <type_id> <attribute_code>type_id</attribute_code> <backend_type>virtual</backend_type> + <group /> </type_id> <attribute_set_id> <attribute_code>attribute_set_id</attribute_code> @@ -441,6 +450,10 @@ <backend_type>virtual</backend_type> <group>product-details</group> </attribute_set_name> + <affected_attribute_set> + <attribute_code>affected_attribute_set</attribute_code> + <backend_type>virtual</backend_type> + </affected_attribute_set> <custom_options> <attribute_code>custom_options</attribute_code> <backend_type>virtual</backend_type> @@ -454,6 +467,12 @@ <default_value>Main Website</default_value> <group>websites</group> </website_ids> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <source>Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\CheckoutData</source> + </checkout_data> </fields> <data_set> <sku></sku> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php new file mode 100644 index 0000000000000000000000000000000000000000..f586878dd952734b8395805bc8575a4f9df3b5aa --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php @@ -0,0 +1,108 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class CheckoutData + * Data for fill product form on frontend + * + * Data keys: + * - preset (Checkout data verification preset name) + */ +class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData +{ + /** + * Get preset array + * + * @param $name + * @return array|null + */ + protected function getPreset($name) + { + $presets = [ + 'default' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_0', + ], + [ + 'title' => 'attribute_1', + 'value' => 'option_0', + ] + ], + 'checkoutItemForm' => [ + 'price' => 101, + ], + 'qty' => 1 + ], + 'two_options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_0', + ] + ], + 'checkoutItemForm' => [ + 'price' => 101, + ] + ], + 'two_new_options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_1', + ] + ], + 'checkoutItemForm' => [ + 'price' => 102, + ] + ], + 'two_new_options_with_special_price' =>[ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_1', + ] + ], + 'checkoutItemForm' => [ + 'price' => 12, + ] + ], + 'two_options_with_assigned_product' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_0', + ] + ], + 'checkoutItemForm' => [ + 'price' => 101, + ] + ], + ]; + return isset($presets[$name]) ? $presets[$name] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php new file mode 100644 index 0000000000000000000000000000000000000000..7109b845623b41daacdc78e313411ccca24ff653 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php @@ -0,0 +1,726 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +use Mtf\Fixture\FixtureFactory; +use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; + +/** + * Class ConfigurableAttributesData + * Source configurable attributes data of the configurable products + */ +class ConfigurableAttributesData implements FixtureInterface +{ + /** + * Fixture factory + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Data set configuration settings + * + * @var array + */ + protected $params; + + /** + * Prepared dataSet data + * + * @var array + */ + protected $data = []; + + /** + * Prepared attributes data + * + * @var array + */ + protected $attributesData = []; + + /** + * Prepared variation matrix + * + * @var array + */ + protected $variationsMatrix = []; + + /** + * Prepared attributes + * + * @var array + */ + protected $attributes = []; + + /** + * Prepared products + * + * @var array + */ + protected $products = []; + + /** + * Presets data + * + * @var array + */ + protected $presets = [ + 'default' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'options' => [ + 'option_0' => [ + 'pricing_value' => 12.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + 'option_1' => [ + 'pricing_value' => 20.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + 'option_2' => [ + 'pricing_value' => 18.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + ] + ], + 'attribute_1' => [ + 'options' => [ + 'option_0' => [ + 'pricing_value' => 42.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + 'option_1' => [ + 'pricing_value' => 40.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + 'option_2' => [ + 'pricing_value' => 48.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + ] + ] + ], + 'products' => [ + + ], + 'attributes' => [ + 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown', + 'attribute_1' => 'catalogProductAttribute::attribute_type_dropdown' + ], + 'matrix' => [ + 'attribute_0:option_0 attribute_1:option_0' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_0 attribute_1:option_1' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_0 attribute_1:option_2' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1 attribute_1:option_0' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1 attribute_1:option_1' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1 attribute_1:option_2' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_2 attribute_1:option_0' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_2 attribute_1:option_1' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_2 attribute_1:option_2' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + ] + ], + 'one_variation' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'options' => [ + 'option_0' => [ + 'pricing_value' => 12.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ] + ] + ] + ], + 'products' => [ + + ], + 'attributes' => [ + 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_one_option' + ], + 'matrix' => [ + 'attribute_0:option_0' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + ] + ], + 'two_options' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'options' => [ + 'option_0' => [ + 'label' => 'option_1_%isolation%', + 'pricing_value' => 1, + 'is_percent' => 'Yes', + 'include' => 'Yes' + ], + 'option_1' => [ + 'label' => 'option_2_%isolation%', + 'pricing_value' => 2, + 'is_percent' => 'Yes', + 'include' => 'Yes', + ] + ] + ] + ], + 'attributes' => [ + 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_two_options', + ], + 'products' => [], + 'matrix' => [ + 'attribute_0:option_0' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 20 + ], + 'weight' => 2 + ] + ] + ], + 'two_new_options' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'frontend_label' => 'two_new_options_title_%isolation%', + 'frontend_input' => 'Dropdown', + 'label' => 'two_new_options_title_%isolation%', + 'is_required' => 'No', + 'options' => [ + 'option_0' => [ + 'label' => 'option_1_%isolation%', + 'pricing_value' => 1, + 'is_percent' => 'No', + 'include' => 'Yes' + ], + 'option_1' => [ + 'label' => 'option_2_%isolation%', + 'pricing_value' => 2, + 'is_percent' => 'No', + 'include' => 'Yes', + ] + ] + ] + ], + 'attributes' => [], + 'products' => [], + 'matrix' => [ + 'attribute_0:option_0' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 20 + ], + 'weight' => 2 + ] + ] + ], + 'two_options_with_assigned_product' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'options' => [ + 'option_0' => [ + 'label' => 'option_1_%isolation%', + 'pricing_value' => 1, + 'is_percent' => 'Yes', + 'include' => 'Yes' + ], + 'option_1' => [ + 'label' => 'option_2_%isolation%', + 'pricing_value' => 2, + 'is_percent' => 'Yes', + 'include' => 'Yes', + ] + ] + ] + ], + 'attributes' => [ + 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_two_options', + ], + 'products' => [ + 'attribute_0:option_0' => 'catalogProductSimple::default', + 'attribute_0:option_1' => 'catalogProductSimple::default' + ], + 'matrix' => [ + 'attribute_0:option_0' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 20 + ], + 'weight' => 2 + ] + ] + ] + ]; + + + /** + * Source constructor + * + * @param FixtureFactory $fixtureFactory + * @param array $data + * @param array $params [optional] + */ + public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) + { + $this->fixtureFactory = $fixtureFactory; + $this->params = $params; + + $preset = isset($data['preset']) ? $this->getPreset($data['preset']) : []; + + $this->prepareAttributes($preset); + $this->prepareAttributesData($preset); + $this->prepareProducts($preset); + $this->prepareVariationsMatrix($preset); + $this->prepareData(); + } + + /** + * Persist configurable attribute data + * + * @return void + */ + public function persist() + { + // + } + + /** + * Prepare attributes + * + * @param array $data + * @return void + */ + protected function prepareAttributes(array $data) + { + if (empty($data['attributes'])) { + return; + } + + foreach ($data['attributes'] as $key => $attribute) { + if (is_string($attribute)) { + list($fixture, $dataSet) = explode('::', $attribute); + /** @var InjectableFixture $attribute */ + $attribute = $this->fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); + } + if (!$attribute->hasData('attribute_id')) { + $attribute->persist(); + } + $this->attributes[$key] = $attribute; + } + } + + /** + * Prepare attributes data + * + * @param array $data + * @return void + */ + protected function prepareAttributesData(array $data) + { + foreach ($this->attributes as $attributeKey => $attribute) { + $attributeData = $attribute->getData(); + $options = []; + + foreach ($attributeData['options'] as $key => $option) { + $options['option_' . $key] = $option; + } + $attributeData['options'] = $options; + + $this->attributesData[$attributeKey] = $attributeData; + } + + $this->attributesData = array_replace_recursive( + isset($data['attributes_data']) ? $data['attributes_data'] : [], + $this->attributesData + ); + } + + /** + * Prepare products + * + * @param array $data + * @return void + */ + protected function prepareProducts(array $data) + { + if (empty($data['products'])) { + return; + } + + $attributeSetData = []; + if (!empty($this->attributes)) { + $attributeSetData['attribute_set_id'] = ['attribute_set' => $this->createAttributeSet()]; + } + + foreach ($data['products'] as $key => $product) { + if (is_string($product)) { + list($fixture, $dataSet) = explode('::', $product); + $attributeData = ['attributes' => $this->getProductAttributeData($key)]; + $product = $this->fixtureFactory->createByCode( + $fixture, + ['dataSet' => $dataSet, 'data' => array_merge($attributeSetData, $attributeData)] + ); + } + if (!$product->hasData('id')) { + $product->persist(); + } + + $this->products[$key] = $product; + } + } + + /** + * Create attribute set + * + * @return FixtureInterface + */ + protected function createAttributeSet() + { + $attributeSet = $this->fixtureFactory->createByCode( + 'catalogAttributeSet', + [ + 'dataSet' => 'custom_attribute_set', + 'data' => [ + 'assigned_attributes' => [ + 'attributes' => array_values($this->attributes) + ] + ] + ] + ); + $attributeSet->persist(); + return $attributeSet; + } + + /** + * Get prepared attribute data for persist product + * + * @param string $key + * @return array + */ + protected function getProductAttributeData($key) + { + $compositeKeys = explode(' ', $key); + $data = []; + + foreach ($compositeKeys as $compositeKey) { + $attributeId = $this->getAttributeOptionId($compositeKey); + if ($attributeId) { + $compositeKey = explode(':', $compositeKey); + $attributeKey = $compositeKey[0]; + $data[$this->attributesData[$attributeKey]['attribute_code']] = $attributeId; + } + } + + return $data; + } + + /** + * Get id of attribute option by composite key + * + * @param string $compositeKey + * @return int|null + */ + protected function getAttributeOptionId($compositeKey) + { + list($attributeKey, $optionKey) = explode(':', $compositeKey); + return isset($this->attributesData[$attributeKey]['options'][$optionKey]['id']) + ? $this->attributesData[$attributeKey]['options'][$optionKey]['id'] + : null; + } + + /** + * Prepare data for matrix + * + * @param array $data + * @return void + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + protected function prepareVariationsMatrix(array $data) + { + $variationsMatrix = []; + + // generate matrix + foreach ($this->attributesData as $attributeKey => $attribute) { + $variationsMatrix = $this->addVariationMatrix($variationsMatrix, $attribute, $attributeKey); + } + $this->variationsMatrix = array_replace_recursive($variationsMatrix, $data['matrix']); + + // assigned products + foreach ($this->variationsMatrix as $key => $row) { + if (isset($this->products[$key])) { + /** @var CatalogProductSimple $product */ + $product = $this->products[$key]; + $quantityAndStockStatus = $product->getQuantityAndStockStatus(); + + $this->variationsMatrix[$key]['configurable_attribute'] = $product->getId(); + $this->variationsMatrix[$key]['name'] = $product->getName(); + $this->variationsMatrix[$key]['sku'] = $product->getSku(); + $this->variationsMatrix[$key]['quantity_and_stock_status']['qty'] = $quantityAndStockStatus['qty']; + $this->variationsMatrix[$key]['weight'] = $product->getWeight(); + } + } + } + + /** + * Add matrix variation + * + * @param array $variationsMatrix + * @param array $attribute + * @param string $attributeKey + * @return array + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + protected function addVariationMatrix(array $variationsMatrix, array $attribute, $attributeKey) + { + $result = []; + + /* If empty matrix add one empty row */ + if (empty($variationsMatrix)) { + $variationsMatrix = [ + [ + 'name' => 'In configurable product %isolation%', + 'sku' => 'in_configurable_product_%isolation%', + ] + ]; + } + + foreach ($variationsMatrix as $rowKey => $row) { + foreach ($attribute['options'] as $optionKey => $option) { + $compositeKey = "{$attributeKey}:{$optionKey}"; + $optionId = $this->getAttributeOptionId($compositeKey); + + $row['name'] .= '-' . $optionId; + $row['sku'] .= '_' . $optionId; + + $newRowKey = $rowKey ? "{$rowKey} {$compositeKey}" : $compositeKey; + $result[$newRowKey] = $row; + } + } + + return $result; + } + + /** + * Prepare data from source + * + * @return void + */ + protected function prepareData() + { + $attributeFields = [ + 'frontend_label', + 'label', + 'frontend_input', + 'attribute_code', + 'attribute_id', + 'is_required', + 'options', + ]; + $optionFields = [ + 'label', + 'pricing_value', + 'is_percent', + 'include', + ]; + $variationMatrixFields = [ + 'configurable_attribute', + 'display', + 'name', + 'sku', + 'price', + 'quantity_and_stock_status', + 'weight', + ]; + + $this->data = [ + 'matrix' => [], + 'attributes_data' => [] + ]; + + foreach ($this->attributesData as $attributeKey => $attribute) { + foreach ($attribute['options'] as $optionKey => $option) { + $option['label'] = isset($option['view']) ? $option['view'] : $option['label']; + $attribute['options'][$optionKey] = array_intersect_key($option, array_flip($optionFields)); + } + $attribute['label'] = isset($attribute['label']) ? $attribute['label'] : $attribute['frontend_label']; + $attribute = array_intersect_key($attribute, array_flip($attributeFields)); + + $this->data['attributes_data'][$attributeKey] = $attribute; + } + foreach ($this->variationsMatrix as $key => $variationMatrix) { + $this->data['matrix'][$key] = array_intersect_key($variationMatrix, array_flip($variationMatrixFields)); + } + } + + /** + * Return data set configuration settings + * + * @return array + */ + public function getDataConfig() + { + return $this->params; + } + + /** + * Return prepared data set + * + * @param string|null $key + * @return mixed + */ + public function getData($key = null) + { + return isset($this->data[$key]) ? $this->data[$key] : $this->data; + } + + /** + * Get prepared attributes data + * + * @return array + */ + public function getAttributesData() + { + return $this->attributesData; + } + + /** + * Get prepared variations matrix + * + * @return array + */ + public function getVariationsMatrix() + { + return $this->variationsMatrix; + } + + /** + * Get prepared attributes + * + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Get prepared products + * + * @return array + */ + public function getProducts() + { + return $this->products; + } + + /** + * Preset array + * + * @param string $name + * @return mixed|null + */ + protected function getPreset($name) + { + return isset($this->presets[$name]) ? $this->presets[$name] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/Curl.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/Curl.php deleted file mode 100644 index a33deec3fec0b1efaf8e7124195242447173024a..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/Curl.php +++ /dev/null @@ -1,169 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable; - -use Mtf\System\Config; -use Mtf\Fixture\FixtureInterface; -use Mtf\Util\Protocol\CurlTransport; -use Magento\Catalog\Test\Handler\CatalogProductSimple\Curl as ProductCurl; - -/** - * Class Curl - * Create new configurable product via curl - */ -class Curl extends ProductCurl implements CatalogProductConfigurableInterface -{ - /** - * Constructor - * - * @param Config $configuration - */ - public function __construct(Config $configuration) - { - parent::__construct($configuration); - - $this->mappingData += [ - 'is_percent' => [ - 'Yes' => 1, - 'No' => 0 - ], - 'include' => [ - 'Yes' => 1, - 'No' => 0 - ] - ]; - } - - /** - * Prepare POST data for creating product request - * - * @param FixtureInterface $fixture - * @param string|null $prefix [optional] - * @return array - */ - protected function prepareData(FixtureInterface $fixture, $prefix = null) - { - $data = parent::prepareData($fixture, null); - $attributeSetId = $data['attribute_set_id']; - $matrix = $data['configurable_attributes_data']['matrix']; - $attributesData = $data['configurable_attributes_data']['attributes_data']; - unset($data['configurable_attributes_data'], $data['attribute_set_id']); - - // Preparing attribute data - $attributesIds = []; - $data['configurable_attributes_data'] = $this->preparingAttributeData($attributesData, $attributesIds); - $matrix = $this->preparingMatrixData( - $matrix, - [ - '%product_name%' => $data['name'], - '%product_sku%' => $data['sku'], - ] - ); - - // Add prefix data - $data = $prefix ? [$prefix => $data] : $data; - $data['attributes'] = $attributesIds; - - $data = array_merge($data, $this->prepareVariationsMatrix($matrix)); - $data['new-variations-attribute-set-id'] = $attributeSetId; - - return $this->replaceMappingData($data); - } - - /** - * Preparing attribute data - * - * @param array $attributesData - * @param array $attributesIds [link] - * @return array - */ - protected function preparingAttributeData(array $attributesData, array &$attributesIds) - { - $data = []; - foreach ($attributesData as $attribute) { - $attributesIds[] = $attribute['id']; - $data[$attribute['id']] = []; - $dataOption = & $data[$attribute['id']]; - $dataOption['code'] = $attribute['title']; - $dataOption['label'] = $attribute['title']; - $dataOption['attribute_id'] = $attribute['id']; - foreach ($attribute['options'] as $option) { - $dataOption['values'][$option['id']]['pricing_value'] = $option['pricing_value']; - $dataOption['values'][$option['id']]['is_percent'] = $option['is_percent']; - $dataOption['values'][$option['id']]['include'] = $option['include']; - $dataOption['values'][$option['id']]['value_index'] = $option['id']; - } - } - - return $data; - } - - /** - * Preparing matrix data - * - * @param array $matrix - * @param array $placeholder - * @return array - */ - protected function preparingMatrixData(array $matrix, array $placeholder) - { - foreach (array_keys($matrix) as $key) { - foreach ($matrix[$key] as &$value) { - if (is_string($value)) { - $value = strtr($value, $placeholder); - } - } - } - - return $matrix; - } - - /** - * Prepare variations matrix data - * - * @param array $matrix - * @return array - */ - protected function prepareVariationsMatrix(array $matrix) - { - $data = [ - 'variations-matrix' => [], - 'associated_product_ids' => [] - ]; - foreach ($matrix as $key => $variation) { - $data['associated_product_ids'] = array_merge( - $data['associated_product_ids'], - $variation['associated_product_ids'] - ); - $data['variations-matrix'][$key]['name'] = $variation['name']; - $data['variations-matrix'][$key]['configurable_attribute'] = $variation['configurable_attribute']; - $data['variations-matrix'][$key]['sku'] = $variation['sku']; - $data['variations-matrix'][$key]['quantity_and_stock_status']['qty'] = $variation['qty']; - $data['variations-matrix'][$key]['weight'] = $variation['weight']; - } - - return $data; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/CatalogProductConfigurableInterface.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/ConfigurableProductInjectableInterface.php similarity index 82% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/CatalogProductConfigurableInterface.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/ConfigurableProductInjectableInterface.php index dba4fea8b1d3aa887de470ab1ae1da9b4098211e..049f914bd9e9c6e346972f6946c7be234734d9e0 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/CatalogProductConfigurableInterface.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/ConfigurableProductInjectableInterface.php @@ -22,14 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable; +namespace Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable; use Mtf\Handler\HandlerInterface; /** - * Interface CatalogProductConfigurableInterface + * Interface ConfigurableProductInjectableInterface */ -interface CatalogProductConfigurableInterface extends HandlerInterface +interface ConfigurableProductInjectableInterface extends HandlerInterface { // } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/Curl.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/Curl.php new file mode 100644 index 0000000000000000000000000000000000000000..d0f6e70df45847326ec23de278e23b0b25ac529d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/Curl.php @@ -0,0 +1,181 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable; + +use Mtf\System\Config; +use Mtf\Fixture\FixtureInterface; +use Mtf\Util\Protocol\CurlTransport; +use Magento\Catalog\Test\Handler\CatalogProductSimple\Curl as ProductCurl; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\ConfigurableAttributesData; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; + +/** + * Class Curl + * Create new configurable product via curl + */ +class Curl extends ProductCurl implements ConfigurableProductInjectableInterface +{ + /** + * Constructor + * + * @param Config $configuration + */ + public function __construct(Config $configuration) + { + parent::__construct($configuration); + + $this->mappingData += [ + 'is_percent' => [ + 'Yes' => 1, + 'No' => 0 + ], + 'include' => [ + 'Yes' => 1, + 'No' => 0 + ] + ]; + } + + /** + * Prepare POST data for creating product request + * + * @param FixtureInterface $product + * @param string|null $prefix [optional] + * @return array + */ + protected function prepareData(FixtureInterface $product, $prefix = null) + { + $data = parent::prepareData($product, null); + + /** @var ConfigurableAttributesData $configurableAttributesData */ + $configurableAttributesData = $product->getDataFieldConfig('configurable_attributes_data')['source']; + $attributeSetId = $data['attribute_set_id']; + + $data['configurable_attributes_data'] = $this->prepareAttributesData($configurableAttributesData); + $data = $prefix ? [$prefix => $data] : $data; + $data['variations-matrix'] = $this->prepareVariationsMatrix($product); + $data['attributes'] = $this->prepareAttributes($configurableAttributesData); + $data['new-variations-attribute-set-id'] = $attributeSetId; + $data['associated_product_ids'] = []; + + return $this->replaceMappingData($data); + } + + /** + * Preparing attribute data + * + * @param ConfigurableAttributesData $configurableAttributesData + * @return array + */ + protected function prepareAttributesData(ConfigurableAttributesData $configurableAttributesData) + { + $optionFields = [ + 'pricing_value', + 'is_percent', + 'include', + ]; + $result = []; + + foreach ($configurableAttributesData->getAttributesData() as $attribute) { + $attributeId = isset($attribute['attribute_id']) ? $attribute['attribute_id'] : null; + $dataOptions = []; + + foreach ($attribute['options'] as $option) { + $optionId = isset($option['id']) ? $option['id'] : null; + + $dataOption = array_intersect_key($option, array_flip($optionFields)); + $dataOption['value_index'] = $optionId; + + $dataOptions[$optionId] = $dataOption; + } + + $result[$attributeId] = [ + 'code' => $attribute['attribute_code'], + 'attribute_id' => $attributeId, + 'label' => $attribute['frontend_label'], + 'values' => $dataOptions + ]; + } + + return $result; + } + + /** + * Preparing matrix data + * + * @param FixtureInterface $product + * @return array + */ + protected function prepareVariationsMatrix(FixtureInterface $product) + { + /** @var ConfigurableAttributesData $configurableAttributesData */ + $configurableAttributesData = $product->getDataFieldConfig('configurable_attributes_data')['source']; + $attributesData = $configurableAttributesData->getAttributesData(); + $matrixData = $product->getConfigurableAttributesData()['matrix']; + $result = []; + + foreach ($matrixData as $variationKey => $variation) { + $compositeKeys = explode(' ', $variationKey); + $keyIds = []; + $configurableAttribute = []; + + foreach ($compositeKeys as $compositeKey) { + list($attributeKey, $optionKey) = explode(':', $compositeKey); + $attribute = $attributesData[$attributeKey]; + + $keyIds[] = $attribute['options'][$optionKey]['id']; + $configurableAttribute[] = sprintf( + '"%s":"%s"', + $attribute['attribute_code'], + $attribute['options'][$optionKey]['id'] + ); + } + + $keyIds = implode('-', $keyIds); + $variation['configurable_attribute'] = '{' . implode(',', $configurableAttribute) . '}'; + $result[$keyIds] = $variation; + } + + return $result; + } + + /** + * Prepare attributes + * + * @param ConfigurableAttributesData $configurableAttributesData + * @return array + */ + protected function prepareAttributes(ConfigurableAttributesData $configurableAttributesData) + { + $ids = []; + + foreach ($configurableAttributesData->getAttributes() as $attribute) { + /** @var CatalogProductAttribute $attribute */ + $ids[] = $attribute->getAttributeId(); + } + return $ids; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Curl/CreateConfigurable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/Curl/CreateConfigurable.php similarity index 94% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Curl/CreateConfigurable.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/Curl/CreateConfigurable.php index 3b57ed5855a89a8eae8e0608092db73b90e07836..b3d8769e3a2fe12f87b0870ea29150f0fd513bad 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Curl/CreateConfigurable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/Curl/CreateConfigurable.php @@ -23,15 +23,15 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Handler\Curl; +namespace Magento\ConfigurableProduct\Test\Handler\Curl; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; -use Mtf\Fixture\FixtureInterface; use Mtf\Handler\Curl; use Mtf\System\Config; use Mtf\Util\Protocol\CurlInterface; use Mtf\Util\Protocol\CurlTransport; use Mtf\Util\Protocol\CurlTransport\BackendDecorator; +use Mtf\Fixture\FixtureInterface; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; /** * Class Create Configurable Product @@ -46,13 +46,13 @@ class CreateConfigurable extends Curl */ protected function _prepareData(ConfigurableProduct $fixture) { - $curlData = array(); + $curlData = []; $curlData['product'] = $this->_getProductData($fixture); $curlData['product']['configurable_attributes_data'] = $this->_getConfigurableData($fixture); $curlData['variations-matrix'] = $this->_getVariationMatrix($fixture); $curlData['attributes'] = $fixture->getDataConfig()['attributes']['id']; - $curlData['affect_configurable_product_attributes'] = 1; + $curlData['affected_attribute_set'] = 1; $curlData['new-variations-attribute-set-id'] = 4; $curlData['product']['category_ids'] = $fixture->getCategoryIds(); @@ -71,7 +71,7 @@ class CreateConfigurable extends Curl */ protected function _getProductData(ConfigurableProduct $fixture) { - $curlData = array(); + $curlData = []; $baseData = $fixture->getData('fields'); unset($baseData['configurable_attributes_data']); unset($baseData['variations-matrix']); @@ -85,10 +85,10 @@ class CreateConfigurable extends Curl } $curlData['quantity_and_stock_status']['is_in_stock'] = 1; - $curlData['stock_data'] = array( + $curlData['stock_data'] = [ 'use_config_manage_stock' => 1, 'is_in_stock' => 1 - ); + ]; return $curlData; } @@ -103,7 +103,7 @@ class CreateConfigurable extends Curl { $configurableAttribute = $fixture->getData('fields/configurable_attributes_data/value'); $config = $fixture->getDataConfig(); - $curlData = array(); + $curlData = []; foreach ($configurableAttribute as $attributeNumber => $attribute) { $attributeId = $config['attributes']['id'][$attributeNumber]; @@ -137,7 +137,7 @@ class CreateConfigurable extends Curl { $config = $fixture->getDataConfig(); $variationData = $fixture->getData('fields/variations-matrix/value'); - $curlData = array(); + $curlData = []; $variationNumber = 0; foreach ($config['options'] as $attributeId => $options) { foreach ($options['id'] as $option) { @@ -174,7 +174,7 @@ class CreateConfigurable extends Curl $params = $this->_prepareData($fixture); $curl = new BackendDecorator(new CurlTransport(), new Config()); $curl->addOption(CURLOPT_HEADER, 1); - $curl->write(CurlInterface::POST, $url, '1.0', array(), $params); + $curl->write(CurlInterface::POST, $url, '1.0', [], $params); $response = $curl->read(); $curl->close(); diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductEdit.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductEdit.xml old mode 100644 new mode 100755 diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml old mode 100644 new mode 100755 index 4f9d7579b298e0d0f8bf7423f2cd38257c675376..88d3d654d50e50e46bcd7330e34b118f86305e25 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml @@ -25,10 +25,19 @@ --> <page mca="catalog/product/new"> <blocks> - <configurableForm> + <formPageActions> + <renders> + <configurable> + <class>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\FormPageActions</class> + </configurable> + </renders> + </formPageActions> + <productForm> + <renders> + <configurable> <class>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </configurableForm> + </configurable> + </renders> + </productForm> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Product/CatalogProductView.xml new file mode 100644 index 0000000000000000000000000000000000000000..af7e9ddc1bdef34438709847270b9e7c8780b0c2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Product/CatalogProductView.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="catalog/product/view"> + <blocks> + <viewBlock> + <renders> + <configurable> + <class>Magento\ConfigurableProduct\Test\Block\Product\View</class> + </configurable> + </renders> + </viewBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigurableProduct.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.php old mode 100755 new mode 100644 similarity index 88% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigurableProduct.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.php index 37877aab6dade4cce06b1aaad80df0737b1b87c1..79069c70ee1b27b79aa168ec84b6fe4a2f01800a --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigurableProduct.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.php @@ -21,10 +21,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Repository; +namespace Magento\ConfigurableProduct\Test\Repository; use Magento\Catalog\Test\Fixture; -use Magento\Catalog\Test\Fixture\ConfigurableProduct as ConfigurableProductFixture; +use Magento\Catalog\Test\Repository\Product; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct as ConfigurableProductFixture; /** * Class Configurable Product Repository @@ -121,7 +122,7 @@ class ConfigurableProduct extends Product protected function buildProductVariations(array $defaultData) { $data = $defaultData; - $data['affect_configurable_product_attributes'] = 'Template %isolation%'; + $data['affected_attribute_set'] = 'Template %isolation%'; $data['fields'] = array( 'configurable_attributes_data' => array( 'value' => array( @@ -169,6 +170,9 @@ class ConfigurableProduct extends Product protected function editConfigurable() { $editData = array( + 'config' => [ + 'type_id' => 'configurable' + ], 'data' => array( 'fields' => array( 'name' => array( @@ -205,7 +209,23 @@ class ConfigurableProduct extends Product ), 'variations-matrix' => array( 'value' => array( - '0' => array( + '0' => [ + 'value' => [ + 'display' => array( + 'value' => 'Yes', + 'input' => 'checkbox' + ), + ] + ], + '1' => [ + 'value' => [ + 'display' => array( + 'value' => 'Yes', + 'input' => 'checkbox' + ), + ] + ], + '2' => array( 'configurable_attribute' => array( '0' => array( 'attribute_option' => 'Option3_%isolation%' diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/CatalogProductConfigurable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php similarity index 91% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/CatalogProductConfigurable.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php index b7a8498137d9cccfed669a534ccf2d8c3de57f2b..bd125a2ebdd39b132ed026b96d66f9c4f771d6c1 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/CatalogProductConfigurable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php @@ -27,10 +27,10 @@ namespace Magento\ConfigurableProduct\Test\Repository; use Mtf\Repository\AbstractRepository; /** - * Class CatalogProductConfigurable + * Class ConfigurableProductInjectable * Data for creation Catalog Product Configurable */ -class CatalogProductConfigurable extends AbstractRepository +class ConfigurableProductInjectable extends AbstractRepository { /** * Constructor @@ -50,16 +50,17 @@ class CatalogProductConfigurable extends AbstractRepository 'status' => 'Product online', 'visibility' => 'Catalog, Search', 'tax_class_id' => ['dataSet' => 'Taxable Goods'], - 'url_key' => 'test-configurable-product-%isolation%', + 'url_key' => 'configurable-product-%isolation%', 'configurable_attributes_data' => ['preset' => 'default'], 'quantity_and_stock_status' => [ 'is_in_stock' => 'In Stock', ], 'website_ids' => ['Main Website'], 'attribute_set_id' => ['dataSet' => 'default'], + 'checkout_data' => ['preset' => 'default'], ]; - $this->_data['default_one_variation'] = [ + $this->_data['one_variation'] = [ 'name' => 'Test configurable product %isolation%', 'sku' => 'sku_test_configurable_product_%isolation%', 'price' => ['value' => 120.00], diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4c57a3af5cd1dfab9312915eb9c591445eb052d2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Catalog\Test\Fixture\CatalogCategory; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Test Coverage for CreateConfigurableProductEntity + * + * Test Flow: + * + * Preconditions: + * 1. Two simple products are created. + * 2. Configurable attribute with two options is created + * 3. Configurable attribute added to Default template + * + * Steps: + * 1. Go to Backend + * 2. Open Product -> Catalog + * 3. Click on narrow near "Add Product" button + * 4. Select Configurable Product + * 5. Fill in data according to data sets + * 5.1 If field "attributeNew/dataSet" is not empty - search created attribute by putting it's name + * to variation Search field. + * 5.2 If "attribute/dataSet" is not empty- create new Variation Set + * 6. Save product + * 7. Perform all assertions + * + * @group Configurable_Product_(MX) + * @ZephyrId MAGETWO-26041 + */ +class CreateConfigurableProductEntityTest extends Injectable +{ + /** + * Product page with a grid + * + * @var CatalogProductIndex + */ + protected $productIndex; + + /** + * Page to create a product + * + * @var CatalogProductNew + */ + protected $productNew; + + /** + * Injection data + * + * @param CatalogProductIndex $productIndex + * @param CatalogProductNew $productNew + * @return void + */ + public function __inject(CatalogProductIndex $productIndex, CatalogProductNew $productNew) + { + $this->productIndex = $productIndex; + $this->productNew = $productNew; + } + + /** + * Test create catalog Configurable product run + * + * @param ConfigurableProductInjectable $product + * @return void + */ + public function test(ConfigurableProductInjectable $product) + { + // Steps + $this->productIndex->open(); + $this->productIndex->getGridPageActionBlock()->addProduct('configurable'); + $this->productNew->getProductForm()->fill($product); + $this->productNew->getFormPageActions()->save($product); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..89c333704a0047ce10c86243d60d8e4061ab0339 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv @@ -0,0 +1,5 @@ +"product/data/configurable_attributes_data/preset";"product/data/checkout_data/preset";"product/data/name";"product/data/sku";"product/data/tax_class_id";"product/data/price/value";"product/data/special_price";"product/data/category_ids/presets";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/is_in_stock";"product/data/affected_attribute_set";"constraint";"issue" +"two_new_options";"two_new_options";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"default_subcategory";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertProductInCategory, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart, assertChildProductIsNotDisplayedSeparately";"Bug: MAGETWO-26979" +"two_options";"two_options";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"-";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart";"" +"two_new_options";"two_new_options_with_special_price";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"10";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart, assertProductSpecialPriceOnProductPage";"Bug: MAGETWO-26979" +"two_options_with_assigned_product";"two_options_with_assigned_product";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart";"" diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateConfigurableTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php similarity index 88% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateConfigurableTest.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php index ba57c01cbce46f21940e6e1946627e785408661c..f126cdd375ae873c44dba505feb718909b4e86c5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateConfigurableTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php @@ -22,11 +22,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\TestCase\Product; +namespace Magento\ConfigurableProduct\Test\TestCase; use Mtf\Factory\Factory; use Mtf\TestCase\Functional; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; /** * Class CreateConfigurableTest @@ -34,16 +34,6 @@ use Magento\Catalog\Test\Fixture\ConfigurableProduct; */ class CreateConfigurableTest extends Functional { - /** - * Login into backend area before test - * - * @return void - */ - protected function setUp() - { - Factory::getApp()->magentoBackendLoginUser(); - } - /** * Creating configurable product and assigning it to category * @@ -53,7 +43,7 @@ class CreateConfigurableTest extends Functional public function testCreateConfigurableProduct() { //Data - $product = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $product = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $product->switchData('configurable'); //Page & Blocks $manageProductsGrid = Factory::getPageFactory()->getCatalogProductIndex(); @@ -61,9 +51,8 @@ class CreateConfigurableTest extends Functional //Steps $manageProductsGrid->open(); $manageProductsGrid->getGridPageActionBlock()->addProduct('configurable'); - $productForm = $createProductPage->getProductForm(); - $productForm->fill($product); - $createProductPage->getFormAction()->saveProduct($createProductPage, $product); + $createProductPage->getProductForm()->fill($product); + $createProductPage->getFormPageActions()->save($product); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache @@ -82,7 +71,7 @@ class CreateConfigurableTest extends Functional * @param ConfigurableProduct $product * @return void */ - protected function assertOnGrid($product) + protected function assertOnGrid(ConfigurableProduct $product) { //Search data $configurableSearch = [ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/CreateWithAttributeTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php old mode 100755 new mode 100644 similarity index 76% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/CreateWithAttributeTest.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php index 898c802d99cb96aac091d417d7e6a776228afe66..8194b254bc050538ea6fd96714b6e0d65cd17382 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/CreateWithAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php @@ -22,13 +22,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\TestCase\Product\Configurable; +namespace Magento\ConfigurableProduct\Test\TestCase; use Mtf\Factory\Factory; use Mtf\TestCase\Functional; use Magento\Catalog\Test\Fixture\Product; use Magento\Catalog\Test\Fixture\ProductAttribute; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; /** * Class CreateWithAttributeTest @@ -36,16 +36,6 @@ use Magento\Catalog\Test\Fixture\ConfigurableProduct; */ class CreateWithAttributeTest extends Functional { - /** - * Login into backend area before test - * - * @return void - */ - protected function setUp() - { - Factory::getApp()->magentoBackendLoginUser(); - } - /** * Creating configurable product with creating new category and new attribute (required fields only) * @@ -61,7 +51,7 @@ class CreateWithAttributeTest extends Functional $attribute = Factory::getFixtureFactory()->getMagentoCatalogProductAttribute(); $attribute->switchData('new_attribute'); - $variations = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $variations = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $variations->switchData('product_variations'); $variations->provideNewAttributeData($attribute); @@ -82,11 +72,11 @@ class CreateWithAttributeTest extends Functional * @param Product $product * @return void */ - protected function fillSimpleProductWithNewCategory($product) + protected function fillSimpleProductWithNewCategory(Product $product) { //Page & Blocks $manageProductsGrid = Factory::getPageFactory()->getCatalogProductIndex(); - $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); + $createProductPage = Factory::getPageFactory()->getCatalogProductEdit(); $productForm = $createProductPage->getProductForm(); //Steps @@ -105,19 +95,21 @@ class CreateWithAttributeTest extends Functional */ protected function addNewAttribute(ProductAttribute $attribute) { - $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); + $attributeData = $attribute->getData(); + $attributeFields = []; + foreach ($attributeData['fields'] as $name => $field) { + $attributeFields[$name] = $field['value']; + } + $attributeFields['options'] = $attributeData['options']['value']; - $productForm = $createProductPage->getConfigurableProductForm(); - $productForm->openVariationsTab(); - $productForm->clickCreateNewVariationSet(); - - $newAttributeForm = $productForm->getConfigurableAttributeEditBlock(); - $this->assertTrue($newAttributeForm->isVisible(), '"New attribute" window is not opened'); + $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); + $productForm = $createProductPage->getProductForm(); + $productForm->openTab('variations'); - $newAttributeForm->openFrontendProperties(); - $newAttributeForm->fill($attribute); - $newAttributeForm->saveAttribute(); - Factory::getClientBrowser()->switchToFrame(); + /** @var \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config $variations */ + $variations = $productForm->getTabElement('variations'); + $variations->showContent(); + $variations->getAttributeBlock()->fillAttributes([$attributeFields]); } /** @@ -128,9 +120,26 @@ class CreateWithAttributeTest extends Functional */ protected function fillProductVariationsAndSave(ConfigurableProduct $variations) { + $variationsData = $variations->getData(); + $matrix = []; + foreach ($variationsData['fields']['variations-matrix']['value'] as $variation) { + $matrix[] = [ + 'quantity_and_stock_status' => [ + 'qty' => $variation['value']['qty']['value'] + ] + ]; + } + $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); - $createProductPage->getProductForm()->fillVariations($variations); - $createProductPage->getFormAction()->saveProduct($createProductPage, $variations); + $productForm = $createProductPage->getProductForm(); + $productForm->openTab('variations'); + + /** @var \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config $variationsTab */ + $variationsTab = $productForm->getTabElement('variations'); + $variationsTab->generateVariations(); + $variationsTab->getVariationsBlock()->fillVariations($matrix); + + $createProductPage->getFormPageActions()->save($variations); } /** @@ -156,10 +165,10 @@ class CreateWithAttributeTest extends Functional */ protected function assertOnGrid(Product $product) { - $configurableSearch = array( + $configurableSearch = [ 'sku' => $product->getProductSku(), 'type' => 'Configurable Product', - ); + ]; $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); $gridBlock = $productGridPage->getProductGrid(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/EditConfigurableTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/EditConfigurableTest.php old mode 100755 new mode 100644 similarity index 92% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/EditConfigurableTest.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/EditConfigurableTest.php index 7c4e5dfc882f08c25b02a874f567c771f8911c5e..a63df3a08ee26c133671012685540293d71ccd43 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/EditConfigurableTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/EditConfigurableTest.php @@ -22,10 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\TestCase\Product\Configurable; +namespace Magento\ConfigurableProduct\Test\TestCase; use Mtf\Factory\Factory; -use Magento\Catalog\Test\TestCase\Product\CreateConfigurableTest; /** * Class EditConfigurableTest @@ -43,12 +42,13 @@ class EditConfigurableTest extends CreateConfigurableTest { //Preconditions //Preparing Data for original product - $configurable = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $configurable = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $configurable->switchData('configurable'); $configurable->persist(); $productSku = $configurable->getProductSku(); //Preparing Data for editing product $editProduct = $configurable->getEditData(); + //Steps $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); $productForm = $createProductPage->getProductForm(); @@ -60,7 +60,7 @@ class EditConfigurableTest extends CreateConfigurableTest $productGridPage->getProductGrid()->searchAndOpen(['sku' => $productSku]); //Editing product options $productForm->fill($editProduct); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest.php deleted file mode 100755 index 05581120708e14808d0983bc37d42f4d019fa09b..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest.php +++ /dev/null @@ -1,118 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\TestCase\Product; - -use Mtf\TestCase\Injectable; -use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Test Coverage for CreateConfigurableProductEntity - * - * General Flow: - * 1. Log in to Backend. - * 2. Navigate to Products > Catalog. - * 3. Start to create new product. - * 4. Fill in data according to data set. - * 5. Save product. - * 6. Verify created product. - * - * @ticketId MAGETWO-20024 - */ -class CreateConfigurableEntityTest extends Injectable -{ - /** - * Category fixture - * - * @var CatalogCategory - */ - protected $category; - - /** - * Backend catalog page (product grid) - * - * @var CatalogProductIndex - */ - protected $productPageGrid; - - /** - * Product page (product form) - * - * @var CatalogProductNew - */ - protected $newProductPage; - - /** - * Prepare data - * - * @param CatalogCategory $category - * @return array - */ - public function __prepare(CatalogCategory $category) - { - $category->persist(); - - return [ - 'category' => $category - ]; - } - - /** - * Inject data - * - * @param CatalogCategory $category - * @param CatalogProductIndex $productPageGrid - * @param CatalogProductNew $newProductPage - */ - public function __inject( - CatalogCategory $category, - CatalogProductIndex $productPageGrid, - CatalogProductNew $newProductPage - ) { - $this->category = $category; - $this->productPageGrid = $productPageGrid; - $this->newProductPage = $newProductPage; - } - - /** - * Run create configurable product test - * - * @param CatalogProductConfigurable $configurable - * @param CatalogCategory $category - * @return void - */ - public function testCreate(CatalogProductConfigurable $configurable, CatalogCategory $category) - { - // Steps - $this->productPageGrid->open(); - $this->productPageGrid->getGridPageActionBlock()->addProduct('configurable'); - // Fill form - $productBlockForm = $this->newProductPage->getConfigurableProductForm(); - $productBlockForm->fill($configurable, null, $category); - $this->newProductPage->getFormAction()->saveProduct($this->newProductPage, $configurable); - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest/testCreate.csv b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest/testCreate.csv deleted file mode 100755 index 628ab880371262a2e115516f9378b4ca46eea3c4..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest/testCreate.csv +++ /dev/null @@ -1,2 +0,0 @@ -"configurable/data/name"; "configurable/data/sku"; "configurable/data/price/value"; "configurable/data/weight"; "configurable/data/quantity_and_stock_status/qty"; "configurable/data/quantity_and_stock_status/is_in_stock"; "configurable/data/visibility"; "constraint"; "configurable/data/price/preset";"configurable/data/configurable_attributes_data/preset"; -"Configurable %isolation%"; "conf_sku_%isolation%";"100";"1";"-";"-";"-"; "assertProductSaveMessage, assertConfigurableInGrid, assertConfigurableInCategory, assertConfigurableView, assertConfigurableInCart";"MAGETWO-23062";"default"; diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/constraint.xml index 242fa89249052907126ed777349fe6eb4a0b25e8..07c5623891313a7462c671d158c5680825e8c03c 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/constraint.xml @@ -24,59 +24,28 @@ */ --> <constraint> - <assertConfigurableInGrid module="Magento_ConfigurableProduct"> + <assertConfigurableProductInCart module="Magento_ConfigurableProduct"> + <severeness>low</severeness> + </assertConfigurableProductInCart> + <assertConfigurableProductDuplicateForm module="Magento_ConfigurableProduct"> <severeness>high</severeness> - <require> - <manageProductsPage class="Magento\Catalog\Test\Page\Product\CatalogProductIndex" /> - <configurable class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable" /> - </require> - </assertConfigurableInGrid> - <assertConfigurableInCategory module="Magento_ConfigurableProduct"> + </assertConfigurableProductDuplicateForm> + <assertChildProductIsNotDisplayedSeparately module="Magento_ConfigurableProduct"> + <severeness>middle</severeness> + </assertChildProductIsNotDisplayedSeparately> + <assertChildProductsInGrid module="Magento_ConfigurableProduct"> <severeness>low</severeness> - <require> - <catalogCategoryView class="Magento\Catalog\Test\Page\Category\CatalogCategoryView" /> - <cmsIndex class="Magento\Cms\Test\Page\CmsIndex" /> - <configurable class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable" /> - <category class="Magento\Catalog\Test\Fixture\Category" /> - </require> - </assertConfigurableInCategory> - <assertConfigurableView module="Magento_ConfigurableProduct"> + </assertChildProductsInGrid> + <assertConfigurableProductForm module="Magento_ConfigurableProduct"> <severeness>low</severeness> - <require> - <catalogProductView class="Magento\Catalog\Test\Page\Product\CatalogProductView" /> - <configurable class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable" /> - </require> - </assertConfigurableView> - <assertConfigurableInCart module="Magento_ConfigurableProduct"> + </assertConfigurableProductForm> + <assertConfigurableProductInItemsOrderedGrid module="Magento_ConfigurableProduct"> <severeness>low</severeness> - <require> - <catalogProductView class="Magento\Catalog\Test\Page\Product\CatalogProductView" /> - <configurable class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable" /> - <checkoutCart class="Magento\Checkout\Test\Page\CheckoutCart" /> - </require> - </assertConfigurableInCart> - <assertProductAttributeIsConfigurable module="Magento_ConfigurableProduct"> - <severeness>high</severeness> - <require> - <productAttribute class="Magento\Catalog\Test\Fixture\CatalogAttributeEntity" /> - <productGrid class="Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex" /> - <newProductPage class="Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew" /> - </require> - </assertProductAttributeIsConfigurable> - <assertProductConfigurableDuplicateForm module="Magento_ConfigurableProduct"> + </assertConfigurableProductInItemsOrderedGrid> + <assertConfigurableProductPage module="Magento_ConfigurableProduct"> <severeness>high</severeness> - <require> - <productGrid class="Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex" /> - <productPage class="Magento\ConfigurableProduct\Test\Page\Adminhtml\CatalogProductEdit" /> - <product class="Mtf\Fixture\FixtureInterface" /> - </require> - </assertProductConfigurableDuplicateForm> - <assertConfigurableProductForm module="Magento_ConfigurableProduct"> - <severeness>high</severeness> - <require> - <productGrid class="Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex" /> - <productPage class="Magento\ConfigurableProduct\Test\Page\Adminhtml\CatalogProductEdit" /> - <product class="Mtf\Fixture\FixtureInterface" /> - </require> - </assertConfigurableProductForm> + </assertConfigurableProductPage> + <assertProductAttributeAbsenceInVariationsSearch module="Magento_ConfigurableProduct"> + <severeness>low</severeness> + </assertProductAttributeAbsenceInVariationsSearch> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml old mode 100644 new mode 100755 index c60ac77fe79bb5d8f785a3a2f99fdf5b14731959..1e7f710a6de8e5c37e8b6420b88c20d00e7d8f7c --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml @@ -24,5 +24,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable\CatalogProductConfigurableInterface" type="\Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable\Curl" /> + <preference for="Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable\ConfigurableProductInjectableInterface" type="\Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable\Curl" /> </config> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/fixture.xml index 0ea61b470ee4ed79875d2a961789a16fddc5e971..1ca8a81b2d206b84e8ae1e4eea13c6e804b0d8bf 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/fixture.xml @@ -25,7 +25,7 @@ --> <fixture> - <catalogProductConfigurable module="Magento_ConfigurableProduct"> + <configurableProductInjectable module="Magento_ConfigurableProduct"> <type>eav</type> <entity_type>catalog_product</entity_type> <product_type>configurable</product_type> @@ -49,7 +49,7 @@ <backend_type>virtual</backend_type> <is_required>0</is_required> <group>variations</group> - <fixture>Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\ConfigurableOptions</fixture> + <fixture>Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\ConfigurableOptions</fixture> </configurable_options> </fields> <data_set> @@ -66,5 +66,5 @@ </create_url_params> <input_prefix>product</input_prefix> </data_config> - </catalogProductConfigurable> + </configurableProductInjectable> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/page.xml new file mode 100644 index 0000000000000000000000000000000000000000..d9c92344d7dc98121301b239c38a4228f4ac252d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/page.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page module="Magento_ConfigurableProduct"> + <catalogProductEdit> + <mca>catalog/product/edit</mca> + <area>adminhtml</area> + <class>Magento\Configurable\Test\Page\Adminhtml\CatalogProductEdit</class> + </catalogProductEdit> + <catalogProductNew> + <mca>catalog/product/edit</mca> + <area>adminhtml</area> + <class>Magento\Configurable\Test\Page\Adminhtml\CatalogProductNew</class> + </catalogProductNew> + <catalogProductView> + <mca>catalog/product/view</mca> + <area>product</area> + <class>Magento\Configurable\Test\Page\CatalogProductView</class> + </catalogProductView> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Core/Test/Block/Messages.php b/dev/tests/functional/tests/app/Magento/Core/Test/Block/Messages.php index c72bb53b30fba065a5d33a3afe9fd6b663042f52..31297e06bdc33ac32580358302b93dc0fad9dc12 100644 --- a/dev/tests/functional/tests/app/Magento/Core/Test/Block/Messages.php +++ b/dev/tests/functional/tests/app/Magento/Core/Test/Block/Messages.php @@ -89,6 +89,24 @@ class Messages extends Block return count($messages) > 1 ? $messages : $messages[0]; } + /** + * Wait for element is visible in the page + * + * @param string $selector + * @param string $strategy + * @return bool|null + */ + public function waitForElementVisible($selector, $strategy = Locator::SELECTOR_CSS) + { + $browser = $this->browser; + return $browser->waitUntil( + function () use ($browser, $selector, $strategy) { + $message = $browser->find($selector, $strategy); + return $message->isVisible() ? true : null; + } + ); + } + /** * Get all error messages which are present on the page * diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php index 062bb11cb818ca30ae7a248533d9c52cb86e0f02..72fddd7a3403a95c2962f5ec002968f7a25c9067 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php @@ -33,6 +33,13 @@ use Magento\Backend\Test\Block\Widget\Grid as AbstractGrid; */ class CustomerGrid extends AbstractGrid { + /** + * Selector for action option select + * + * @var string + */ + protected $option = '[name="group"]'; + /** * Filters array mapping * diff --git a/lib/internal/Magento/Framework/Error/HandlerInterface.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/FormPageActions.php similarity index 65% rename from lib/internal/Magento/Framework/Error/HandlerInterface.php rename to dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/FormPageActions.php index 5bc4cd4a01dd4e255eef9dd1093a485fbfaf7f25..59be071e65ed412b14545b953eaf28613b48aee7 100644 --- a/lib/internal/Magento/Framework/Error/HandlerInterface.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/FormPageActions.php @@ -22,30 +22,30 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Test\Block\Adminhtml\Edit; + +use Magento\Backend\Test\Block\FormPageActions as ParentFormPageActions; + /** - * Interface of Error Handler + * Class FormPageActions + * Form page actions block for customer page */ -namespace Magento\Framework\Error; - -interface HandlerInterface +class FormPageActions extends ParentFormPageActions { /** - * Error handler callback method + * "Create Order" button * - * @param int $errorNo - * @param string $errorStr - * @param string $errorFile - * @param int $errorLine - * @return bool + * @var string */ - public function handler($errorNo, $errorStr, $errorFile, $errorLine); + protected $createOrderButton = '#order'; /** - * Process exception + * Click on "Create Order" button * - * @param \Exception $exception - * @param string[] $params * @return void */ - public function processException(\Exception $exception, array $params = array()); + public function createOrder() + { + $this->_rootElement->find($this->createOrderButton)->click(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertMassActionSuccessUpdateMessage.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertMassActionSuccessUpdateMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..fc88269417a887bbc0a10c3fbf73987a9fe8fb72 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertMassActionSuccessUpdateMessage.php @@ -0,0 +1,73 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; + +/** + * Class AssertMassActionSuccessUpdateMessage + * Assert update message is appears on customer grid (Customers > All Customers) + */ +class AssertMassActionSuccessUpdateMessage extends AbstractConstraint +{ + /** + * Text value to be checked + */ + const UPDATE_MESSAGE = 'A total of %d record(s) were updated.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert update message is appears on customer grid (Customers > All Customers) + * + * @param CustomerInjectable|CustomerInjectable[] $customer + * @param CustomerIndex $pageCustomerIndex + * @return void + */ + public function processAssert($customer, CustomerIndex $pageCustomerIndex) + { + $customers = is_array($customer) ? $customer : [$customer]; + $customerCount = count($customers); + $actualMessage = $pageCustomerIndex->getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertEquals(sprintf(self::UPDATE_MESSAGE, $customerCount), $actualMessage); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Assert that update message is displayed.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/GroupId.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/GroupId.php index 695bd9998150425d11fafb55fd044bf8a250b144..910d212ce6379f3aea9ce7d8c66294f6245cc954 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/GroupId.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/GroupId.php @@ -117,7 +117,7 @@ class GroupId implements FixtureInterface * * @return array */ - public function getAddresses() + public function getCustomerGroup() { return $this->customerGroupFixture; } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml index 0a43813146a4df03f162895620e376d0dbafc596..903c8a5a4fcfba5a1ce32621ee9d788115664049 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml @@ -36,7 +36,7 @@ <strategy>css selector</strategy> </messagesBlock> <pageActionsBlock> - <class>Magento\Backend\Test\Block\FormPageActions</class> + <class>Magento\Customer\Test\Block\Adminhtml\Edit\FormPageActions</class> <locator>.page-main-actions</locator> <strategy>css selector</strategy> </pageActionsBlock> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.php deleted file mode 100644 index 313553af0ae5c672ea160eb0beb434afdd16b35f..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @spi - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Customer\Test\Page; - -use Mtf\Page\Page; -use Mtf\Factory\Factory; -use Mtf\Client\Element\Locator; - -/** - * Class CustomerAccountLogin - * Customer frontend login page. - * - */ -class CustomerAccountLogin extends Page -{ - /** - * URL for customer login - */ - const MCA = 'customer/account/login'; - - /** - * Messages block - * - * @var string - */ - protected $messagesBlock = '.page.messages'; - - /** - * Form for customer login - * - * @var string - */ - protected $loginBlock = '#login-form'; - - /** - * Custom constructor - */ - protected function _init() - { - $this->_url = $_ENV['app_frontend_url'] . self::MCA; - } - - /** - * Get Messages block - * - * @return \Magento\Core\Test\Block\Messages - */ - public function getMessages() - { - return Factory::getBlockFactory()->getMagentoCoreMessages($this->_browser->find($this->messagesBlock)); - } - - /** - * Get customer login form - * - * @return \Magento\Customer\Test\Block\Form\Login - */ - public function getLoginBlock() - { - return Factory::getBlockFactory()->getMagentoCustomerFormLogin( - $this->_browser->find($this->loginBlock, Locator::SELECTOR_CSS) - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.xml new file mode 100644 index 0000000000000000000000000000000000000000..6405c18d5356693f8cac5dabcfefaf7a94d8b8bc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="customer/account/login" module="Magento_Customer"> + <blocks> + <messages> + <class>Magento\Core\Test\Block\Messages</class> + <locator>.page.messages</locator> + <strategy>css selector</strategy> + </messages> + <loginBlock> + <class>Magento\Customer\Test\Block\Form\Login</class> + <locator>#login-form</locator> + <strategy>css selector</strategy> + </loginBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c9230ef62969e275ab101584bdacaf42d54322b0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.php @@ -0,0 +1,110 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Fixture\CustomerGroupInjectable; + +/** + * Test creation for MassAssignCustomerGroup + * + * Test Flow: + * + * Preconditions: + * 1. Create customer + * 2. Create customer group + * + * Steps: + * 1. Open Backend + * 2. Go to Customers> All Customers + * 3. Find and select(using checkbox) created customer + * 4. Select "Assign a Customer Group" from action drop-down + * 5. Select created customer group + * 6. Click "Submit" button + * 7. Perform all assertions + * + * @group Customer_Groups_(CS), Customers_(CS) + * @ZephyrId MAGETWO-27892 + */ +class MassAssignCustomerGroupTest extends Injectable +{ + /** + * Customer index page + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customers grid actions + * + * @var string + */ + protected $customersGridActions = 'Assign a Customer Group'; + + /** + * Prepare data + * + * @param CustomerInjectable $customer + * @return array + */ + public function __prepare(CustomerInjectable $customer) + { + $customer->persist(); + + return ['customer' => $customer]; + } + + /** + * Injection data + * + * @param CustomerIndex $customerIndex + * @return void + */ + public function __inject(CustomerIndex $customerIndex) + { + $this->customerIndex = $customerIndex; + } + + /** + * Mass assign customer group + * + * @param CustomerInjectable $customer + * @param CustomerGroupInjectable $customerGroup + * @return void + */ + public function test(CustomerInjectable $customer, CustomerGroupInjectable $customerGroup) + { + // Steps + $customerGroup->persist(); + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->massaction( + [['email' => $customer->getEmail()]], + [$this->customersGridActions => $customerGroup->getCustomerGroupCode()] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest/test.csv b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..67a66f8bf9c90a1c4d50d72124a8f32545786a21 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest/test.csv @@ -0,0 +1,2 @@ +"customerGroup/dataSet";"constraint" +"default";"assertMassActionSuccessUpdateMessage, assertCustomerGroupInGrid" diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml index c82ef107d76d97fb11bbdedadd98532c6395e135..48923128731e51307dd9c7ab59d98fd0d96ce986 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml @@ -133,4 +133,7 @@ <severeness>low</severeness> <require /> </assertCustomerMassDeleteInGrid> + <assertMassActionSuccessUpdateMessage module="Magento_Customer"> + <severeness>low</severeness> + </assertMassActionSuccessUpdateMessage> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/page.xml index a40bce6276e2e33f3583f638ca1fdb86997b8dea..58b39cbc38f602c522ef9436273166e28d04c255 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/page.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/page.xml @@ -32,6 +32,10 @@ <mca>customer/account/index</mca> <class>Magento\Customer\Test\Page\CustomerAccountIndex</class> </customerAccountIndex> + <customerAccountLogin> + <mca>customer/account/login</mca> + <class>Magento\Customer\Test\Page\CustomerAccountLogin</class> + </customerAccountLogin> <customerAccountEdit> <mca>customer/account/edit</mca> <class>Magento\Customer\Test\Page\CustomerAccountEdit</class> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php index b831d11b23e7ad4bc32947a51a9b83869c37d2d6..c12476856b3496c3f40f67dcd201045a0b7c3128 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php @@ -57,7 +57,7 @@ class AssertDownloadableDuplicateForm extends AssertProductDuplicateForm $filter = ['sku' => $product->getSku() . '-1']; $productGrid->open()->getProductGrid()->searchAndOpen($filter); - $formData = $productPage->getForm()->getData($product); + $formData = $productPage->getProductForm()->getData($product); $fixtureData = $this->convertDownloadableArray($this->prepareFixtureData($product->getData())); $errors = $this->verifyData($fixtureData, $formData); diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php index 40a4780c22562a4995d72789ef7d4c2f0e8bcc83..e6d589489fade8431829af9c6d9f88127b3bce60 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php @@ -75,6 +75,9 @@ class CatalogProductDownloadable extends InjectableFixture $dataSet = '', $persist = false ) { + if (!isset($data['url_key']) && isset($data['name'])) { + $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); + } parent::__construct( $configuration, $repositoryFactory, @@ -85,10 +88,6 @@ class CatalogProductDownloadable extends InjectableFixture $dataSet, $persist ); - - if (!isset($this->data['url_key']) && isset($this->data['name'])) { - $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); - } } protected $dataConfig = [ @@ -120,6 +119,7 @@ class CatalogProductDownloadable extends InjectableFixture 'is_required' => '0', 'default_value' => '', 'input' => 'text', + 'group' => 'product-details', 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\CategoryIds' ]; diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml index e83b7dea98518d8a973b6e8a2ca688d787f4d6ab..b900829c1ee0e6265f83d717bdb6185a641218ef 100755 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml @@ -37,6 +37,8 @@ <is_required>0</is_required> <default_value></default_value> <input>text</input> + <group>product-details</group> + <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\CategoryIds</source> </category_ids> <cost> <attribute_code>cost</attribute_code> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php index db0a8266b81936bb7ff4e922ea3eae9944079531..9b064e8544a6989f68ee532ed00918414350639f 100755 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php @@ -61,11 +61,11 @@ class LinksPurchasedSeparatelyTest extends Functional $createProductPage->getGridPageActionBlock()->addProduct('downloadable'); $createProductPageNew = Factory::getPageFactory()->getCatalogProductNew(); - $productBlockForm = $createProductPageNew->getForm(); + $productBlockForm = $createProductPageNew->getProductForm(); $category = $this->product->getCategories()['category']; $productBlockForm->fill($this->product, null, $category); - $createProductPageNew->getFormAction()->save(); + $createProductPageNew->getFormPageActions()->save(); $createProductPageNew->getMessagesBlock()->assertSuccessMessage(); diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php index 7c7f564bc8f604fcf7806eeff524c7133086410b..d10086c72ebddb0ab5d97643635e5f77e54b87ac 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php @@ -111,8 +111,8 @@ class CreateDownloadableProductEntityTest extends Injectable { $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('downloadable'); - $productBlockForm = $this->catalogProductNew->getForm(); + $productBlockForm = $this->catalogProductNew->getProductForm(); $productBlockForm->fill($product, null, $category); - $this->catalogProductNew->getFormAction()->save(); + $this->catalogProductNew->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php index 0c0de0794e321460be47f6792c72dc235f72f94d..0f8267503003352b415dd68a9c2b75aeec228652 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php @@ -121,8 +121,8 @@ class UpdateDownloadableProductEntityTest extends Injectable { $filter = ['sku' => $this->product->getSku()]; $this->catalogProductIndex->open()->getProductGrid()->searchAndOpen($filter); - $productBlockForm = $this->catalogProductEdit->getForm(); + $productBlockForm = $this->catalogProductEdit->getProductForm(); $productBlockForm->fill($product, null, $category); - $this->catalogProductEdit->getFormAction()->save(); + $this->catalogProductEdit->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductForm.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductForm.php index b85ac418f65fcbe4881b5c0719c54165913b78b2..71fabdb0b9593a1b60b6a5c864cd9b10d66f3616 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductForm.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductForm.php @@ -56,7 +56,7 @@ class AssertGroupedProductForm extends AssertProductForm ) { $filter = ['sku' => $product->getSku()]; $productGrid->open()->getProductGrid()->searchAndOpen($filter); - $fieldsForm = $productPage->getForm()->getData($product); + $fieldsForm = $productPage->getProductForm()->getData($product); $fieldsFixture = $this->prepareFixtureData($product->getData()); $fieldsFixture['associated'] = $this->prepareGroupedOptions($fieldsFixture['associated']); diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php index a50d70becffb78b0675ca0c45587a57f6a39895c..d8ecfa6b48df209ea07b6b6c214768d6de719ec7 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php @@ -75,6 +75,9 @@ class CatalogProductGrouped extends InjectableFixture $dataSet = '', $persist = false ) { + if (!isset($data['url_key']) && isset($data['name'])) { + $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); + } parent::__construct( $configuration, $repositoryFactory, @@ -85,10 +88,6 @@ class CatalogProductGrouped extends InjectableFixture $dataSet, $persist ); - - if (!isset($this->data['url_key']) && isset($this->data['name'])) { - $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); - } } protected $dataConfig = [ diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php index ed912e0c5b66412745e274be662d6fa69ffb8591..04ea3664ed7b77a1fc6373aa51cdc770fee99e75 100755 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php @@ -105,8 +105,7 @@ class CreateGroupedProductEntityTest extends Injectable //Steps $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('grouped'); - $productBlockForm = $this->catalogProductNew->getForm(); - $productBlockForm->fill($product, null, $category); - $this->catalogProductNew->getFormAction()->save(); + $this->catalogProductNew->getProductForm()->fill($product, null, $category); + $this->catalogProductNew->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php index fbff0403b2dae61861d8e237819a42ffc2759eb9..cce5f8a4976e07fd17569451b946a3c3c178b3db 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php @@ -94,7 +94,7 @@ class UpdateGroupedProductEntityTest extends Injectable // Steps $this->catalogProductIndex->open(); $this->catalogProductIndex->getProductGrid()->searchAndOpen(['sku' => $originalProduct->getSku()]); - $this->catalogProductEdit->getForm()->fill($product); - $this->catalogProductEdit->getFormAction()->save(); + $this->catalogProductEdit->getProductForm()->fill($product); + $this->catalogProductEdit->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php new file mode 100644 index 0000000000000000000000000000000000000000..863f515d1bbfa2f8f6f1a2cbf38e96b19761a9a6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php @@ -0,0 +1,115 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Block\Adminhtml\Customer; + +use Mtf\ObjectManager; +use Mtf\Client\Element\Locator; + +/** + * Class AccountsGrid + * New Customer Account report grid + */ +class AccountsGrid extends \Magento\Backend\Test\Block\Widget\Grid +{ + /** + * Mapping for fields in Account Report Grid + * + * @var array + */ + protected $dataMapping = [ + 'report_from' => 'datepicker', + 'report_to' => 'datepicker', + 'report_period' => 'select', + ]; + + /** + * Total results locator + * + * @var string + */ + protected $totalResults = 'tfoot .col-qty'; + + /** + * Filter locator + * + * @var string + */ + protected $filter = '[name=%s]'; + + /** + * Refresh button locator + * + * @var string + */ + protected $refreshButton = '[data-ui-id="adminhtml-report-grid-refresh-button"]'; + + /** + * Search accounts in report grid + * + * @var array $customersReport + * @return void + */ + public function searchAccounts(array $customersReport) + { + $customersReport = $this->prepareData($customersReport); + foreach ($customersReport as $name => $value) { + $this->_rootElement + ->find(sprintf($this->filter, $name), Locator::SELECTOR_CSS, $this->dataMapping[$name]) + ->setValue($value); + } + $this->_rootElement->find($this->refreshButton)->click(); + } + + /** + * Get total Results from New Accounts Report grid + * + * @return string + */ + public function getTotalResults() + { + return $this->_rootElement->find($this->totalResults)->getText(); + } + + /** + * Prepare data + * + * @param array $customersReport + * @return array + */ + protected function prepareData(array $customersReport) + { + foreach ($customersReport as $name => $reportFilter) { + if ($name === 'report_period') { + continue; + } + $date = ObjectManager::getInstance()->create( + '\Magento\Backend\Test\Fixture\Date', + ['params' => [], 'data' => ['pattern' => $reportFilter]] + ); + $customersReport[$name] = $date->getData(); + } + return $customersReport; + } +} diff --git a/app/code/Magento/Install/Controller/Wizard/Administrator.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php similarity index 67% rename from app/code/Magento/Install/Controller/Wizard/Administrator.php rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php index ebdd7c395fa99c4a9c1c2ecfcd020a0548dfc3a7..bccabb9ab184b7da74044e94ffa87ee23caf8476 100644 --- a/app/code/Magento/Install/Controller/Wizard/Administrator.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,23 +21,31 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class Administrator extends \Magento\Install\Controller\Wizard +namespace Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed; + +use Magento\Backend\Test\Block\GridPageActions; + +/** + * Class Action + * Action block for Product Views Report + */ +class Action extends GridPageActions { /** - * Install administrator account + * Show Report button + * + * @var string + */ + protected $showReportButton = '#filter_form_submit'; + + /** + * Show report button click * * @return void */ - public function execute() + public function showReport() { - $this->_checkIfInstalled(); - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - - $this->_view->getLayout()->addBlock('Magento\Install\Block\Admin', 'install.administrator', 'content'); - $this->_view->renderLayout(); + $this->_rootElement->find($this->showReportButton)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php new file mode 100644 index 0000000000000000000000000000000000000000..9f808c067f343c4a33cbf36529d92057d4bec86b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php @@ -0,0 +1,69 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed; + +use Mtf\Block\Form; +use Mtf\ObjectManager; + +/** + * Class Filter + * Filter for Product Views Report + */ +class Filter extends Form +{ + /** + * Search products in report grid + * + * @var array $productsReport + * @return void + */ + public function viewsReport(array $viewsReport) + { + $viewsReport = $this->prepareData($viewsReport); + $data = $this->dataMapping($viewsReport); + $this->_fill($data); + } + + /** + * Prepare data + * + * @param array $viewsReport + * @return array + */ + protected function prepareData(array $viewsReport) + { + foreach ($viewsReport as $name => $reportFilter) { + if ($name === 'period_type' || $name === 'show_empty_rows') { + continue; + } + $date = ObjectManager::getInstance()->create( + '\Magento\Backend\Test\Fixture\Date', + ['params' => [], 'data' => ['pattern' => $reportFilter]] + ); + $viewsReport[$name] = $date->getData(); + } + return $viewsReport; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml similarity index 77% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.xml rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml index 94b0ab23542ab04a29f02890e8a6b46ae9d6d522..0d28736f7b1f15f3ac64697af2e426691df13795 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml @@ -25,12 +25,17 @@ --> <mapping strict="0"> <fields> - <pricing_value> - <selector>[name$='[pricing_value]']</selector> - </pricing_value> - <include> - <selector>[type="checkbox"][name$='[include]']</selector> - <input>checkbox</input> - </include> + <from> + <input>datepicker</input> + </from> + <to> + <input>datepicker</input> + </to> + <period_type> + <input>select</input> + </period_type> + <show_empty_rows> + <input>select</input> + </show_empty_rows> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductGrid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php similarity index 55% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductGrid.php rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php index 6f026ca74a90d86e8bdb9655c138e32db1317c0d..a98e434e52f4f3ed8fbfd1ff9d36b80c6b390800 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductGrid.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php @@ -18,51 +18,48 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @spi * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Block\Backend; +namespace Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed; use Magento\Backend\Test\Block\Widget\Grid; /** * Class ProductGrid - * Backend catalog product grid - * + * Product Views Report */ class ProductGrid extends Grid { /** - * Initialize block elements + * Product in grid locator + * + * @var string + */ + protected $product = './/*[contains(.,"%s") and *[contains(@class,"price") and contains(.,"%d")]]'; + + /** + * Count product views + * + * @var string */ - protected $filters = array( - 'name' => array( - 'selector' => '#productGrid_product_filter_name' - ), - 'sku' => array( - 'selector' => '#productGrid_product_filter_sku' - ), - 'type' => array( - 'selector' => '#productGrid_product_filter_type', - 'input' => 'select' - ), - 'price_from' => array( - 'selector' => '#productGrid_product_filter_price_from' - ), - 'price_to' => array( - 'selector' => '#productGrid_product_filter_price_to' - ) - ); + protected $productView = '/*[contains(@class,"qty")]'; /** - * Update attributes for selected items + * Get views Results from Products Report grid * - * @param array $items + * @param array $products + * @return array */ - public function updateAttributes(array $items = array()) + public function getViewsResults(array $products) { - $this->massaction($items, 'Update Attributes'); + $views = []; + foreach ($products as $product) { + $views[] = $this->_rootElement + ->find(sprintf($this->product . $this->productView, $product->getName(), $product->getPrice())) + ->getText(); + } + return $views; } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Shopcart/Product/Grid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Shopcart/Product/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..408b50fb0cf18ef75bc654157915a0e18d65ba91 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Shopcart/Product/Grid.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Block\Adminhtml\Shopcart\Product; + +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Mtf\Client\Element\Locator; + +/** + * Class Grid + * Products in Carts Report grid + */ +class Grid extends \Magento\Backend\Test\Block\Widget\Grid +{ + /** + * Product row selector + * + * @var string + */ + protected $productRow = '//tr[td[contains(@class,"col-name")] and contains(.,"%s")]'; + + /** + * Product price selector + * + * @var string + */ + protected $productPrice = '//td[contains(@class,"col-price") and contains(.,"%s")]'; + + /** + * Product carts selector + * + * @var string + */ + protected $productCarts = '//td[contains(@class,"col-carts") and contains(.,"%d")]'; + + /** + * Check that product visible in grid + * + * @param CatalogProductSimple $product + * @param string $carts + * @return bool + */ + public function isProductVisible(CatalogProductSimple $product, $carts) + { + $result = false; + $productRowSelector = sprintf($this->productRow, $product->getName()); + $productPrice = sprintf($this->productPrice, $product->getPrice()); + $productRow = $this->_rootElement->find($productRowSelector, Locator::SELECTOR_XPATH); + if ($productRow->isVisible()) { + $result = $productRow->find($productPrice, Locator::SELECTOR_XPATH)->isVisible() + && $productRow->find(sprintf($this->productCarts, $carts), Locator::SELECTOR_XPATH)->isVisible(); + } + + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertNewAccountsReportTotalResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertNewAccountsReportTotalResult.php new file mode 100644 index 0000000000000000000000000000000000000000..15d7e8470461b368d9551b1d8557704260481268 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertNewAccountsReportTotalResult.php @@ -0,0 +1,65 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Constraint; + +use Magento\Reports\Test\Page\Adminhtml\CustomerAccounts; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertNewAccountsReportTotalResult + * Assert that new account total result is equals to data from dataSet + */ +class AssertNewAccountsReportTotalResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that new account total result is equals to data from dataSet + * + * @param CustomerAccounts $customerAccounts + * @param string $total + * @return void + */ + public function processAssert(CustomerAccounts $customerAccounts, $total) + { + $totalForm = $customerAccounts->getGridBlock()->getTotalResults(); + \PHPUnit_Framework_Assert::assertEquals($totalForm, $total); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'New account total result is equals to data from dataSet.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductInCartResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductInCartResult.php new file mode 100644 index 0000000000000000000000000000000000000000..48f94e5bd9da4fec36f71af5f5722e189c73657f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductInCartResult.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Reports\Test\Page\Adminhtml\ShopCartProductReport; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; + +/** + * Class AssertProductInCartResult + * Assert that product is present in Products in Carts report grid + */ +class AssertProductInCartResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that product is present in Products in Carts report grid by name, price, carts + * + * @param ShopCartProductReport $shopCartProductReport + * @param CatalogProductSimple $product + * @param string $carts + * @return void + */ + public function processAssert(ShopCartProductReport $shopCartProductReport, CatalogProductSimple $product, $carts) + { + $shopCartProductReport->open(); + \PHPUnit_Framework_Assert::assertTrue( + $shopCartProductReport->getGridBlock()->isProductVisible($product, $carts), + 'Product is absent in Products in Carts report grid.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Product is present in Products in Carts report grid with correct carts number.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductViewsReportTotalResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductViewsReportTotalResult.php new file mode 100644 index 0000000000000000000000000000000000000000..3375ac30ed139d8085c94c45227bf2ba68e0b4f7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductViewsReportTotalResult.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Constraint; + +use Magento\Reports\Test\Page\Adminhtml\ProductReportView; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertProductViewsReportTotalResult + * Assert product info in report: product name, price and views + */ +class AssertProductViewsReportTotalResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert product info in report: product name, price and views + * + * @param ProductReportView $productReportView + * @param string $total + * @param array $productsList + * @return void + */ + public function processAssert(ProductReportView $productReportView, $total, array $productsList) + { + $total = explode(', ', $total); + $totalForm = $productReportView->getGridBlock()->getViewsResults($productsList); + \PHPUnit_Framework_Assert::assertEquals($totalForm, $total); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Products view total result is equals to data from dataSet.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/CustomerAccounts.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/CustomerAccounts.xml new file mode 100644 index 0000000000000000000000000000000000000000..b259f8c77e1e60a71275a9696808cb1e755c95d3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/CustomerAccounts.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="reports/report_customer/accounts/index" module="Magento_Reports"> + <blocks> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Customer\AccountsGrid</class> + <locator>#gridAccounts</locator> + <strategy>css selector</strategy> + </gridBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml new file mode 100644 index 0000000000000000000000000000000000000000..32c82d39a3a778cbc370c92ad52ea27909b4b15e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="reports/report_product/viewed/" module="Magento_Reports"> + <blocks> + <actionsBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\Action</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </actionsBlock> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\ProductGrid</class> + <locator>.grid</locator> + <strategy>css selector</strategy> + </gridBlock> + <filterBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\Filter</class> + <locator>#filter_form</locator> + <strategy>css selector</strategy> + </filterBlock> + <messagesBlock> + <class>Magento\Core\Test\Block\Messages</class> + <locator>#messages .messages</locator> + <strategy>css selector</strategy> + </messagesBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ShopCartProductReport.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ShopCartProductReport.xml new file mode 100644 index 0000000000000000000000000000000000000000..6de291e9561df03499417ff207f4e2fac5272a17 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ShopCartProductReport.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="reports/report_shopcart/product" module="Magento_Reports"> + <blocks> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Shopcart\Product\Grid</class> + <locator>#gridProducts</locator> + <strategy>css selector</strategy> + </gridBlock> + </blocks> +</page> + diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1c80e538e06f6e82f5e810598d1f18b8e837c33a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Reports\Test\Page\Adminhtml\CustomerAccounts; + +/** + * Test Creation for NewAccountsReportEntity + * + * Test Flow: + * Preconditions: + * 1. Delete all existing customers + * 2. Create customer + * + * Steps: + * 1. Open Backend + * 2. Go to Reports> Customers> New + * 3. Select time range and report period + * 4. Click "Refresh button" + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-27742 + */ +class NewAccountsReportEntityTest extends Injectable +{ + /** + * Customer Accounts pages + * + * @var CustomerAccounts + */ + protected $customerAccounts; + + /** + * Customer index pages + * + * @var CustomerIndex + */ + protected $customerIndexPage; + + /** + * Inject pages + * + * @param CustomerIndex $customerIndexPage + * @param CustomerAccounts $customerAccounts + * @return void + */ + public function __inject(CustomerIndex $customerIndexPage, CustomerAccounts $customerAccounts) + { + $this->customerAccounts = $customerAccounts; + $this->customerIndexPage = $customerIndexPage; + } + + /** + * New Accounts Report + * + * @param CustomerInjectable $customer + * @param array $customersReport + * @return void + */ + public function test(CustomerInjectable $customer, array $customersReport) + { + // Preconditions + $this->customerIndexPage->open(); + $this->customerIndexPage->getCustomerGridBlock()->massaction([], 'Delete', true, 'Select All'); + $customer->persist(); + + // Steps + $this->customerAccounts->open(); + $this->customerAccounts->getGridBlock()->searchAccounts($customersReport); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..c8b4dda5f1132407ace58d4ad3cacab4afa2c9dc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest/test.csv @@ -0,0 +1,5 @@ +"customer/dataSet";"total";"customersReport/report_from";"customersReport/report_to";"customersReport/report_period";"constraint" +"default";"1";"m/d/Y";"m/d/Y";"Year";"assertNewAccountsReportTotalResult" +"default";"1";"m/d/Y";"m/d/Y";"Month";"assertNewAccountsReportTotalResult" +"default";"1";"m/d/Y";"m/d/Y";"Day";"assertNewAccountsReportTotalResult" +"default";"0";"m/d/Y 12:00 a+1 day";"m/d/Y 12:00 a+1 day";"Day";"assertNewAccountsReportTotalResult" diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity.php new file mode 100644 index 0000000000000000000000000000000000000000..a9e5af3ed664cf29404990c5c66381c720f5478a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity.php @@ -0,0 +1,159 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Mtf\Client\Browser; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Customer\Test\Page\CustomerAccountLogout; +use Magento\Cms\Test\Page\CmsIndex; + +/** + * Test Creation for ProductsInCartReportEntity + * + * Test Flow: + * + * Preconditions: + * 1. Create customer + * 2. Create product + * + * Steps: + * 1. Login as customer in frontend + * 2. Add product to cart + * 3. Logout + * 4. Add product to cart as unregistered customer + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-27952 + */ +class ProductsInCartReportEntity extends Injectable +{ + /** + * Cms index page + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Customer login page + * + * @var CustomerAccountLogin + */ + protected $customerAccountLogin; + + /** + * Product view page + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Customer logout page + * + * @var CustomerAccountLogout + */ + protected $customerAccountLogout; + + /** + * Prepare data + * + * @param CustomerInjectable $customer + * @return array + */ + public function __prepare(CustomerInjectable $customer) + { + $customer->persist(); + + return ['customer' => $customer]; + } + + /** + * Injection data + * + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CustomerAccountLogout $customerAccountLogout + * @param CatalogProductView $catalogProductView + * @return void + */ + public function __inject( + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CustomerAccountLogout $customerAccountLogout, + CatalogProductView $catalogProductView + ) { + $this->cmsIndex = $cmsIndex; + $this->customerAccountLogin = $customerAccountLogin; + $this->customerAccountLogout = $customerAccountLogout; + $this->catalogProductView = $catalogProductView; + } + + /** + * Create products in cart report entity + * + * @param CustomerInjectable $customer + * @param CatalogProductSimple $product + * @param string $isGuest + * @param Browser $browser + * @return void + */ + public function test( + CustomerInjectable $customer, + CatalogProductSimple $product, + $isGuest, + Browser $browser + ) { + // Preconditions + $product->persist(); + + //Steps + $this->cmsIndex->open()->getLinksBlock()->openLink("Log In"); + $this->customerAccountLogin->getLoginBlock()->login($customer); + $productUrl = $_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'; + $browser->open($productUrl); + $this->catalogProductView->getViewBlock()->addToCart($product); + if ($isGuest) { + $this->customerAccountLogout->open(); + $browser->open($productUrl); + $this->catalogProductView->getViewBlock()->addToCart($product); + } + } + + /** + * Log out after test + * + * @return void + */ + public function tearDown() + { + $this->customerAccountLogout->open(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..d2461670586d59f98982c1b89a58e359e17f3e38 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity/test.csv @@ -0,0 +1,3 @@ +"product/dataSet";"carts";"isGuest";"constraint" +"default";"1";"0";"assertProductInCartResult" +"default";"2";"1";"assertProductInCartResult" \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..68f07881e4ff18c686c15b74afef8b1cffb7228b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php @@ -0,0 +1,150 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\TestCase; + +use Mtf\Client\Browser; +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Reports\Test\Page\Adminhtml\ProductReportView; + +/** + * Test Creation for ViewedProductsReportEntity + * + * Test Flow: + * Preconditions: + * 1. Create products + * 2. Open product page on frontend + * 3. Refresh statistic + * + * Steps: + * 1. Open Backend + * 2. Go to Reports> Products> Views + * 3. Select time range, report period + * 4. Click "Show report" + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-27954 + */ +class ViewedProductsReportEntityTest extends Injectable +{ + /** + * Product Report View page + * + * @var ProductReportView + */ + protected $productReportView; + + /** + * Fixture factory + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Browser interface + * + * @var Browser + */ + protected $browser; + + /** + * Inject pages + * + * @param ProductReportView $productReportView + * @param FixtureFactory $fixtureFactory + * @param Browser $browser + * @return void + */ + public function __inject( + ProductReportView $productReportView, + FixtureFactory $fixtureFactory, + Browser $browser + ) { + $this->productReportView = $productReportView; + $this->fixtureFactory = $fixtureFactory; + $this->browser = $browser; + } + + /** + * Viewed product report list + * + * @param string $products + * @param array $viewsReport + * @param string $total + * @return array + */ + public function test($products, array $viewsReport, $total) + { + $this->markTestIncomplete('MAGETWO-15707'); + // Preconditions + $productsList = $this->prepareProducts($products); + $this->openProducts($productsList, $total); + $this->productReportView->open(); + $this->productReportView->getMessagesBlock()->clickLinkInMessages('notice', 'here'); + + // Steps + $this->productReportView->getFilterBlock()->viewsReport($viewsReport); + $this->productReportView->getActionsBlock()->showReport(); + return ['productsList' => $productsList]; + } + + /** + * Create products + * + * @param string $productList + * @return array + */ + protected function prepareProducts($productList) + { + $productsData = explode(', ', $productList); + $products = []; + foreach ($productsData as $productConfig) { + $product = explode('::', $productConfig); + $productFixture = $this->fixtureFactory->createByCode($product[0], ['dataSet' => $product[1]]); + $productFixture->persist(); + $products[] = $productFixture; + } + return $products; + } + + /** + * Open products + * + * @param array $products + * @param string $total + * @return void + */ + protected function openProducts(array $products, $total) + { + $total = explode(', ', $total); + foreach ($products as $key => $product) { + for ($i = 0; $i < $total[$key]; $i++) { + $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + } + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..430790d9c7851e56a4076aa79aec83ae9128e9fa --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest/test.csv @@ -0,0 +1,4 @@ +"description";"total";"products";"viewsReport/period_type";"viewsReport/from";"viewsReport/to";"viewsReport/show_empty_rows";"constraint" +"view products on front and verify they all reflected in Year report";"2, 1";"catalogProductSimple::default, catalogProductVirtual::default";"Year";"m/d/Y -1 year";"m/d/Y";"No";"assertProductViewsReportTotalResult" +"view products on front and verify they all reflected in Month report";"1, 1";"catalogProductDownloadable::default, catalogProductBundle::bundle_dynamic_product";"Month";"m/d/Y";"m/d/Y";"No";"assertProductViewsReportTotalResult" +"view products on front and verify they all reflected in Day report";"1, 1";"catalogProductConfigurable::default, catalogProductGrouped::default";"Day";"m/d/Y -1 day";"m/d/Y +1 day";"Yes";"assertProductViewsReportTotalResult" diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml index 738295b83c772a2bec9a5afd485afdba5fc95f6c..6fd3f3d703ac7b67844c8bf970e3e7c4b9261f31 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml @@ -39,6 +39,9 @@ <assertProductReviewIsAvailableForProduct module="Magento_Reports"> <severeness>low</severeness> </assertProductReviewIsAvailableForProduct> + <assertNewAccountsReportTotalResult module="Magento_Reports"> + <severeness>low</severeness> + </assertNewAccountsReportTotalResult> <assertProductReviewsQtyByCustomer module="Magento_Reports"> <severeness>low</severeness> </assertProductReviewsQtyByCustomer> @@ -48,4 +51,10 @@ <assertProductReportByCustomerNotInGrid module="Magento_Reports"> <severeness>low</severeness> </assertProductReportByCustomerNotInGrid> + <assertProductViewsReportTotalResult module="Magento_Reports"> + <severeness>low</severeness> + </assertProductViewsReportTotalResult> + <assertProductInCartResult module="Magento_Reports"> + <severeness>low</severeness> + </assertProductInCartResult> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml index 106bba5c02c4f1bf3965198d88105873cff87392..f486dc564505f186ed84f6aa3145677f508c7b07 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml @@ -39,9 +39,24 @@ <area>adminhtml</area> <class>Magento\Reports\Test\Page\Adminhtml\ProductReportReview</class> </productReportReview> + <customerAccounts> + <mca>reports/report_customer/accounts/index</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\CustomerAccounts</class> + </customerAccounts> <customerReportReview> <mca>reports/report_review/customer</mca> <area>adminhtml</area> <class>Magento\Reports\Test\Page\Adminhtml\CustomerReportReview</class> </customerReportReview> + <productReportView> + <mca>reports/report_product/viewed/</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\ProductReportView</class> + </productReportView> + <shopCartProductReport> + <mca>reports/report_shopcart/product</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\ShopCartProductReport</class> + </shopCartProductReport> </page> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php new file mode 100644 index 0000000000000000000000000000000000000000..ce2372c7c6154c25e21763fd88e15cfc792fb828 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php @@ -0,0 +1,36 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Review\Test\Block\Adminhtml\Customer\Edit\Tab; + +use Magento\Review\Test\Block\Adminhtml\ReviewsTab; + +/** + * Class Reviews + * Reviews tab on customer edit page + */ +class Reviews extends ReviewsTab +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml new file mode 100644 index 0000000000000000000000000000000000000000..23020202fb85763016c3a6f563a18e505ca574a5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<tabs> + <product_reviews> + <class>\Magento\Review\Test\Block\Adminhtml\Customer\Edit\Tab\Reviews</class> + <selector>#customer_info_tabs_reviews</selector> + <strategy>css selector</strategy> + </product_reviews> +</tabs> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Grid.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Grid.php index f295e2c0c8b1086378581f705985f1db5b27e941..4b2965cfdd666bf7ea2b5fc7721b97648f6ea68c 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Grid.php @@ -24,7 +24,6 @@ namespace Magento\Review\Test\Block\Adminhtml; -use Mtf\Client\Element; use Magento\Backend\Test\Block\Widget\Grid as GridAbstract; /** @@ -46,7 +45,7 @@ class Grid extends GridAbstract 'selector' => 'input[name="title"]', ], 'status' => [ - 'selector' => '.grid select[name="status"]', + 'selector' => '#reviwGrid_filter_status', 'input' => 'select', ], 'nickname' => [ diff --git a/app/code/Magento/Webapi/DeserializationException.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php similarity index 81% rename from app/code/Magento/Webapi/DeserializationException.php rename to dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php index f9e4db42d4b4669cea0be01e43cb7ed932a41edf..037dff88e52c10c9d07bdeda45240b8fb153613f 100644 --- a/app/code/Magento/Webapi/DeserializationException.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php @@ -22,12 +22,15 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Webapi; +namespace Magento\Review\Test\Block\Adminhtml\Product\Edit\Tab; + +use Magento\Review\Test\Block\Adminhtml\ReviewsTab; /** - * Exception to be thrown when there is an issue with deserialization of web API request. + * Class Reviews + * Reviews tab on product edit page */ -class DeserializationException extends \Magento\Framework\Exception\LocalizedException +class Reviews extends ReviewsTab { - + // } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml new file mode 100644 index 0000000000000000000000000000000000000000..c9866c8ffdb815e72e73a4b7ad859906a9d22b24 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<tabs> + <product_reviews> + <class>\Magento\Review\Test\Block\Adminhtml\Product\Edit\Tab\Reviews</class> + <selector>#product_info_tabs_product-reviews</selector> + <strategy>css selector</strategy> + </product_reviews> +</tabs> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php new file mode 100644 index 0000000000000000000000000000000000000000..f81428b1c5b465c919ee85b5b3894cf55bbd0615 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php @@ -0,0 +1,54 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Review\Test\Block\Adminhtml; + +use Magento\Backend\Test\Block\Widget\Tab; + +/** + * Class Reviews + * Reviews tab on backend + */ +class ReviewsTab extends Tab +{ + /** + * Product reviews block selector + * + * @var string + */ + protected $reviews = '#Product_Reviews'; + + /** + * Returns product reviews grid + * + * @return \Magento\Review\Test\Block\Adminhtml\Grid + */ + public function getReviewsGrid() + { + return $this->blockFactory->create( + 'Magento\Review\Test\Block\Adminhtml\Grid', + ['element' => $this->_rootElement->find($this->reviews)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingInProductPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingInProductPage.php index eaacf1b4c1f9ef127c09b49f2d1d86845213d46e..5d21b495e74a091b18a6551b3b5c1bc595362339 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingInProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingInProductPage.php @@ -48,20 +48,19 @@ class AssertProductRatingInProductPage extends AbstractConstraint * Assert that product rating is displayed on product review(frontend) * * @param CatalogProductView $catalogProductView - * @param CatalogProductSimple $product * @param Browser $browser + * @param CatalogProductSimple $product * @param ReviewInjectable|null $review [optional] * @param Rating|null $productRating [optional] * @return void */ public function processAssert( CatalogProductView $catalogProductView, - CatalogProductSimple $product, Browser $browser, + CatalogProductSimple $product, ReviewInjectable $review = null, Rating $productRating = null ) { - $product = $review === null ? $product : $review->getDataFieldConfig('entity_id')['source']->getEntity(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $reviewSummaryBlock = $catalogProductView->getReviewSummary(); if ($reviewSummaryBlock->isVisible()) { diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingNotInProductPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingNotInProductPage.php index 95bdafbd232b57c145f1c96bfc00211ddefcb166..c43da69ab5d75f7e6fb3ec33c74719ec84da5481 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingNotInProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingNotInProductPage.php @@ -27,7 +27,6 @@ namespace Magento\Review\Test\Constraint; use Mtf\Client\Browser; use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Catalog\Test\Fixture\CatalogProductSimple; -use Magento\Review\Test\Fixture\ReviewInjectable; use Magento\Review\Test\Fixture\Rating; use Mtf\Constraint\AbstractConstraint; @@ -50,17 +49,14 @@ class AssertProductRatingNotInProductPage extends AbstractConstraint * @param CatalogProductSimple $product * @param Rating $productRating * @param Browser $browser - * @param ReviewInjectable $review * @return void */ public function processAssert( CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating, - Browser $browser, - ReviewInjectable $review = null + Browser $browser ) { - $product = $review === null ? $product : $review->getDataFieldConfig('entity_id')['source']->getEntity(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getReviewSummary()->getAddReviewLink()->click(); diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php index ec615729f011e5d33dd1d77c1ed11cddf2d7c19c..14f2a1ebdc84bcc56581f965907623c6239c7810 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php @@ -63,21 +63,18 @@ class AssertProductReviewInGrid extends AbstractConstraint * Assert that review is displayed in grid * * @param ReviewIndex $reviewIndex - * @param ReviewInjectable $review + * @param ReviewInjectable $review , + * @param FixtureInterface $product * @param string $gridStatus - * @param ReviewInjectable $reviewInitial * @return void */ public function processAssert( ReviewIndex $reviewIndex, ReviewInjectable $review, - $gridStatus = '', - ReviewInjectable $reviewInitial = null + FixtureInterface $product, + $gridStatus = '' ) { - $product = $reviewInitial === null - ? $review->getDataFieldConfig('entity_id')['source']->getEntity() - : $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); - $filter = $this->prepareFilter($product, $review, $gridStatus); + $filter = $this->prepareFilter($product, $review->getData(), $gridStatus); $reviewIndex->open(); $reviewIndex->getReviewGrid()->search($filter); @@ -92,11 +89,13 @@ class AssertProductReviewInGrid extends AbstractConstraint * Prepare filter for assert * * @param FixtureInterface $product - * @param ReviewInjectable $review - * @param string $gridStatus + * @param array $review + * @param string $gridStatus [optional] * @return array + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function prepareFilter(FixtureInterface $product, ReviewInjectable $review, $gridStatus) + public function prepareFilter(FixtureInterface $product, array $review, $gridStatus = '') { $filter = []; foreach ($this->filter as $key => $item) { @@ -110,13 +109,13 @@ class AssertProductReviewInGrid extends AbstractConstraint $value = $product->getData($param); break; case 'select_stores': - $value = $review->getData($param)[0]; + $value = isset($review[$param]) ? $review[$param][0] : null; break; case 'status_id': - $value = $gridStatus != '' ? $gridStatus : $review->getData($param); + $value = $gridStatus != '' ? $gridStatus : (isset($review[$param]) ? $review[$param] : null); break; default: - $value = $review->getData($param); + $value = isset($review[$param]) ? $review[$param] : null; break; } if ($value !== null) { diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGridOnCustomerPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGridOnCustomerPage.php new file mode 100644 index 0000000000000000000000000000000000000000..13af1eae39694ed7a4d63ae9448eba9be968c7c7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGridOnCustomerPage.php @@ -0,0 +1,111 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Review\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; +use Magento\Review\Test\Block\Adminhtml\Product\Grid as ReviewsGrid; + +/** + * Class AssertProductReviewInGridOnCustomerPage + * Asserts all Product Review variables in the reviews grid on customer page + */ +class AssertProductReviewInGridOnCustomerPage extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Asserts all Product Review variables in the reviews grid on customer page + * + * @param CustomerInjectable $customer + * @param ReviewInjectable $reviewInitial + * @param ReviewInjectable $review + * @param CustomerIndexEdit $customerIndexEdit + * @param CustomerIndex $customerIndex + * @param AssertProductReviewInGrid $assertProductReviewInGrid + * @return void + */ + public function processAssert( + CustomerInjectable $customer, + ReviewInjectable $reviewInitial, + ReviewInjectable $review, + CustomerIndexEdit $customerIndexEdit, + CustomerIndex $customerIndex, + AssertProductReviewInGrid $assertProductReviewInGrid + ) { + /** var CatalogProductSimple $product */ + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $customerIndex->open(); + $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $customerIndexEdit->getCustomerForm()->openTab('product_reviews'); + $filter = $assertProductReviewInGrid->prepareFilter($product, $this->prepareData($review, $reviewInitial)); + /** @var ReviewsGrid $reviewsGrid */ + $reviewsGrid = $customerIndexEdit->getCustomerForm()->getTabElement('product_reviews')->getReviewsGrid(); + $reviewsGrid->search($filter); + unset($filter['visible_in']); + \PHPUnit_Framework_Assert::assertTrue( + $reviewsGrid->isRowVisible($filter, false), + 'Review is absent in Review grid on customer page.' + ); + } + + /** + * Prepare Review data + * + * @param ReviewInjectable $review + * @param ReviewInjectable $reviewInitial + * @return array + */ + protected function prepareData(ReviewInjectable $review, ReviewInjectable $reviewInitial) + { + $dataReviewInitial = $reviewInitial->getData(); + $data = $review->getData(); + foreach ($dataReviewInitial as $key => $value) { + if (!isset($data[$key])) { + $data[$key] = $value; + } + } + $data['type'] = 'Customer'; + return $data; + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Review is present in grid on customer page.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php index 61910be58d65db4bf73e99dd838ae71b85ab66d2..5a8ffcaedee0f9333eea7fd44cff8b645f14dab9 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php @@ -25,8 +25,10 @@ namespace Magento\Review\Test\Constraint; use Mtf\Client\Browser; +use Mtf\Fixture\FixtureInterface; use Mtf\Constraint\AbstractConstraint; use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Backend\Test\Page\Adminhtml\AdminCache; use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\Catalog\Test\Page\Product\CatalogProductView; @@ -48,19 +50,20 @@ class AssertProductReviewOnProductPage extends AbstractConstraint * * @param CatalogProductView $catalogProductView * @param ReviewInjectable $review - * @param ReviewInjectable $reviewInitial + * @param FixtureInterface $product * @param Browser $browser + * @param AdminCache $cachePage * @return void */ public function processAssert( CatalogProductView $catalogProductView, ReviewInjectable $review, - ReviewInjectable $reviewInitial, - Browser $browser + FixtureInterface $product, + Browser $browser, + AdminCache $cachePage ) { $errors = []; - /** @var CatalogProductSimple $product */ - $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $cachePage->open()->getActionsBlock()->flushMagentoCache(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $reviewBlock = $catalogProductView->getCustomerReviewBlock(); diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Fixture/ReviewInjectable/Ratings.php b/dev/tests/functional/tests/app/Magento/Review/Test/Fixture/ReviewInjectable/Ratings.php index cfd0a5f385ac393fd64434adbfcfa117af771534..f1b7bd570764c37ec49c36955dd5c9d6aa727f89 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Fixture/ReviewInjectable/Ratings.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Fixture/ReviewInjectable/Ratings.php @@ -64,16 +64,21 @@ class Ratings implements FixtureInterface public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) { $this->params = $params; + /** @var Rating $fixtureRating */ + $fixtureRating = null; foreach ($data as $rating) { if (isset($rating['dataSet'])) { - /** @var Rating $fixtureRating */ $fixtureRating = $fixtureFactory->createByCode('rating', ['dataSet' => $rating['dataSet']]); - if (!$fixtureRating->hasData('id')) { + if (!$fixtureRating->hasData('rating_id')) { $fixtureRating->persist(); } - $this->ratings[] = $fixtureRating; + } elseif (isset($rating['fixtureRating'])) { + $fixtureRating = $rating['fixtureRating']; + } + if ($fixtureRating !== null) { + $this->ratings[] = $fixtureRating; $this->data[] = [ 'title' => $fixtureRating->getRatingCode(), 'rating' => $rating['rating'] diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php index 413bf728aba60efb9116addfc60fd467312e194a..d34bc2ae6041248e699c1f6cef2ae5e5ac638397 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php @@ -129,6 +129,9 @@ class CreateProductRatingEntityTest extends Injectable */ public function tearDown() { + if (!($this->productRating instanceof Rating)) { + return; + } $filter = ['rating_code' => $this->productRating->getRatingCode()]; $this->ratingIndex->open(); $this->ratingIndex->getRatingGrid()->searchAndOpen($filter); diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php index faa53940c7422039ea09afdcd72b6549c390e7a5..18cd55a0a6d9d883037aa8838a8cce7f52ceb513 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php @@ -119,12 +119,13 @@ class CreateProductReviewBackendEntityTest extends Injectable * Run Create Product Review Entity Backend Test * * @param ReviewInjectable $review - * @return void + * @return array */ public function test(ReviewInjectable $review) { // Precondition: - $filter = ['id' => $review->getDataFieldConfig('entity_id')['source']->getEntity()->getId()]; + $product = $review->getDataFieldConfig('entity_id')['source']->getEntity(); + $filter = ['id' => $product->getId()]; $this->review = $review; // Steps: @@ -133,6 +134,8 @@ class CreateProductReviewBackendEntityTest extends Injectable $this->reviewEdit->getProductGrid()->searchAndOpen($filter); $this->reviewEdit->getReviewForm()->fill($this->review); $this->reviewEdit->getPageActions()->save(); + + return ['product' => $product]; } /** @@ -143,12 +146,11 @@ class CreateProductReviewBackendEntityTest extends Injectable public function tearDown() { $this->ratingIndex->open(); - $ratingGrid = $this->ratingIndex->getRatingGrid(); - $pageActions = $this->ratingEdit->getPageActions(); - foreach ($this->review->getRatings() as $rating) { - $filter = ['rating_code' => $rating['title']]; - $ratingGrid->searchAndOpen($filter); - $pageActions->delete(); + if ($this->review instanceof ReviewInjectable) { + foreach ($this->review->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php index 96fbb068a922341ddd40486756e1ac7cbe55f3aa..2f214ff54d88bb0caa4f869b1d26634427caf843 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php @@ -104,7 +104,7 @@ class CreateProductReviewFrontendEntityTest extends Injectable * * @param ReviewInjectable $review * @param Browser $browser - * @return void + * @return array */ public function test(ReviewInjectable $review, Browser $browser) { @@ -121,6 +121,8 @@ class CreateProductReviewFrontendEntityTest extends Injectable $reviewForm = $this->catalogProductView->getReviewFormBlock(); $reviewForm->fill($review); $reviewForm->submit(); + + return ['product' => $product]; } /** @@ -131,12 +133,11 @@ class CreateProductReviewFrontendEntityTest extends Injectable public function tearDown() { $this->ratingIndex->open(); - $ratingGrid = $this->ratingIndex->getRatingGrid(); - $pageActions = $this->ratingEdit->getPageActions(); - foreach ($this->review->getRatings() as $rating) { - $filter = ['rating_code' => $rating['title']]; - $ratingGrid->searchAndOpen($filter); - $pageActions->delete(); + if ($this->review instanceof ReviewInjectable) { + foreach ($this->review->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9c72dad9e7e738c86d2e9fdcccbeb4a9772b41e7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php @@ -0,0 +1,254 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Review\Test\TestCase; + +use Mtf\Client\Browser; +use Mtf\TestCase\Injectable; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Review\Test\Page\Adminhtml\ReviewEdit; +use Magento\Review\Test\Page\Adminhtml\RatingEdit; +use Magento\Review\Test\Page\Adminhtml\RatingIndex; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; + +/** + * Test Creation for ManageProductReviewFromCustomerPage + * + * Test Flow: + * + * Preconditions: + * 1. Create Customer + * 2. Create simple product + * 3. Create Product review on the front + * + * Steps: + * 1. Open backend + * 2. Go to Customers->All Customers + * 3. Open customer from preconditions + * 4. Open Product Review tab + * 5. Open Review created in preconditions + * 6. Fill data according to dataset + * 7. Click "Submit review" + * 8. Perform all assertions + * + * @group Reviews_and_Ratings_(MX) + * @ZephyrId MAGETWO-27625 + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ManageProductReviewFromCustomerPageTest extends Injectable +{ + /** + * Customer index page + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customer edit page + * + * @var CustomerIndexEdit + */ + protected $customerIndexEdit; + + /** + * Customer login page + * + * @var CustomerAccountLogin + */ + protected $customerAccountLogin; + + /** + * Catalog product view page + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Browser + * + * @var Browser + */ + protected $browser; + + /** + * Cms index page + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Backend rating grid page + * + * @var RatingIndex + */ + protected $ratingIndex; + + /** + * Backend rating edit page + * + * @var RatingEdit + */ + protected $ratingEdit; + + /** + * Review fixture + * + * @var ReviewInjectable + */ + protected $reviewInitial; + + /** + * Review edit page + * + * @var ReviewEdit + */ + protected $reviewEdit; + + /** + * Prepare data + * + * @param CustomerInjectable $customer + * @return array + */ + public function __prepare(CustomerInjectable $customer) + { + $customer->persist(); + return ['customer' => $customer]; + } + + /** + * Injection data + * + * @param CustomerIndexEdit $customerIndexEdit + * @param CustomerIndex $customerIndex + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CatalogProductView $catalogProductView + * @param Browser $browser + * @param RatingIndex $ratingIndex + * @param RatingEdit $ratingEdit + * @param ReviewEdit $reviewEdit + * @return void + */ + public function __inject( + CustomerIndexEdit $customerIndexEdit, + CustomerIndex $customerIndex, + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CatalogProductView $catalogProductView, + Browser $browser, + RatingIndex $ratingIndex, + RatingEdit $ratingEdit, + ReviewEdit $reviewEdit + ) { + $this->customerIndexEdit = $customerIndexEdit; + $this->customerIndex = $customerIndex; + $this->cmsIndex = $cmsIndex; + $this->customerAccountLogin = $customerAccountLogin; + $this->catalogProductView = $catalogProductView; + $this->browser = $browser; + $this->ratingIndex = $ratingIndex; + $this->ratingEdit = $ratingEdit; + $this->reviewEdit = $reviewEdit; + } + + /** + * Run manage product review test + * + * @param ReviewInjectable $reviewInitial + * @param ReviewInjectable $review + * @param CustomerInjectable $customer + * @return array + */ + public function test( + ReviewInjectable $reviewInitial, + ReviewInjectable $review, + CustomerInjectable $customer + ) { + // Preconditions + $this->login($customer); + /** @var CatalogProductSimple $product */ + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + $this->catalogProductView->getReviewSummary()->getAddReviewLink()->click(); + $this->catalogProductView->getReviewFormBlock()->fill($reviewInitial); + $this->catalogProductView->getReviewFormBlock()->submit(); + $this->reviewInitial = $reviewInitial; + // Steps + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $this->customerIndexEdit->getCustomerForm()->openTab('product_reviews'); + $filter = [ + 'title' => $reviewInitial->getTitle(), + 'sku' => $product->getSku() + ]; + $this->customerIndexEdit->getCustomerForm()->getTabElement('product_reviews')->getReviewsGrid() + ->searchAndOpen($filter); + $this->reviewEdit->getReviewForm()->fill($review); + $this->reviewEdit->getPageActions()->save(); + + return ['reviewInitial' => $reviewInitial, 'product' => $product]; + } + + /** + * Login customer on frontend + * + * @param CustomerInjectable $customer + * @return void + */ + protected function login(CustomerInjectable $customer) + { + $this->cmsIndex->open(); + if (!$this->cmsIndex->getLinksBlock()->isLinkVisible('Log Out')) { + $this->cmsIndex->getLinksBlock()->openLink("Log In"); + $this->customerAccountLogin->getLoginBlock()->login($customer); + } + } + + /** + * Clear data after test + * + * @return void + */ + public function tearDown() + { + $this->ratingIndex->open(); + if ($this->reviewInitial instanceof ReviewInjectable) { + foreach ($this->reviewInitial->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest/test.csv b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..ef0f249f45bf59686b037f6467d6ce708091008f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest/test.csv @@ -0,0 +1,3 @@ +"review/data/status_id";"review/data/nickname";"review/data/title";"review/data/detail";"constraint" +"Approved";"name_upd_%isolation%";"title_upd_%isolation%";"review_upd_%isolation%";"assertReviewSuccessSaveMessage, assertProductReviewInGridOnCustomerPage, assertProductReviewOnProductPage" +"Not Approved";"name_upd_%isolation%";"title_upd_%isolation%";"review_upd_%isolation%";"assertReviewSuccessSaveMessage, assertProductReviewInGridOnCustomerPage, assertProductRatingNotInProductPage" diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php index 385c9e70b9af91afee2fafc359d2aade1380f3f3..3629490c1e57f962b268cd97138eed4d11a4f4b9 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php @@ -102,8 +102,9 @@ class MassActionsProductReviewEntityTest extends Injectable $this->ratingEdit = $ratingEdit; $this->review = $review; $this->review->persist(); + $product = $review->getDataFieldConfig('entity_id')['source']->getEntity(); - return ['review' => $this->review]; + return ['review' => $this->review, 'product' => $product]; } /** @@ -132,11 +133,11 @@ class MassActionsProductReviewEntityTest extends Injectable public function tearDown() { $this->ratingIndex->open(); - $ratingGrid = $this->ratingIndex->getRatingGrid(); - $pageActions = $this->ratingEdit->getPageActions(); - foreach ($this->review->getRatings() as $rating) { - $ratingGrid->searchAndOpen(['rating_code' => $rating['title']]); - $pageActions->delete(); + if ($this->review instanceof ReviewInjectable) { + foreach ($this->review->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php index 59a11b666bf3749e67cd4b395ebab560f80d6cdd..5eeebb4c41bc5a517908b931af4c9a7ddfe5ae44 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php @@ -83,7 +83,7 @@ class ModerateProductReviewEntityTest extends Injectable * * @param ReviewInjectable $reviewInitial * @param ReviewInjectable $review - * @return void + * @return array */ public function test(ReviewInjectable $reviewInitial, ReviewInjectable $review) { @@ -95,5 +95,10 @@ class ModerateProductReviewEntityTest extends Injectable $this->reviewIndex->getReviewGrid()->searchAndOpen(['review_id' => $reviewInitial->getReviewId()]); $this->reviewEdit->getReviewForm()->fill($review); $this->reviewEdit->getPageActions()->save(); + + // Prepare data for asserts + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + + return ['product' => $product]; } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8306fbd1a5ba6e031c978a2e02e2d313fa7ef66f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php @@ -0,0 +1,211 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Review\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Review\Test\Page\Adminhtml\ReviewEdit; +use Magento\Review\Test\Page\Adminhtml\RatingEdit; +use Magento\Review\Test\Page\Adminhtml\RatingIndex; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; + +/** + * Test Creation for UpdateProductReviewEntity on product page + * + * Test Flow: + * + * Preconditions: + * 1. Create Product + * 2. Create review with rating for this product + * + * Steps: + * 1. Open Products -> Catalog + * 2. Search and open product from preconditions + * 3. Open Review tab + * 4. Search and open review created in preconditions + * 5. Fill data according to dataSet + * 6. Save changes + * 7. Perform all assertions + * + * @group Reviews_and_Ratings_(MX) + * @ZephyrId MAGETWO-27743 + */ +class UpdateProductReviewEntityOnProductPageTest extends Injectable +{ + /** + * Catalog product index page + * + * @var CatalogProductIndex + */ + protected $catalogProductIndex; + + /** + * Catalog product edit page + * + * @var CatalogProductEdit + */ + protected $catalogProductEdit; + + /** + * Backend rating grid page + * + * @var RatingIndex + */ + protected $ratingIndex; + + /** + * Backend rating edit page + * + * @var RatingEdit + */ + protected $ratingEdit; + + /** + * Review fixture + * + * @var ReviewInjectable + */ + protected $reviewInitial; + + /** + * Review edit page + * + * @var ReviewEdit + */ + protected $reviewEdit; + + /** + * Fixture factory + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Prepare data + * + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $this->reviewInitial = $fixtureFactory->createByCode( + 'reviewInjectable', + ['dataSet' => 'review_for_simple_product_with_rating'] + ); + $this->reviewInitial->persist(); + $this->fixtureFactory = $fixtureFactory; + } + + /** + * Injection data + * + * @param RatingIndex $ratingIndex + * @param RatingEdit $ratingEdit + * @param CatalogProductIndex $catalogProductIndex + * @param CatalogProductEdit $catalogProductEdit + * @param ReviewEdit $reviewEdit + * @return void + */ + public function __inject( + RatingIndex $ratingIndex, + RatingEdit $ratingEdit, + CatalogProductIndex $catalogProductIndex, + CatalogProductEdit $catalogProductEdit, + ReviewEdit $reviewEdit + ) { + $this->ratingIndex = $ratingIndex; + $this->ratingEdit = $ratingEdit; + $this->catalogProductIndex = $catalogProductIndex; + $this->catalogProductEdit = $catalogProductEdit; + $this->reviewEdit = $reviewEdit; + } + + /** + * Update product review on product page + * + * @param ReviewInjectable $review + * @param int $rating + * @return array + */ + public function test(ReviewInjectable $review, $rating) + { + // Steps + $review = $this->createReview($review, $rating); + $this->catalogProductIndex->open(); + /** @var CatalogProductSimple $product */ + $product = $this->reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $this->catalogProductIndex->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]); + $this->catalogProductEdit->getForm()->openTab('product_reviews'); + $filter = [ + 'title' => $this->reviewInitial->getTitle(), + 'sku' => $product->getSku() + ]; + $this->catalogProductEdit->getForm()->getTabElement('product_reviews')->getReviewsGrid() + ->searchAndOpen($filter); + $this->reviewEdit->getReviewForm()->fill($review); + $this->reviewEdit->getPageActions()->save(); + $productRating = $this->reviewInitial->getDataFieldConfig('ratings')['source']->getRatings()[0]; + + return ['product' => $product, 'productRating' => $productRating]; + } + + /** + * Create review + * + * @param ReviewInjectable $review + * @param int $rating + * @return ReviewInjectable + */ + protected function createReview($review, $rating) + { + $reviewData = $review->getData(); + $fixtureRating = $this->reviewInitial->getDataFieldConfig('ratings')['source']->getRatings()[0]; + $reviewData['ratings'][0] = ['fixtureRating' => $fixtureRating, 'rating' => $rating]; + + return $this->fixtureFactory->createByCode('reviewInjectable', ['data' => $reviewData]); + } + + /** + * Clear data after test + * + * @return void + */ + public function tearDown() + { + if (!$this->reviewInitial instanceof ReviewInjectable) { + return; + } + $this->ratingIndex->open(); + foreach ($this->reviewInitial->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest/test.csv b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..9d4bcc35b2b270b8edb74ee1e0c390f7b1be2d61 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest/test.csv @@ -0,0 +1,2 @@ +"rating";"review/data/status_id";"productRating/data/select_stores";"review/data/nickname";"review/data/title";"review/data/detail";"constraint" +"3";"Approved";"Main Website/Main Website Store/Default Store View";"name%isolation%";"title%isolation%";"details%isolation%";"assertProductReviewBackendSuccessSaveMessage, assertProductReviewInGrid, assertProductReviewOnProductPage, assertProductRatingInProductPage" diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php index 5be0f612f0c4b4d8097910aa481696c9522c7946..6b2c90d28ea09203e346626d7210eadacf489466 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php @@ -115,7 +115,7 @@ class UpdateProductReviewEntityTest extends Injectable * * @param ReviewInjectable $reviewInitial * @param ReviewInjectable $review - * @return void + * @return array */ public function test(ReviewInjectable $reviewInitial, ReviewInjectable $review) { @@ -130,6 +130,11 @@ class UpdateProductReviewEntityTest extends Injectable $this->reviewIndex->getReviewGrid()->searchAndOpen(['review_id' => $reviewInitial->getReviewId()]); $this->reviewEdit->getReviewForm()->fill($review); $this->reviewEdit->getPageActions()->save(); + + // Prepare data for asserts + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + + return ['product' => $product]; } /** @@ -140,11 +145,11 @@ class UpdateProductReviewEntityTest extends Injectable public function tearDown() { $this->ratingIndex->open(); - $ratingGrid = $this->ratingIndex->getRatingGrid(); - $pageActions = $this->ratingEdit->getPageActions(); - foreach ($this->review->getRatings() as $rating) { - $ratingGrid->searchAndOpen(['rating_code' => $rating['title']]); - $pageActions->delete(); + if ($this->review instanceof ReviewInjectable) { + foreach ($this->review->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Review/Test/etc/constraint.xml index 793cb704f3021b08f26f609d24578025e83ede27..113b6538e8bdcf062414794372229260e1677ba5 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/etc/constraint.xml @@ -81,4 +81,7 @@ <assertProductReviewNotInGrid module="Magento_Review"> <severeness>low</severeness> </assertProductReviewNotInGrid> + <assertProductReviewInGridOnCustomerPage module="Magento_Review"> + <severeness>low</severeness> + </assertProductReviewInGridOnCustomerPage> </constraint> \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Block/Switcher.php b/dev/tests/functional/tests/app/Magento/Store/Test/Block/Switcher.php index ac873714ba652e34e9832f5410ca49cbaba2e1a5..592979ef677a52942ec4bbdfe0bb5b67cd9280d1 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Block/Switcher.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Block/Switcher.php @@ -27,6 +27,7 @@ namespace Magento\Store\Test\Block; use Mtf\Block\Block; use Mtf\Client\Element\Locator; +use Magento\Store\Test\Fixture\Store; class Switcher extends Block { @@ -37,6 +38,13 @@ class Switcher extends Block */ protected $dropDownButton = '#switcher-language-trigger'; + /** + * StoreView selector + * + * @var string + */ + protected $storeViewSelector = 'li.view-%s'; + /** * Select store * @@ -59,4 +67,31 @@ class Switcher extends Block { return $this->_rootElement->find($this->dropDownButton)->getText(); } + + /** + * Check is Store View Visible + * + * @param Store $store + * @return bool + */ + public function isStoreViewVisible($store) + { + $storeViewDropdown = $this->_rootElement->find($this->dropDownButton); + + $storeViewDropdown->click(); + $isStoreViewVisible = $this->_rootElement->find(sprintf($this->storeViewSelector, $store->getCode())) + ->isVisible(); + $storeViewDropdown->click(); + return $isStoreViewVisible; + } + + /** + * Check if StoreView dropdown is visible + * + * @return bool + */ + public function isStoreViewDropdownVisible() + { + return $this->_rootElement->find($this->dropDownButton)->isVisible(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreBackend.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreBackend.php new file mode 100644 index 0000000000000000000000000000000000000000..1df338ce29713bed6a7e9a6ee19292f1fdf789bf --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreBackend.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Magento\Backend\Test\Page\Adminhtml\SystemConfig; +use Magento\Store\Test\Fixture\Store; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertStoreBackend + * Assert that created store view displays in backend configuration (Stores > Configuration > "Scope" dropdown) + */ +class AssertStoreBackend extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created store view displays in backend configuration (Stores > Configuration > "Scope" dropdown) + * + * @param Store $store + * @param SystemConfig $systemConfig + * @return void + */ + public function processAssert(Store $store, SystemConfig $systemConfig) + { + $systemConfig->open(); + $isStoreVisible = $systemConfig->getPageActions()->isStoreVisible($store); + \PHPUnit_Framework_Assert::assertTrue($isStoreVisible, "Store view is not visible in dropdown on config page"); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store View is available in backend configuration (Stores > Configuration > "Scope" dropdown)'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreForm.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreForm.php new file mode 100644 index 0000000000000000000000000000000000000000..5fc67645681bfeb252166e797cafd7c287b5f774 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreForm.php @@ -0,0 +1,74 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractAssertForm; +use Magento\Store\Test\Fixture\Store; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\StoreNew; + +/** + * Class AssertStoreForm + * Assert that displayed Store View data on edit page equals passed from fixture + */ +class AssertStoreForm extends AbstractAssertForm +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that displayed Store View data on edit page equals passed from fixture + * + * @param StoreIndex $storeIndex + * @param StoreNew $storeNew + * @param Store $store + * @return void + */ + public function processAssert( + StoreIndex $storeIndex, + StoreNew $storeNew, + Store $store + ) { + $storeIndex->open()->getStoreGrid()->searchAndOpenStore($store); + $formData = $storeNew->getStoreForm()->getData(); + $fixtureData = $store->getData(); + $errors = $this->verifyData($fixtureData, $formData); + \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Store View data on edit page equals data from fixture.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreFrontend.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreFrontend.php new file mode 100644 index 0000000000000000000000000000000000000000..7665c01494b503a4380f67ea569bc167e1c950a3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreFrontend.php @@ -0,0 +1,79 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Store\Test\Fixture\Store; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertStoreFrontend + * Assert that created store view available on frontend (store view selector on page top) + */ +class AssertStoreFrontend extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created store view available on frontend (store view selector on page top) + * + * @param Store $store + * @param CmsIndex $cmsIndex + * @return void + */ + public function processAssert(Store $store, CmsIndex $cmsIndex) + { + $cmsIndex->open(); + if ($cmsIndex->getFooterBlock()->isStoreGroupSwitcherVisible() + && $cmsIndex->getFooterBlock()->isStoreGroupVisible($store) + ) { + $cmsIndex->getFooterBlock()->selectStoreGroup($store); + } + + $isStoreViewVisible = !$cmsIndex->getStoreSwitcherBlock()->isStoreViewDropdownVisible() + ? true // if only one store view is assigned to store group + : $cmsIndex->getStoreSwitcherBlock()->isStoreViewVisible($store); + + \PHPUnit_Framework_Assert::assertTrue( + $isStoreViewVisible, + "Store view is not visible in dropdown on CmsIndex page" + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store view is visible in dropdown on CmsIndex page'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupForm.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupForm.php index f3921c915534288e8ff5c13a516c3f7c51d0df58..a2475dd2eff58ac567297da3d11a63b1a8e4153e 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupForm.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupForm.php @@ -67,7 +67,7 @@ class AssertStoreGroupForm extends AbstractAssertForm $fixtureData = $storeGroupOrigin != null ? array_merge($storeGroupOrigin->getData(), $storeGroup->getData()) : $storeGroup->getData(); - $storeIndex->open()->getStoreGrid()->searchAndOpenStore($storeGroup); + $storeIndex->open()->getStoreGrid()->searchAndOpenStoreGroup($storeGroup); $formData = $editGroup->getEditFormGroup()->getData(); $errors = $this->verifyData($fixtureData, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupSuccessDeleteAndBackupMessages.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupSuccessDeleteAndBackupMessages.php index 151a7b83717fa6bba8a969cb96bd57b9937066a7..829d8587a615bae9c4070da84628a6bcdcc47f56 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupSuccessDeleteAndBackupMessages.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupSuccessDeleteAndBackupMessages.php @@ -62,7 +62,7 @@ class AssertStoreGroupSuccessDeleteAndBackupMessages extends AbstractConstraint \PHPUnit_Framework_Assert::assertTrue( in_array(self::SUCCESS_BACKUP_MESSAGE, $actualMessages) && in_array(self::SUCCESS_DELETE_MESSAGE, $actualMessages), - 'Wrong success messages is displayed.' + 'Wrong success messages are displayed.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreInGrid.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreInGrid.php new file mode 100644 index 0000000000000000000000000000000000000000..f97e9ad95ff1aebdbe89a58f6850039ba22a3b5e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreInGrid.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Magento\Store\Test\Fixture\Store; +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertStoreInGrid + * Assert that created Store View can be found in Stores grid + */ +class AssertStoreInGrid extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created Store View can be found in Stores grid by name + * + * @param StoreIndex $storeIndex + * @param Store $store + * @return void + */ + public function processAssert(StoreIndex $storeIndex, Store $store) + { + $storeName = $store->getName(); + $storeIndex->open()->getStoreGrid()->search(['store_title' => $storeName]); + \PHPUnit_Framework_Assert::assertTrue( + $storeIndex->getStoreGrid()->isStoreExists($storeName), + 'Store \'' . $storeName . '\' is not present in grid.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store View is present in grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotInGrid.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotInGrid.php new file mode 100644 index 0000000000000000000000000000000000000000..20ff2a2e0aa6085794226cfa9a2dc52b45b24e6b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotInGrid.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Store\Test\Fixture\Store; + +/** + * Class AssertStoreNotInGrid + * Assert that store is absent in grid + */ +class AssertStoreNotInGrid extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created Store can not be found in Stores grid by name + * + * @param StoreIndex $storeIndex + * @param Store $store + * @return void + */ + public function processAssert(StoreIndex $storeIndex, Store $store) + { + $storeName = $store->getName(); + $storeIndex->open()->getStoreGrid()->search(['store_title' => $storeName]); + \PHPUnit_Framework_Assert::assertFalse( + $storeIndex->getStoreGrid()->isStoreExists($storeName), + 'Store \'' . $storeName . '\' is present in grid.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Store is absent in grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotOnFrontend.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotOnFrontend.php new file mode 100644 index 0000000000000000000000000000000000000000..eaa81fd986474101958d1e8280d115936bd5eddd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotOnFrontend.php @@ -0,0 +1,79 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Store\Test\Fixture\Store; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertStoreNotOnFrontend + * Assert that created store view is not available on frontend (store view selector on page top) + */ +class AssertStoreNotOnFrontend extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created store view is not available on frontend (store view selector on page top) + * + * @param Store $store + * @param CmsIndex $cmsIndex + * @return void + */ + public function processAssert(Store $store, CmsIndex $cmsIndex) + { + $cmsIndex->open(); + if ($cmsIndex->getFooterBlock()->isStoreGroupSwitcherVisible() + && $cmsIndex->getFooterBlock()->isStoreGroupVisible($store) + ) { + $cmsIndex->getFooterBlock()->selectStoreGroup($store); + } + + $isStoreViewVisible = !$cmsIndex->getStoreSwitcherBlock()->isStoreViewDropdownVisible() + ? false // if only one store view is assigned to store group + : $cmsIndex->getStoreSwitcherBlock()->isStoreViewVisible($store); + + \PHPUnit_Framework_Assert::assertFalse( + $isStoreViewVisible, + "Store view is visible in dropdown on CmsIndex page" + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store view is not visible in dropdown on CmsIndex page'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteAndBackupMessages.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteAndBackupMessages.php new file mode 100644 index 0000000000000000000000000000000000000000..b70be010e349a17f7a1e9d419176f90917b15544 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteAndBackupMessages.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertStoreSuccessDeleteAndBackupMessages + * Assert that store success delete and backup messages are present + */ +class AssertStoreSuccessDeleteAndBackupMessages extends AbstractConstraint +{ + /** + * Success backup message + */ + const SUCCESS_BACKUP_MESSAGE = 'The database was backed up.'; + + /** + * Success store delete message + */ + const SUCCESS_DELETE_MESSAGE = 'The store view has been deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that store success delete and backup messages are present + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + $actualMessages = $storeIndex->getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertTrue( + in_array(self::SUCCESS_BACKUP_MESSAGE, $actualMessages) && + in_array(self::SUCCESS_DELETE_MESSAGE, $actualMessages), + 'Wrong success messages are displayed.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Store view success delete and backup messages are present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteMessage.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..ebb965440ff5aa64941cb42a80660b7abb8c662c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteMessage.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertStoreSuccessDeleteMessage + * Assert that after store delete successful message appears + */ +class AssertStoreSuccessDeleteMessage extends AbstractConstraint +{ + /** + * Success store delete message + */ + const SUCCESS_DELETE_MESSAGE = 'The store view has been deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that after store delete successful message appears + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_DELETE_MESSAGE, + $storeIndex->getMessagesBlock()->getSuccessMessages(), + 'Wrong success delete message is displayed.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store success delete message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessSaveMessage.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessSaveMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..b488a730f7ce7a20a558f2bc03deb836d22cc549 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessSaveMessage.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertStoreSuccessSaveMessage + * Assert that after Store View save successful message appears + */ +class AssertStoreSuccessSaveMessage extends AbstractConstraint +{ + /** + * Success store view create message + */ + const SUCCESS_MESSAGE = 'The store view has been saved'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that success message is displayed after Store View has been created + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_MESSAGE, + $storeIndex->getMessagesBlock()->getSuccessMessages(), + 'Wrong success message is displayed.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store View success create message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteForm.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteForm.php new file mode 100644 index 0000000000000000000000000000000000000000..7949cd240201b1ab3b2768a65e61aac2e0109ccc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteForm.php @@ -0,0 +1,81 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractAssertForm; +use Magento\Store\Test\Fixture\Website; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditWebsite; + +/** + * Class AssertWebsiteForm + * Assert that displayed Website data on edit page equals passed from fixture + */ +class AssertWebsiteForm extends AbstractAssertForm +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Skipped fields for verify data + * + * @var array + */ + protected $skippedFields = ['website_id']; + + /** + * Assert that displayed Website data on edit page equals passed from fixture + * + * @param StoreIndex $storeIndex + * @param EditWebsite $editWebsite + * @param Website $website + * @return void + */ + public function processAssert( + StoreIndex $storeIndex, + EditWebsite $editWebsite, + Website $website + ) { + $fixtureData = $website->getData(); + $storeIndex->open()->getStoreGrid()->searchAndOpenWebsite($website); + $formData = $editWebsite->getEditFormWebsite()->getData(); + $errors = $this->verifyData($fixtureData, $formData); + \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website data on edit page equals data from fixture.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInGrid.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteInGrid.php similarity index 59% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInGrid.php rename to dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteInGrid.php index 0bd4f7ffd022aaea09cb5a1ea106f41b8fbb38c8..4d170d9c942fa48efcc5c800a62e39cdaaf50b04 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteInGrid.php @@ -22,38 +22,39 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\ConfigurableProduct\Test\Constraint; +namespace Magento\Store\Test\Constraint; use Mtf\Constraint\AbstractConstraint; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Store\Test\Fixture\Website; /** - * Class AssertConfigurableInGrid + * Class AssertWebsiteInGrid + * Assert that created Website can be found in Stores grid */ -class AssertConfigurableInGrid extends AbstractConstraint +class AssertWebsiteInGrid extends AbstractConstraint { /** * Constraint severeness * * @var string */ - protected $severeness = 'high'; + protected $severeness = 'low'; /** - * Assert product availability in products grid + * Assert that created Website can be found in Stores grid by name * - * @param CatalogProductConfigurable $configurable - * @param CatalogProductIndex $productPageGrid + * @param StoreIndex $storeIndex + * @param Website $website * @return void */ - public function processAssert(CatalogProductConfigurable $configurable, CatalogProductIndex $productPageGrid) + public function processAssert(StoreIndex $storeIndex, Website $website) { - $filter = ['sku' => $configurable->getSku()]; - $productPageGrid->open(); + $websiteName = $website->getName(); + $storeIndex->open()->getStoreGrid()->search(['website_title' => $websiteName]); \PHPUnit_Framework_Assert::assertTrue( - $productPageGrid->getProductGrid()->isRowVisible($filter), - 'Product with sku \'' . $configurable->getSku() . '\' is absent in Products grid.' + $storeIndex->getStoreGrid()->isWebsiteExists($website), + 'Website \'' . $websiteName . '\' is not present in grid.' ); } @@ -64,6 +65,6 @@ class AssertConfigurableInGrid extends AbstractConstraint */ public function toString() { - return 'Product is present in Products grid.'; + return 'Website is present in grid.'; } } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteNotInGrid.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteNotInGrid.php new file mode 100644 index 0000000000000000000000000000000000000000..f2810e0aa4ab05fdec626423cc72a070d80f3dc5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteNotInGrid.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Store\Test\Fixture\Website; + +/** + * Class AssertWebsiteNotInGrid + * Assert that deleted website is absent in grid + */ +class AssertWebsiteNotInGrid extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created Website can't be found in grid by name + * + * @param StoreIndex $storeIndex + * @param Website $website + * @return void + */ + public function processAssert(StoreIndex $storeIndex, Website $website) + { + $websiteName = $website->getName(); + $storeIndex->open()->getStoreGrid()->search(['website_title' => $websiteName]); + \PHPUnit_Framework_Assert::assertFalse( + $storeIndex->getStoreGrid()->isWebsiteExists($website), + 'Website \'' . $websiteName . '\' is present in grid.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website is absent in grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteOnStoreForm.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteOnStoreForm.php new file mode 100644 index 0000000000000000000000000000000000000000..c1f74ded798ca3089acf56565745309904baf439 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteOnStoreForm.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\NewGroupIndex; +use Magento\Store\Test\Fixture\Website; + +/** + * Class AssertWebsiteOnStoreForm + * Assert that Website visible on Store Group Form in Website dropdown + */ +class AssertWebsiteOnStoreForm extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that Website visible on Store Group Form in Website dropdown + * + * @param StoreIndex $storeIndex + * @param NewGroupIndex $newGroupIndex + * @param Website $website + * @return void + */ + public function processAssert(StoreIndex $storeIndex, NewGroupIndex $newGroupIndex, Website $website) + { + $websiteName = $website->getName(); + $storeIndex->open()->getGridPageActions()->createStoreGroup(); + \PHPUnit_Framework_Assert::assertTrue( + $newGroupIndex->getEditFormGroup()->isWebsiteVisible($websiteName), + 'Website \'' . $websiteName . '\' is not present on Store Group Form in Website dropdown.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website is visible on Store Group Form in Website dropdown.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteAndBackupMessages.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteAndBackupMessages.php new file mode 100644 index 0000000000000000000000000000000000000000..a53faf5be800ae5b10a6ade4ac41394d04f4cca3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteAndBackupMessages.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertWebsiteSuccessDeleteAndBackupMessages + * Assert that after website delete successful messages appears + */ +class AssertWebsiteSuccessDeleteAndBackupMessages extends AbstractConstraint +{ + /** + * Success backup message + */ + const SUCCESS_BACKUP_MESSAGE = 'The database was backed up.'; + + /** + * Success website delete message + */ + const SUCCESS_DELETE_MESSAGE = 'The website has been deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that success messages is displayed after deleting website + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + $actualMessages = $storeIndex->getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertTrue( + in_array(self::SUCCESS_BACKUP_MESSAGE, $actualMessages) && + in_array(self::SUCCESS_DELETE_MESSAGE, $actualMessages), + 'Wrong success messages are displayed.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website success delete and backup messages are present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteMessage.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..b4d52d6191aab32a4adf6a6b8f9e6b95284c051e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteMessage.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertWebsiteSuccessDeleteMessage + * Assert that after website delete successful message appears + */ +class AssertWebsiteSuccessDeleteMessage extends AbstractConstraint +{ + /** + * Success website delete message + */ + const SUCCESS_DELETE_MESSAGE = 'The website has been deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that success message is displayed after deleting website + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_DELETE_MESSAGE, + $storeIndex->getMessagesBlock()->getSuccessMessages(), + 'Wrong success delete message is displayed.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Website success delete message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessSaveMessage.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessSaveMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..0f56d581a03c859e82ac3c7915e7be01c72c3b6c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessSaveMessage.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertWebsiteSuccessSaveMessage + * Assert that after Website save successful message appears + */ +class AssertWebsiteSuccessSaveMessage extends AbstractConstraint +{ + /** + * Success website create message + */ + const SUCCESS_MESSAGE = 'The website has been saved.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that success message is displayed after Website has been created + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_MESSAGE, + $storeIndex->getMessagesBlock()->getSuccessMessages(), + 'Wrong success message is displayed.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website success create message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.php b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.php index e530f73b84fc166bc5ddc7d198591dd63275f190..bd8e0f574fbd8ee89f38432c72878e1e3b74ffc2 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.php @@ -43,7 +43,7 @@ class Store extends InjectableFixture protected $handlerInterface = 'Magento\Store\Test\Handler\Store\StoreInterface'; protected $defaultDataSet = [ - 'group_id' => 'Main Website Store', + 'group_id' => ['dataSet' => 'default'], 'name' => 'Custom_Store_%isolation%', 'code' => 'code_%isolation%', 'is_active' => 'Enabled', @@ -79,6 +79,7 @@ class Store extends InjectableFixture 'is_required' => '', 'default_value' => '0', 'input' => 'select', + 'source' => 'Magento\Store\Test\Fixture\Store\GroupId', ]; protected $name = [ diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.xml b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.xml index cd4f421f55cc2210d0749c073104562003680470..7dd02b13a5fda92803c2234a7522b1d13bd86b97 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.xml @@ -56,6 +56,7 @@ <is_required></is_required> <default_value>0</default_value> <input>select</input> + <source>Magento\Store\Test\Fixture\Store\GroupId</source> </group_id> <name> <attribute_code>name</attribute_code> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/Price.php b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php similarity index 61% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/Price.php rename to dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php index 918f84757d5ca798a0fbd8bc9fe6b203c1ddeefc..3ab42e6505d9373bca03ba577793f299ffd242f5 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/Price.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php @@ -22,18 +22,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; +namespace Magento\Store\Test\Fixture\Store; +use Mtf\Fixture\FixtureFactory; use Mtf\Fixture\FixtureInterface; +use Magento\Store\Test\Fixture\StoreGroup; /** - * Class Price - * - * Data keys: - * - preset (Price verification preset name) - * - value (Price value) + * Class GroupId + * Prepare StoreGroup for Store */ -class Price implements FixtureInterface +class GroupId implements FixtureInterface { /** * Prepared dataSet data @@ -50,31 +49,35 @@ class Price implements FixtureInterface protected $params; /** - * Current preset + * StoreGroup fixture * - * @var string + * @var StoreGroup */ - protected $currentPreset; + protected $storeGroup; /** * Constructor * + * @param FixtureFactory $fixtureFactory * @param array $params * @param array $data [optional] */ - public function __construct(array $params, array $data = []) + public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) { $this->params = $params; - if (isset($data['value'])) { - $this->data = $data['value']; - } - if (isset($data['preset'])) { - $this->currentPreset = $data['preset']; + if (isset($data['dataSet'])) { + $storeGroup = $fixtureFactory->createByCode('storeGroup', ['dataSet' => $data['dataSet']]); + /** @var StoreGroup $storeGroup */ + if (!$storeGroup->getGroupId()) { + $storeGroup->persist(); + } + $this->storeGroup = $storeGroup; + $this->data = $storeGroup->getWebsiteId() . "/" . $storeGroup->getName(); } } /** - * Persist custom selections products + * Persist attribute options * * @return void */ @@ -99,7 +102,7 @@ class Price implements FixtureInterface /** * Return data set configuration settings * - * @return string + * @return array */ public function getDataConfig() { @@ -107,27 +110,12 @@ class Price implements FixtureInterface } /** - * @return array|null + * Return StoreGroup fixture + * + * @return StoreGroup */ - public function getPreset() + public function getStoreGroup() { - $presets = [ - 'MAGETWO-23062' => [ - 'category_price' => '100.00', - 'product_price' => '100.00', - 'cart_price' => '154.00' - ], - 'MAGETWO-23063' => [ - 'category_price' => '100.00', - 'product_price' => '100.00', - 'cart_price' => '140.00' - ], - ]; - - if (!isset($presets[$this->currentPreset])) { - return null; - } - - return $presets[$this->currentPreset]; + return $this->storeGroup; } } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Handler/Store/Curl.php b/dev/tests/functional/tests/app/Magento/Store/Test/Handler/Store/Curl.php index e62368ac34185e6432cf3d8397fc92b5d7a93d3b..58a6e8c4543d99a6b0ee799c21b208d075aa10c4 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Handler/Store/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Handler/Store/Curl.php @@ -92,6 +92,7 @@ class Curl extends AbstractCurl implements StoreInterface $data['store'] = $this->replaceMappingData($fixture->getData()); $data['store_action'] = isset($data['store_action']) ? $data['store_action'] : 'add'; $data['store_type'] = isset($data['store_type']) ? $data['store_type'] : 'store'; + $data['store']['group_id'] = $fixture->getDataFieldConfig('group_id')['source']->getStoreGroup()->getGroupId(); return $data; } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.php b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.php index 3c86a70dc5221292d26f5f5f5697dff1fef84147..3c76d6bf8121ac8123e5cd9f271c6f096e828e04 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.php @@ -42,19 +42,24 @@ class Store extends AbstractRepository public function __construct(array $defaultConfig = [], array $defaultData = []) { $this->_data['default'] = [ - 'group_id' => 'Main Website Store', + 'group_id' => ['dataSet' => 'default'], 'name' => 'Custom_Store_%isolation%', 'code' => 'code_%isolation%', 'is_active' => 'Enabled', ]; + $this->_data['default_store_view'] = [ + 'store_id' => 1, + 'name' => 'Default Store View', + ]; + $this->_data['All Store Views'] = [ 'name' => 'All Store Views', 'store_id' => 0, ]; $this->_data['german'] = [ - 'group_id' => 'Main Website Store', + 'group_id' => ['dataSet' => 'default'], 'name' => 'DE%isolation%', 'code' => 'de%isolation%', 'is_active' => 'Enabled', diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.php b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.php index 1e1b11aede3c1d2e57c08d8f69a49b8ec0c19072..ca9c6f508414083e6d5ce4b23736be6d64ebf86d 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.php @@ -42,6 +42,17 @@ class StoreGroup extends AbstractRepository public function __construct(array $defaultConfig = [], array $defaultData = []) { $this->_data['default'] = [ + 'website_id' => [ + 'dataSet' => 'main_website' + ], + 'name' => 'Main Website Store', + 'group_id' => 1, + 'root_category_id' => [ + 'dataSet' => 'default_category' + ], + ]; + + $this->_data['custom'] = [ 'website_id' => [ 'dataSet' => 'main_website' ], diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6225715499174debedd9f78152cca7b188e112e5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php @@ -0,0 +1,92 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\StoreNew; +use Magento\Store\Test\Fixture\Store; +use Magento\Store\Test\Fixture\StoreGroup; + +/** + * Test Creation for CreateStoreEntity (Store Management) + * + * Preconditions: + * 1. Create Store Group + * + * Test Flow: + * 1. Open Backend + * 2. Go to Stores -> All Stores + * 3. Click "Create Store View" button + * 4. Fill data according to dataset + * 5. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27647 + */ +class CreateStoreEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page StoreNew + * + * @var StoreNew + */ + protected $storeNew; + + /** + * Preparing pages for test + * + * @param StoreIndex $storeIndex + * @param StoreNew $storeNew + * @return void + */ + public function __inject(StoreIndex $storeIndex, StoreNew $storeNew) + { + $this->storeIndex = $storeIndex; + $this->storeNew = $storeNew; + } + + /** + * Runs Test Creation for StoreEntityTest + * + * @param Store $store + * @return void + */ + public function test(Store $store) + { + //Steps: + $this->storeIndex->open(); + $this->storeIndex->getGridPageActions()->addStoreView(); + $this->storeNew->getStoreForm()->fill($store); + $this->storeNew->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..ab0eb22bdb511c8a691d564ca203cd5c7079d1af --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest/test.csv @@ -0,0 +1,4 @@ +"store/data/group_id/dataSet";"store/data/name";"store/data/code";"store/data/is_active";"constraint";"issue" +"default";"store_name_%isolation%";"storecode_%isolation%";"Enabled";"assertStoreSuccessSaveMessage, assertStoreInGrid, assertStoreForm, assertStoreBackend, assertStoreFrontend";"" +"default";"store_name_%isolation%";"storecode_%isolation%";"Disabled";"assertStoreSuccessSaveMessage, assertStoreInGrid, assertStoreForm, assertStoreBackend, assertStoreNotOnFrontend";"" +"custom";"store_name_%isolation%";"storecode_%isolation%";"Enabled";"assertStoreSuccessSaveMessage, assertStoreInGrid, assertStoreForm, assertStoreBackend, assertStoreFrontend";"Bug: MAGETWO-27726" \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..310a4ffff29d02c1fd14611c02a87970ca53fc40 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php @@ -0,0 +1,91 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Store\Test\Fixture\Website; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\NewWebsiteIndex; + +/** + * Create Website (Store Management) + * + * Test Flow: + * 1. Open Backend + * 2. Go to Stores-> All Stores + * 3. Click "Create Website" button + * 4. Fill data according to dataset + * 5. Click "Save Web Site" button + * 6. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27665 + */ +class CreateWebsiteEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * NewWebsiteIndex page + * + * @var NewWebsiteIndex + */ + protected $newWebsiteIndex; + + /** + * Injection data + * + * @param StoreIndex $storeIndex + * @param NewWebsiteIndex $newWebsiteIndex + * @return void + */ + public function __inject( + StoreIndex $storeIndex, + NewWebsiteIndex $newWebsiteIndex + ) { + $this->storeIndex = $storeIndex; + $this->newWebsiteIndex = $newWebsiteIndex; + } + + /** + * Create Website + * + * @param Website $website + * @return void + */ + public function test(Website $website) + { + //Steps + $this->storeIndex->open(); + $this->storeIndex->getGridPageActions()->addNew(); + $this->newWebsiteIndex->getEditWebsiteForm()->fill($website); + $this->newWebsiteIndex->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..5f4163b380f43bd2a6088c9bd05b393a3e2770c8 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest/test.csv @@ -0,0 +1,2 @@ +"website/data/name";"website/data/code";"constraint" +"website_%isolation%";"code_%isolation%";"assertWebsiteSuccessSaveMessage, assertWebsiteInGrid, assertWebsiteForm, assertWebsiteOnStoreForm" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ceaf7055d87ee392de0c9d91a3d3ce0518a3b3e9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php @@ -0,0 +1,124 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditStore; +use Magento\Backup\Test\Page\Adminhtml\BackupIndex; +use Magento\Backend\Test\Page\Adminhtml\StoreDelete; +use Magento\Store\Test\Fixture\Store; + +/** + * Test Creation for DeleteStoreEntity + * + * Test Flow: + * Preconditions: + * 1. Create store view + * + * Steps: + * 1. Open Backend + * 2. Go to Stores -> All Stores + * 3. Open created store view + * 4. Click "Delete Store View" + * 5. Set "Create DB Backup" according to dataSet + * 6. Click "Delete Store View" + * 7. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27942 + */ +class DeleteStoreEntityTest extends Injectable +{ + /** + * Page BackupIndex + * + * @var BackupIndex + */ + protected $backupIndex; + + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditStore + * + * @var EditStore + */ + protected $editStore; + + /** + * Page StoreDelete + * + * @var StoreDelete + */ + protected $storeDelete; + + /** + * Prepare pages for test + * + * @param BackupIndex $backupIndex + * @param StoreIndex $storeIndex + * @param EditStore $editStore + * @param StoreDelete $storeDelete + * @return void + */ + public function __inject( + BackupIndex $backupIndex, + StoreIndex $storeIndex, + EditStore $editStore, + StoreDelete $storeDelete + ) { + $this->storeIndex = $storeIndex; + $this->editStore = $editStore; + $this->backupIndex = $backupIndex; + $this->storeDelete = $storeDelete; + } + + /** + * Run Delete Store Entity test + * + * @param Store $store + * @param string $createBackup + * @return void + */ + public function test(Store $store, $createBackup) + { + // Preconditions: + $store->persist(); + $this->backupIndex->open()->getBackupGrid()->massaction([], 'Delete', true, 'Select All'); + + // Steps: + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenStore($store); + $this->editStore->getFormPageActions()->delete(); + $this->storeDelete->getStoreForm()->fillForm(['create_backup' => $createBackup]); + $this->storeDelete->getFormPageFooterActions()->delete(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..51721d8136229e2da913e45498b27c03fcc5731f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest/test.csv @@ -0,0 +1,3 @@ +"store/dataSet";"createBackup";"constraint" +"default";"Yes";"assertStoreSuccessDeleteAndBackupMessages, assertStoreNotInGrid, assertBackupInGrid, assertStoreNotOnFrontend" +"custom";"No";"assertStoreSuccessDeleteMessage, assertStoreNotInGrid, assertStoreNotOnFrontend" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php index 3cfbff171256bf531b5b96a76be19497a2aa55f7..ebce8803b16878e92c2d0be00b9e1dc6c4954f3d 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php @@ -118,7 +118,7 @@ class DeleteStoreGroupEntityTest extends Injectable //Steps $this->storeIndex->open(); - $this->storeIndex->getStoreGrid()->searchAndOpenStore($storeGroup); + $this->storeIndex->getStoreGrid()->searchAndOpenStoreGroup($storeGroup); $this->editGroup->getFormPageActions()->delete(); $this->deleteGroup->getDeleteGroupForm()->fillForm(['create_backup' => $createBackup]); $this->deleteGroup->getFormPageFooterActions()->delete(); diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest/test.csv index 546ab359a88d3f46b46e1239d74bf14f12b8b1fc..d79cf9afa6d43960533561ffa8af1660b5f4f1d9 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest/test.csv +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest/test.csv @@ -1,3 +1,3 @@ "storeGroup/dataSet";"createBackup";"constraint" -"default";"Yes";"assertStoreGroupSuccessDeleteAndBackupMessages, assertStoreGroupNotInGrid, assertBackupInGrid" -"default";"No";"assertStoreGroupSuccessDeleteMessage, assertStoreGroupNotInGrid" +"custom";"Yes";"assertStoreGroupSuccessDeleteAndBackupMessages, assertStoreGroupNotInGrid, assertBackupInGrid" +"custom";"No";"assertStoreGroupSuccessDeleteMessage, assertStoreGroupNotInGrid" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..30cd3e6d2c6d309bd03d23549a20fe07523d939a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php @@ -0,0 +1,126 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Store\Test\Fixture\Website; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditWebsite; +use Magento\Backend\Test\Page\Adminhtml\DeleteWebsite; +use Magento\Backup\Test\Page\Adminhtml\BackupIndex; + +/** + * Delete Website (Store Management) + * + * Test Flow: + * + * Preconditions: + * 1. Create website + * 2. Delete all backups + * + * Steps: + * 1. Open Backend + * 2. Go to Stores-> All Stores + * 3. Open created website + * 4. Click "Delete Web Site" + * 5. Fill data according to dataset + * 6. Click "Delete Web Site" + * 7. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27723 + */ +class DeleteWebsiteEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditWebsite + * + * @var EditWebsite + */ + protected $editWebsite; + + /** + * Page DeleteWebsite + * + * @var DeleteWebsite + */ + protected $deleteWebsite; + + /** + * Page BackupIndex + * + * @var BackupIndex + */ + protected $backupIndex; + + /** + * Injection data + * + * @param StoreIndex $storeIndex + * @param EditWebsite $editWebsite + * @param DeleteWebsite $deleteWebsite + * @param BackupIndex $backupIndex + * @return void + */ + public function __inject( + StoreIndex $storeIndex, + EditWebsite $editWebsite, + DeleteWebsite $deleteWebsite, + BackupIndex $backupIndex + ) { + $this->storeIndex = $storeIndex; + $this->editWebsite = $editWebsite; + $this->deleteWebsite = $deleteWebsite; + $this->backupIndex = $backupIndex; + } + + /** + * Delete Website + * + * @param Website $website + * @param string $createBackup + * @return void + */ + public function test(Website $website, $createBackup) + { + //Preconditions + $website->persist(); + $this->backupIndex->open()->getBackupGrid()->massaction([], 'Delete', true, 'Select All'); + + //Steps + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenWebsite($website); + $this->editWebsite->getFormPageActions()->delete(); + $this->deleteWebsite->getDeleteWebsiteForm()->fillForm(['create_backup' => $createBackup]); + $this->deleteWebsite->getFormPageFooterActions()->delete(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..5e94af67424adfa90826981fcaf64cb65320e8a2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest/test.csv @@ -0,0 +1,3 @@ +"website/dataSet";"createBackup";"constraint" +"custom_website";"Yes";"assertWebsiteSuccessDeleteAndBackupMessages, assertWebsiteNotInGrid, assertBackupInGrid" +"custom_website";"No";"assertWebsiteSuccessDeleteMessage, assertWebsiteNotInGrid" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/StoreTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/StoreTest.php index 303a97ace440c10fbaf630482f996f8619d3b810..a4fb5a0a3ec65e9bc73dc51da6b85bfba86f34e2 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/StoreTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/StoreTest.php @@ -70,9 +70,7 @@ class StoreTest extends Functional $configPage = Factory::getPageFactory()->getAdminSystemConfig(); $configPage->open(); - $configPage->getPageActions()->selectStore( - ['Main Website', $storeFixture->getGroupId(), $storeFixture->getName()] - ); + $configPage->getPageActions()->selectStore($storeFixture->getGroupId() . "/" . $storeFixture->getName()); $configGroup = $configPage->getForm()->getGroup('Locale Options'); $configGroup->open(); $configGroup->setValue('select-groups-locale-fields-code-value', 'German (Germany)'); diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..888a7f0994378651ff98634de9bf56ac5467d5c3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php @@ -0,0 +1,96 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\TestCase; + +use Magento\Store\Test\Fixture\Store; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditStore; +use Mtf\TestCase\Injectable; + +/** + * Test Creation for UpdateStoreEntity (Store Management) + * + * Test Flow: + * Preconditions: + * 1.Create store view + * + * Steps: + * 1. Open Backend + * 2. Go to Stores -> All Stores + * 3. Open created store view + * 4. Fill data according to dataset + * 5. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27786 + */ +class UpdateStoreEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditStore + * + * @var EditStore + */ + protected $editStore; + + /** + * Preparing pages for test + * + * @param StoreIndex $storeIndex + * @param EditStore $editStore + * @return void + */ + public function __inject(StoreIndex $storeIndex, EditStore $editStore) + { + $this->storeIndex = $storeIndex; + $this->editStore = $editStore; + } + + /** + * Runs Update Store Entity test + * + * @param Store $storeInitial + * @param Store $store + * @return void + */ + public function test(Store $storeInitial, Store $store) + { + // Preconditions: + $storeInitial->persist(); + + // Steps: + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenStore($storeInitial); + $this->editStore->getStoreForm()->fill($store); + $this->editStore->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..57998422915b296ae0ab3eb1c42a27b760236d6d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest/test.csv @@ -0,0 +1,2 @@ +"store/data/group_id/dataSet";"store/data/name";"store/data/code";"store/data/is_active";"constraint";"issue" +"default";"storename_updated%isolation%";"storecode_updated%isolation%";"Enabled";"assertStoreSuccessSaveMessage, assertStoreInGrid, assertStoreForm, assertStoreBackend, assertStoreFrontend";"Bug: MAGETWO-27726" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php index bb7284c19d369516f909ef425d837fb42983537f..8282fb0051decc0b1bcac6701a3fa47a1b556e06 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php @@ -93,7 +93,7 @@ class UpdateStoreGroupEntityTest extends Injectable //Steps $this->storeIndex->open(); - $this->storeIndex->getStoreGrid()->searchAndOpenStore($storeGroupOrigin); + $this->storeIndex->getStoreGrid()->searchAndOpenStoreGroup($storeGroupOrigin); $this->editGroup->getEditFormGroup()->fill($storeGroup); $this->editGroup->getFormPageActions()->save(); } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..32fb04a0fed26d91f6512bc241a6348e7d38fd66 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php @@ -0,0 +1,126 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Store\Test\Fixture\Website; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditWebsite; + +/** + * Update Website (Store Management) + * + * Test Flow: + * + * Preconditions: + * 1. Create website + * + * Steps: + * 1. Open Backend + * 2. Go to Stores-> All Stores + * 3. Open created website + * 4. Fill data according to dataset + * 5. Click "Save Web Site" button + * 6. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27690 + */ +class UpdateWebsiteEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditWebsite + * + * @var EditWebsite + */ + protected $editWebsite; + + /** + * Fixture factory + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Injection data + * + * @param StoreIndex $storeIndex + * @param EditWebsite $editWebsite + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __inject( + StoreIndex $storeIndex, + EditWebsite $editWebsite, + FixtureFactory $fixtureFactory + ) { + $this->storeIndex = $storeIndex; + $this->editWebsite = $editWebsite; + $this->fixtureFactory = $fixtureFactory; + } + + /** + * Update Website + * + * @param Website $websiteOrigin + * @param Website $website + * @return array + */ + public function test(Website $websiteOrigin, Website $website) + { + //Preconditions + $websiteOrigin->persist(); + + //Steps + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenWebsite($websiteOrigin); + $this->editWebsite->getEditFormWebsite()->fill($website); + $this->editWebsite->getFormPageActions()->save(); + + return ['website' => $this->mergeFixture($website, $websiteOrigin)]; + } + + /** + * Merge Website fixtures + * + * @param Website $website + * @param Website $websiteOrigin + * @return Website + */ + protected function mergeFixture(Website $website, Website $websiteOrigin) + { + $data = array_merge($websiteOrigin->getData(), $website->getData()); + return $this->fixtureFactory->createByCode('website', ['data' => $data]); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..003ccb847ab9a9edf088e518d2789569f49f4147 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest/test.csv @@ -0,0 +1,2 @@ +"websiteOrigin/dataSet";"website/data/name";"website/data/code";"constraint" +"custom_website";"website_upd%isolation%";"code_upd%isolation%";"assertWebsiteSuccessSaveMessage, assertWebsiteInGrid, assertWebsiteForm, assertWebsiteOnStoreForm" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Store/Test/etc/constraint.xml index 4d1b8dafb80f65e6d7c534353719dc67c8a32fa5..6f3542645b24b69f691c5bc46e4668009c45b7a3 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/etc/constraint.xml @@ -45,4 +45,58 @@ <assertStoreGroupSuccessDeleteAndBackupMessages module="Magento_Store"> <severeness>low</severeness> </assertStoreGroupSuccessDeleteAndBackupMessages> + <assertStoreSuccessSaveMessage module="Magento_Store"> + <severeness>low</severeness> + </assertStoreSuccessSaveMessage> + <assertStoreInGrid module="Magento_Store"> + <severeness>low</severeness> + </assertStoreInGrid> + <assertStoreBackend module="Magento_Store"> + <severeness>low</severeness> + </assertStoreBackend> + <assertStoreFrontend module="Magento_Store"> + <severeness>low</severeness> + </assertStoreFrontend> + <assertStoreNotOnFrontend module="Magento_Store"> + <severeness>low</severeness> + </assertStoreNotOnFrontend> + <assertWebsiteSuccessSaveMessage module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteSuccessSaveMessage> + <assertWebsiteInGrid module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteInGrid> + <assertWebsiteOnStoreForm module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteOnStoreForm> + <assertWebsiteForm module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteForm> + <assertWebsiteSuccessDeleteAndBackupMessages module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteSuccessDeleteAndBackupMessages> + <assertWebsiteSuccessDeleteMessage module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteSuccessDeleteMessage> + <assertWebsiteNotInGrid module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteNotInGrid> + <assertStoreForm module="Magento_Store"> + <severeness>low</severeness> + </assertStoreForm> + <assertStoreSuccessDeleteMessage module="Magento_Store"> + <severeness>low</severeness> + </assertStoreSuccessDeleteMessage> + <assertStoreSuccessDeleteMessage module="Magento_Store"> + <severeness>low</severeness> + </assertStoreSuccessDeleteMessage> + <assertStoreNotInGrid module="Magento_Store"> + <severeness>low</severeness> + </assertStoreNotInGrid> + <assertStoreNotOnFrontend module="Magento_Store"> + <severeness>low</severeness> + </assertStoreNotOnFrontend> + <assertStoreSuccessDeleteAndBackupMessages module="Magento_Store"> + <severeness>low</severeness> + </assertStoreSuccessDeleteAndBackupMessages> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Footer.php b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Footer.php index e8c6933006ce07de0866c7d41439a94005f4bb05..bb64ed04fa7a315d200ba23bfc1f56a6b1934e8c 100644 --- a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Footer.php +++ b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Footer.php @@ -27,9 +27,11 @@ namespace Magento\Theme\Test\Block\Html; use Mtf\Block\Block; use Mtf\Client\Element\Locator; +use Magento\Store\Test\Fixture\Store; /** * Footer block + * CmsIndex page footer block */ class Footer extends Block { @@ -47,6 +49,27 @@ class Footer extends Block */ protected $variableSelector = './/div[contains(@class, "links")]/*[text()="%s"]'; + /** + * Store group dropdown selector + * + * @var string + */ + protected $storeGroupDropdown = '.switcher.store'; + + /** + * Store Group switch selector + * + * @var string + */ + protected $storeGroupSwitch = '[data-toggle="dropdown"]'; + + /** + * Store group selector + * + * @var string + */ + protected $storeGroupSelector = './/a[contains(.,"%s")]'; + /** * Click on link by name * @@ -76,4 +99,47 @@ class Footer extends Block Locator::SELECTOR_XPATH )->isVisible(); } + + /** + * Select store group + * + * @param Store $store + * @return void + */ + public function selectStoreGroup(Store $store) + { + $storeGroupName = explode("/", $store->getGroupId())[1]; + $this->_rootElement->find($this->storeGroupSwitch)->click(); + $storeGroup = $this->_rootElement->find( + sprintf($this->storeGroupSelector, $storeGroupName), + Locator::SELECTOR_XPATH + ); + $storeGroup->click(); + } + + /** + * Check if store visible in dropdown + * + * @param Store $store + * @return bool + */ + public function isStoreGroupVisible(Store $store) + { + $storeGroupName = explode("/", $store->getGroupId())[1]; + $this->_rootElement->find($this->storeGroupSwitch)->click(); + return $this->_rootElement->find( + sprintf($this->storeGroupSelector, $storeGroupName), + Locator::SELECTOR_XPATH + )->isVisible(); + } + + /** + * Check if store group switcher is visible + * + * @return bool + */ + public function isStoreGroupSwitcherVisible() + { + return $this->_rootElement->find($this->storeGroupSwitch)->isVisible(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php index 2b4a18baeea4a05b99e2292484054f5fbe0e7967..bb95c7642d65c781efd9cc7730cf9aac856dea69 100644 --- a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php +++ b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php @@ -53,14 +53,11 @@ class Links extends Block * Open Link by title * * @param string $linkTitle - * @return Element + * @return void */ public function openLink($linkTitle) { - $link = $this->_rootElement->find(sprintf($this->link, $linkTitle), Locator::SELECTOR_XPATH); - if ($link->isVisible()) { - $link->click(); - } + $this->_rootElement->find(sprintf($this->link, $linkTitle), Locator::SELECTOR_XPATH)->click(); } /** diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleSalesRestrictedAccess.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleSalesRestrictedAccess.php index fde7fdf4d8f6e146677ec2d4c3d6fd0d388cd603..8d47ae0977394ab4f29b00b8f52efb6eea2cac65 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleSalesRestrictedAccess.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleSalesRestrictedAccess.php @@ -24,7 +24,7 @@ namespace Magento\User\Test\Constraint; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Page\Adminhtml\UserIndex; use Mtf\Constraint\AbstractConstraint; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogOut.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogOut.php index f28c256c9a50086bf3b28e0d775dde432a97fc15..b36598af652bb28f728bad089aa0d45cad78a4e5 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogOut.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogOut.php @@ -24,7 +24,7 @@ namespace Magento\User\Test\Constraint; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Mtf\Constraint\AbstractConstraint; use Magento\Backend\Test\Page\AdminAuthLogin; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php index ec153d57da0ce87e83528d3e68a7375c392bb758..1b892d2dccb83410d2fb29165b99cc6db4258b53 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php @@ -26,7 +26,7 @@ namespace Magento\User\Test\Constraint; use Magento\User\Test\Fixture\User; use Mtf\Constraint\AbstractConstraint; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\Backend\Test\Page\AdminAuthLogin; /** diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php index 025957a13f0f59253e99397ddb805401d67196db..41becdfffb24e7a1f98c1887ba24681e28d1bf55 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php @@ -25,7 +25,7 @@ namespace Magento\User\Test\TestCase; use Magento\Backend\Test\Page\AdminAuthLogin; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Page\Adminhtml\UserEdit; use Magento\User\Test\Page\Adminhtml\UserIndex; use Mtf\TestCase\Injectable; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php index 6b4aa2d57f6970082944696fd2ba02afe0c6a0f2..67d86b6cffc6b32c71ca3ce0381e26e7105e77a7 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php @@ -25,7 +25,7 @@ namespace Magento\User\Test\TestCase; use Magento\Backend\Test\Page\AdminAuthLogin; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Fixture\User; use Magento\User\Test\Fixture\AdminUserRole; use Magento\User\Test\Page\Adminhtml\UserRoleIndex; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php index a7c99546e7d938ac192769b088d0357d84d06f70..b62a01cf0ecb267540a2d368df6a6856006e8a4f 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php @@ -29,7 +29,7 @@ use Magento\User\Test\Fixture\User; use Magento\User\Test\Fixture\AdminUserRole; use Mtf\Fixture\FixtureFactory; use Mtf\TestCase\Injectable; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Page\Adminhtml\UserEdit; use Magento\User\Test\Page\Adminhtml\UserIndex; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php index e86507cf1e628f72a55d086eb8688093fbfe2b4f..2c802043f44f3dc773c630c3bac7f5ebd9b7493d 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php @@ -25,7 +25,7 @@ namespace Magento\User\Test\TestCase; use Magento\Backend\Test\Page\AdminAuthLogin; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Page\Adminhtml\UserRoleIndex; use Magento\User\Test\Page\Adminhtml\UserRoleEditRole; use Magento\User\Test\Fixture\User; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/User/Test/etc/constraint.xml index cff67adbe367d32e12b74d9c5891a3aebfbd6c2b..b0b8a44a22f455784177cb48a7f49208f9eb2d61 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/etc/constraint.xml @@ -27,7 +27,7 @@ <assertUserSuccessLogin module="Magento_User"> <severeness>low</severeness> <require> - <dashboard class="Magento\Backend\Test\Page\Dashboard" /> + <dashboard class="Magento\Backend\Test\Page\Adminhtml\Dashboard" /> <adminAuth class="Magento\Backend\Test\Page\AdminAuthLogin" /> <user class="Magento\User\Test\Fixture\User" /> <customAdmin class="Magento\User\Test\Fixture\User" /> @@ -37,7 +37,7 @@ <severeness>low</severeness> <require> <adminAuth class="Magento\Backend\Test\Page\AdminAuthLogin" /> - <dashboard class="Magento\Backend\Test\Page\Dashboard" /> + <dashboard class="Magento\Backend\Test\Page\Adminhtml\Dashboard" /> </require> </assertUserSuccessLogOut> <assertUserWrongCredentialsMessage module="Magento_User"> @@ -51,7 +51,7 @@ <severeness>low</severeness> <require> <userIndex class="Magento\User\Test\Page\Adminhtml\UserIndex" /> - <dashboard class="Magento\Backend\Test\Page\Dashboard" /> + <dashboard class="Magento\Backend\Test\Page\Adminhtml\Dashboard" /> </require> </assertUserRoleSalesRestrictedAccess> <assertRoleSuccessSaveMessage module="Magento_User"> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php new file mode 100644 index 0000000000000000000000000000000000000000..ec3a08020fcb91ba8a82b8beccb7e235982692ab --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php @@ -0,0 +1,56 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab; + +use Mtf\Client\Element; +use Magento\Backend\Test\Block\Widget\Tab; +use Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist\Grid; + +/** + * Class Wishlist + * Customer Wishlist edit tab + */ +class Wishlist extends Tab +{ + /** + * Wishlist grid selector + * + * @var string + */ + protected $wishlistGrid = '#wishlistGrid'; + + /** + * Get wishlist grid + * + * @return Grid + */ + public function getSearchGridBlock() + { + return $this->blockFactory->create( + 'Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist\Grid', + ['element' => $this->_rootElement->find($this->wishlistGrid)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..d6a2795732af81451a8080040aac62db61f9c97b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php @@ -0,0 +1,68 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist; + +use Magento\Backend\Test\Block\Widget\Grid as ParentGrid; +use Mtf\Client\Element\Locator; + +/** + * Class Grid + * Grid on Wishlist tab in customer details on backend + */ +class Grid extends ParentGrid +{ + /** + * Grid fields map + * + * @var array + */ + protected $filters = [ + 'product_name' => [ + 'selector' => 'input[name="product_name"]' + ], + ]; + + /** + * Delete link selector + * + * @var string + */ + protected $deleteLink = 'a[onclick*="removeItem"]'; + + /** + * Search item and delete it + * + * @param array $filter + * @return void + * @throws \Exception + */ + public function searchAndDelete(array $filter) + { + $this->search($filter); + $rowItem = $this->_rootElement->find($this->rowItem, Locator::SELECTOR_CSS); + $rowItem->find($this->deleteLink, Locator::SELECTOR_CSS)->click(); + $this->_rootElement->acceptAlert(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml new file mode 100644 index 0000000000000000000000000000000000000000..3b0db450390e23bb7b482a0ae070720a612a6128 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<tabs> + <wishlist> + <class>\Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist</class> + <selector>#customer_info_tabs_wishlist</selector> + <strategy>css selector</strategy> + </wishlist> +</tabs> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php index 7e59d1c591bbdc09e300680522efbb90114b3b8c..d9cde22eebd8587e482746dafc7efebb9fbd0507 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php @@ -39,6 +39,27 @@ class Wishlist extends Block */ protected $shareWishList = '[name="save_and_share"]'; + /** + * Product items selector + * + * @var string + */ + protected $productItems = '.product-items'; + + /** + * Selector for 'Add to Cart' button + * + * @var string + */ + protected $addToCart = '.action.tocart'; + + /** + * Button 'Update Wish List' css selector + * + * @var string + */ + protected $updateButton = '.action.update'; + /** * Click button "Share Wish List" * @@ -48,4 +69,37 @@ class Wishlist extends Block { $this->_rootElement->find($this->shareWishList)->click(); } + + /** + * Get items product block + * + * @return \Magento\Wishlist\Test\Block\Customer\Wishlist\Items + */ + public function getProductItemsBlock() + { + return $this->blockFactory->create( + 'Magento\Wishlist\Test\Block\Customer\Wishlist\Items', + ['element' => $this->_rootElement->find($this->productItems)] + ); + } + + /** + * Click button 'Add To Cart' + * + * @return void + */ + public function clickAddToCart() + { + $this->_rootElement->find($this->addToCart)->click(); + } + + /** + * Click button 'Update Wish List' + * + * @return void + */ + public function clickUpdateWishlist() + { + $this->_rootElement->find($this->updateButton)->click(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php new file mode 100644 index 0000000000000000000000000000000000000000..9bb947f4b96f7b15d66303cf2fa4430a59b2a55d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php @@ -0,0 +1,56 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Wishlist\Test\Block\Customer\Wishlist; + +use Mtf\Block\Block; +use Mtf\Client\Element; +use Mtf\Client\Element\Locator; + +/** + * Class Items + * Customer wishlist items block on frontend + */ +class Items extends Block +{ + /** + * Product name link selector + * + * @var string + */ + protected $productName = '//a[contains(@class,"product-item-link") and contains(.,"%s")]'; + + /** + * Check that product present in wishlist + * + * @param string $productName + * @return bool + */ + public function isProductPresent($productName) + { + $productNameSelector = sprintf($this->productName, $productName); + + return $this->_rootElement->find($productNameSelector, Locator::SELECTOR_XPATH)->isVisible(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsAbsentInWishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsAbsentInWishlist.php new file mode 100644 index 0000000000000000000000000000000000000000..d5d194f202e86c69d989f4b78f4b5c18f820ac11 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsAbsentInWishlist.php @@ -0,0 +1,90 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Wishlist\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Customer\Test\Page\CustomerAccountIndex; +use Magento\Wishlist\Test\Page\WishlistIndex; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Customer\Test\Page\CustomerAccountLogout; +use Mtf\Fixture\InjectableFixture; + +/** + * Class AssertProductIsAbsentInWishlist + * Assert that product is absent in Wishlist on Frontend + */ +class AssertProductIsAbsentInWishlist extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that product is not present in Wishlist on Frontend + * + * @param CustomerAccountIndex $customerAccountIndex + * @param WishlistIndex $wishlistIndex + * @param InjectableFixture $product + * @param CustomerInjectable $customer + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CustomerAccountLogout $customerAccountLogout + * @return void + */ + public function processAssert( + CustomerAccountIndex $customerAccountIndex, + WishlistIndex $wishlistIndex, + InjectableFixture $product, + CustomerInjectable $customer, + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CustomerAccountLogout $customerAccountLogout + ) { + $productName = $product->getName(); + $customerAccountLogout->open(); + $cmsIndex->getLinksBlock()->openLink('Log In'); + $customerAccountLogin->getLoginBlock()->login($customer); + $customerAccountIndex->open()->getAccountMenuBlock()->openMenuItem("My Wish List"); + \PHPUnit_Framework_Assert::assertFalse( + $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->isProductPresent($productName), + 'Product \'' . $productName . '\' is present in Wishlist on Frontend.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Product is absent in Wishlist on Frontend.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest.php new file mode 100644 index 0000000000000000000000000000000000000000..42dc56f3d80733e268ac5465d73dd66b7a312ef5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest.php @@ -0,0 +1,200 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Wishlist\Test\TestCase; + +use Mtf\Client\Browser; +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Customer\Test\Page\CustomerAccountLogout; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; + +/** + * Test creation for DeleteProductFromCustomerWishlistOnBackend + * + * Test Flow: + * + * Preconditions: + * 1. Create customer + * 2. Create product + * 3. Login to frontend as a customer + * 4. Add product to Wish List + * + * Steps: + * 1. Go to Backend + * 2. Go to Customers > All Customers + * 3. Open the customer + * 4. Open wishlist tab + * 5. Click 'Delete' + * 6. Perform assertions + * + * @group Wishlist_(CS) + * @ZephyrId MAGETWO-27813 + */ +class DeleteProductFromCustomerWishlistOnBackendTest extends Injectable +{ + /** + * Cms index page + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Customer login page + * + * @var CustomerAccountLogin + */ + protected $customerAccountLogin; + + /** + * Product view page + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Page CustomerAccountLogout + * + * @var CustomerAccountLogout + */ + protected $customerAccountLogout; + + /** + * Page of all customer grid + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customer edit page + * + * @var CustomerIndexEdit + */ + protected $customerIndexEdit; + + /** + * Prepare data + * + * @param CustomerInjectable $customer + * @return array + */ + public function __prepare(CustomerInjectable $customer) + { + $customer->persist(); + + return ['customer' => $customer]; + } + + /** + * Injection data + * + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CustomerAccountLogout $customerAccountLogout + * @param CatalogProductView $catalogProductView + * @param CustomerIndex $customerIndex + * @param CustomerIndexEdit $customerIndexEdit + * @return void + */ + public function __inject( + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CustomerAccountLogout $customerAccountLogout, + CatalogProductView $catalogProductView, + CustomerIndex $customerIndex, + CustomerIndexEdit $customerIndexEdit + ) { + $this->cmsIndex = $cmsIndex; + $this->customerAccountLogin = $customerAccountLogin; + $this->customerAccountLogout = $customerAccountLogout; + $this->catalogProductView = $catalogProductView; + $this->customerIndex = $customerIndex; + $this->customerIndexEdit = $customerIndexEdit; + + } + + /** + * Delete product from customer wishlist on backend + * + * @param Browser $browser + * @param CustomerInjectable $customer + * @param FixtureFactory $fixtureFactory + * @param string $product + * @return array + */ + public function test(Browser $browser, CustomerInjectable $customer, FixtureFactory $fixtureFactory, $product) + { + $this->markTestIncomplete('MAGETWO-27949'); + //Preconditions + list($fixture, $dataSet) = explode('::', $product); + $product = $fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); + $product->persist(); + $this->loginCustomer($customer); + $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + $this->catalogProductView->getViewBlock()->addToWishlist(); + + //Steps + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $customerForm = $this->customerIndexEdit->getCustomerForm(); + $customerForm->openTab('wishlist'); + $filter = ['product_name' => $product->getName()]; + $customerForm->getTabElement('wishlist')->getSearchGridBlock()->searchAndDelete($filter); + + return ['product' => $product]; + } + + /** + * Login customer + * + * @param CustomerInjectable $customer + * @return void + */ + protected function loginCustomer(CustomerInjectable $customer) + { + $this->cmsIndex->open(); + if (!$this->cmsIndex->getLinksBlock()->isLinkVisible('Log Out')) { + $this->cmsIndex->getLinksBlock()->openLink('Log In'); + $this->customerAccountLogin->getLoginBlock()->login($customer); + } + } + + /** + * Log out after test + * + * @return void + */ + public function tearDown() + { + $this->customerAccountLogout->open(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest/test.csv b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..1991656cea382ea906b171cf7a658ed1809e9239 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest/test.csv @@ -0,0 +1,3 @@ +"product";"constraint" +"configurableProductInjectable::default";"assertProductIsAbsentInWishlist" +"catalogProductSimple::simple_for_composite_products";"assertProductIsAbsentInWishlist" diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php index 19dcbed29dea9857eabcc26b80aa07a876a405d3..a2b41e6afab78a06bd12791484c772f23a21ba61 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php @@ -24,6 +24,7 @@ namespace Magento\Wishlist\Test\TestCase; +use Mtf\Client\Browser; use Mtf\TestCase\Injectable; use Magento\Cms\Test\Page\CmsIndex; use Magento\Customer\Test\Page\CustomerAccountLogin; @@ -38,11 +39,13 @@ use Magento\Wishlist\Test\Page\WishlistShare; /** * Test Creation for ShareWishlistEntity * + * Test Flow: + * * Preconditions: * 1. Create Customer Account * 2. Create product * - * Test Flow: + * Steps: * 1. Login to frontend as a Customer * 2. Add product to Wish List * 3. Click "Share Wish List" button @@ -157,17 +160,22 @@ class ShareWishlistEntityTest extends Injectable /** * Share wish list * + * @param Browser $browser * @param CustomerInjectable $customer * @param CatalogProductSimple $product * @param array $sharingInfo * @return void */ - public function test(CustomerInjectable $customer, CatalogProductSimple $product, $sharingInfo) - { + public function test( + Browser $browser, + CustomerInjectable $customer, + CatalogProductSimple $product, + array $sharingInfo + ) { //Steps $this->loginCustomer($customer); - $this->catalogProductView->init($product); - $this->catalogProductView->open()->getViewBlock()->addToWishlist(); + $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + $this->catalogProductView->getViewBlock()->addToWishlist(); $this->wishlistIndex->getWishlistBlock()->clickShareWishList(); $this->wishlistShare->getSharingInfoForm()->fillForm($sharingInfo); $this->wishlistShare->getSharingInfoForm()->shareWishlist(); diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/constraint.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/constraint.xml similarity index 88% rename from dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/constraint.xml rename to dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/constraint.xml index 4d3295a76480bf5000dc9c49e06fd77a59811873..3645f787454fb2576e58d300a0eb066718768a53 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/constraint.xml @@ -27,4 +27,7 @@ <assertWishlistShareMessage module="Magento_Wishlist"> <severeness>low</severeness> </assertWishlistShareMessage> + <assertProductIsAbsentInWishlist module="Magento_Wishlist"> + <severeness>low</severeness> + </assertProductIsAbsentInWishlist> </constraint> diff --git a/dev/tests/functional/utils/generate/factory.php b/dev/tests/functional/utils/generate/factory.php index 69fa2cc30fd25233badacad0f920ee54dd3a4de2..279a8d24bcaa17c2e36690e8b9f6c57bac7e148c 100644 --- a/dev/tests/functional/utils/generate/factory.php +++ b/dev/tests/functional/utils/generate/factory.php @@ -21,11 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -umask(0); -$appRoot = dirname(dirname(dirname(dirname(dirname(__DIR__))))); - -require $appRoot . '/app/bootstrap.php'; +require __DIR__ . '/../../../../../app/bootstrap.php'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); $mtfRoot = dirname(dirname(dirname(__FILE__))); $mtfRoot = str_replace('\\', '/', $mtfRoot); @@ -41,6 +39,8 @@ $path .= PATH_SEPARATOR . MTF_BP . '/vendor/magento/mtf'; $path .= PATH_SEPARATOR . MTF_BP . '/vendor/phpunit/phpunit'; set_include_path($path); -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $_SERVER); -$entryPoint->run('Mtf\Util\Generate\Factory'); +$om = $bootstrap->getObjectManager(); +/** @var \Mtf\Util\Generate\Factory $generator */ +$generator = $om->create('Mtf\Util\Generate\Factory'); +$generator->launch(); \Mtf\Util\Generate\GenerateResult::displayResults(); diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php index 0ab3c7d9f6d37413606c1839f1123debe6b8fc64..5f3f878465f87b586f787a748bd1f34327d06915 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php @@ -36,7 +36,7 @@ class Eav public static function setIncrementIdPrefix($entityType, $prefix) { $website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite(); $storeId = $website->getDefaultStore()->getId(); $entityTypeModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index e0ae647b2ac620937f14ea95467cb56f28b2f204..21cc737136486ab5882c214a8d170ae63bb80079 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -157,6 +157,7 @@ class ObjectManagerFactory extends \Magento\Framework\App\ObjectManagerFactory * Override method in while running integration tests to prevent getting Exception * * @param \Magento\Framework\ObjectManager $objectManager + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function configureDirectories(\Magento\Framework\ObjectManager $objectManager) { diff --git a/app/code/Magento/Install/Controller/Wizard/LocalePost.php b/dev/tests/integration/testsuite/Magento/Backend/AdminConfigTest.php similarity index 63% rename from app/code/Magento/Install/Controller/Wizard/LocalePost.php rename to dev/tests/integration/testsuite/Magento/Backend/AdminConfigTest.php index e98107200f2f5a906b1bb1b316bb35f5c1f47554..eabab85f95f8ffa6f143420031ef8c5642155444 100644 --- a/app/code/Magento/Install/Controller/Wizard/LocalePost.php +++ b/dev/tests/integration/testsuite/Magento/Backend/AdminConfigTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,25 +21,28 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class LocalePost extends \Magento\Install\Controller\Wizard +namespace Magento\Backend; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test class for \Magento\Backend\AdminConfig + * + */ +class AdminConfigTest extends \PHPUnit_Framework_TestCase { /** - * Saving localization settings + * Test for setting session name for admin * - * @return void */ - public function execute() + public function testSetSessionNameByConstructor() { - $this->_checkIfInstalled(); - $step = $this->_getWizard()->getStepByName('locale'); - - $data = $this->getRequest()->getPost('config'); - if ($data) { - $this->_session->setLocaleData($data); - } - - $this->getResponse()->setRedirect($step->getNextUrl()); + $sessionName = 'adminHtmlSession'; + $adminConfig = Bootstrap::getObjectManager()->create( + 'Magento\Backend\AdminConfig', + ['sessionName' => $sessionName] + ); + $this->assertSame($sessionName, $adminConfig->getName()); } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Edit/FormTest.php index f215badc3a414bd3a6b39f4e6c8846619a607a9a..720fa4b7d0a67d959a794eb3395de53623376851 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Edit/FormTest.php @@ -118,7 +118,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * @magentoAppIsolation enabled * @magentoDataFixture Magento/Core/_files/store.php * - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\Model\Exception * @expectedExceptionMessage We can't set up a URL rewrite because the product you chose is not associated with */ public function testGetEntityStoresProductStoresException() @@ -133,7 +133,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * @magentoAppIsolation enabled * @magentoDataFixture Magento/Core/_files/store.php * - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\Model\Exception * @expectedExceptionMessage We can't set up a URL rewrite because the product you chose is not associated with */ public function testGetEntityStoresProductCategoryStoresException() @@ -151,7 +151,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * @magentoAppIsolation enabled * @magentoDataFixture Magento/Core/_files/store.php * - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\Model\Exception * @expectedExceptionMessage We can't set up a URL rewrite because the category your chose is not associated with */ public function testGetEntityStoresCategoryStoresException() diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/FormTest.php index f45662a211525a7f571ab0f217cacd36efcdfcd5..5620a13d839c3d8f2bd3d3b4a5c6d3ab185a988d 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/FormTest.php @@ -114,8 +114,8 @@ class FormTest extends \PHPUnit_Framework_TestCase * @magentoAppIsolation enabled * @magentoDataFixture Magento/Core/_files/store.php * - * @expectedException \Magento\Store\Model\Exception - * @expectedExceptionMessage Chosen cms page does not associated with any website. + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Chosen cms page is not associated with any website. */ public function testGetEntityStoresProductStoresException() { diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Edit/FormTest.php index 83dbf152e17a4b6505b3b4f8e61e1569d3566115..c0d0354f2bfb67a43cac28b1f3be1304df52fa59 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Edit/FormTest.php @@ -122,7 +122,7 @@ class FormTest extends \PHPUnit_Framework_TestCase // Check that store value set correctly $defaultStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( true )->getId(); diff --git a/dev/tests/integration/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php b/dev/tests/integration/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..44d019b7f9d713a7f0f3c0702bc66a495f5aec38 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php @@ -0,0 +1,215 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Bundle\Service\V1\Product; + +use Magento\Bundle\Service\V1\Data\Product\Link; +use Magento\Bundle\Service\V1\Data\Product\LinkBuilder; +use Magento\Bundle\Service\V1\Data\Product\Option; +use Magento\Bundle\Service\V1\Data\Product\OptionBuilder; +use Magento\Catalog\Service\V1\Data\Product; +use Magento\Catalog\Service\V1\Data\ProductBuilder; +use Magento\Catalog\Service\V1\Data\ProductMapper; +use Magento\Catalog\Service\V1\ProductServiceInterface; +use Magento\Catalog\Service\V1\Product\ProductLoader; +use Magento\Catalog\Model\Product\Type; +use Magento\Framework\ObjectManager; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Integration test for service layer \Magento\Bundle\Service\V1\Product\BundleProductSaveProcessor + * + */ +class BundleProductSaveProcessorTest extends \PHPUnit_Framework_TestCase +{ + + /** @var ProductMapper */ + protected $productMapper; + + /** @var ObjectManager */ + private $objectManager; + + /** @var ProductLoader */ + private $productLoader; + + /** @var ProductServiceInterface */ + private $productService; + + /** @var ProductBuilder */ + private $productBuilder; + + /** @var LinkBuilder */ + private $linkBuilder; + + /** @var OptionBuilder */ + private $optionBuilder; + + /** @var \Magento\Bundle\Model\Product\Type $productType */ + private $productType; + + /** @var \Magento\Catalog\Model\ProductRepository */ + private $productRepository; + + + /** + * Initialize dependencies + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->productType = $this->objectManager->create('Magento\Bundle\Model\Product\Type'); + $this->productRepository = $this->objectManager->get('Magento\Catalog\Model\ProductRepository'); + $this->productLoader = $this->objectManager->create('Magento\Catalog\Service\V1\Product\ProductLoader'); + $this->productMapper = $this->objectManager->create('Magento\Catalog\Service\V1\Data\ProductMapper'); + $this->productService = $this->objectManager->create('Magento\Catalog\Service\V1\ProductServiceInterface'); + $this->productBuilder = $this->objectManager->create('Magento\Catalog\Service\V1\Data\ProductBuilder'); + $this->linkBuilder = $this->objectManager->create('Magento\Bundle\Service\V1\Data\Product\LinkBuilder'); + $this->optionBuilder = $this->objectManager->create('Magento\Bundle\Service\V1\Data\Product\OptionBuilder'); + + // create existing options + } + + /** + * Create bundle product data for use in creating a new product + * + * @return Product + */ + private function createBundleProductData($skuSuffix) + { + /** @var Link $firstLink */ + $firstLink = $this->linkBuilder + ->setSku('simple') + ->create(); + /** @var Link[] $links */ + $links = array($firstLink); + + /** @var Option $firstOption */ + $firstOption = $this->optionBuilder + ->setProductLinks($links) + ->create(); + + /** @var Product bundleProduct */ + $bundleProduct = $this->productBuilder + ->setSku('sku-z' . $skuSuffix) + ->setName('Fancy Bundle') + ->setTypeId(Type::TYPE_BUNDLE) + ->setPrice(50.00) + ->setCustomAttribute('bundle_product_options', array($firstOption)) + ->setCustomAttribute('price_view', 'test') + ->create(); + + return $bundleProduct; + } + + /** + * Test creation of bundle product through ProductService. + * data fixture below automatically isolates the db + * + * @magentoDataFixture Magento/Catalog/_files/products.php + * @magentoAppIsolation enabled + */ + public function testCreateBundleProduct() + { + /** @var Product $bundleProduct */ + $bundleProduct = $this->createBundleProductData('-create'); + $sku = $this->productService->create($bundleProduct); + $this->assertEquals('sku-z-create', $sku); + + // load and confirm number of options and links + /** @var Product $savedProduct */ + $savedProduct = $this->productService->get($sku); + /** @var Option[] $updatedOptions */ + $savedOptions = $savedProduct->getCustomAttribute('bundle_product_options')->getValue(); + $this->assertTrue(is_array($savedOptions)); + $this->assertEquals(1, count($savedOptions)); + $option = $savedOptions[0]; + $linkedProducts = $option->getProductLinks(); + $this->assertTrue(is_array($linkedProducts)); + $this->assertEquals(1, count($linkedProducts)); + $link = $linkedProducts[0]; + $this->assertEquals('simple', $link->getSku()); + } + + /** + * @magentoDataFixture Magento/Bundle/_files/product.php + * @magentoDataFixture Magento/Catalog/_files/second_product_simple.php + * @magentoAppIsolation enabled + */ + public function testUpdateBundleProduct() + { + // get existing bundle product + $savedProduct = $this->productService->get('bundle-product'); + + /** @var Link $newLink */ + $newLink = $this->linkBuilder + ->setSku('simple2') + ->create(); + /** @var Link[] $links */ + $links = array($newLink); + + /** @var Option $newOption */ + $newOption = $this->optionBuilder + ->setProductLinks($links) + ->create(); + + /** @var Product bundleProduct */ + $updatedBundleProduct = $this->productBuilder + ->populate($savedProduct) + ->setCustomAttribute('bundle_product_options', array($newOption)) + ->setCustomAttribute('price_view', 'test') + ->setCustomAttribute('price', 10) + ->create(); + + $this->assertEquals('bundle-product', $this->productService->update('bundle-product', $updatedBundleProduct)); + $this->productRepository->get('bundle-product')->unsetData('_cache_instance_options_collection'); + + // load and confirm number of links and options + $savedProduct = $this->productService->get('bundle-product'); + /** @var Option[] $updatedOptions */ + $savedOptions = $savedProduct->getCustomAttribute('bundle_product_options')->getValue(); + $this->assertTrue(is_array($savedOptions)); + $this->assertEquals(1, count($savedOptions)); + $option = $savedOptions[0]; + $linkedProducts = $option->getProductLinks(); + $this->assertTrue(is_array($linkedProducts)); + $this->assertEquals(1, count($linkedProducts)); + $link = $linkedProducts[0]; + $this->assertEquals('simple2', $link->getSku()); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Bundle/_files/product.php + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ + public function testDeleteBundleProduct() + { + $existingProduct = $this->productService->get('bundle-product'); + $this->assertNotNull($existingProduct); + $this->assertTrue($this->productService->delete('bundle-product')); + $this->productService->get('bundle-product'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php index ac9337bbe2705d671b51a1310d553accc5528495..570e72a9b5104835a683e11c3b6b7c6348ecbb21 100644 --- a/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php @@ -64,7 +64,7 @@ class ObserverTest extends \Magento\TestFramework\TestCase\AbstractController public function testCaptchaIsRequiredAfterFailedLoginAttempts() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->setCurrentStore( 0 ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php index edf1e97513a7ab92dfb57642468db08f0d703510..50e23a41906fbd17c6f5da952c149b30ea636dd6 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php @@ -65,7 +65,7 @@ class NewTest extends \PHPUnit_Framework_TestCase $this->assertSame(1, array_shift($keys)); $this->assertEquals( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $info[1] ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php index b33bd480889dc2de346c8808d2f90e47952cab86..bae2f771724e75cd29a945594a3f180346d43967 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php @@ -175,8 +175,9 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController protected function _prepareCompareListWithProductNameXss() { - /** @var $visitor \Magento\Log\Model\Visitor */ - $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Log\Model\Visitor'); + /** @var $visitor \Magento\Customer\Model\Visitor */ + $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Framework\Stdlib\DateTime'); @@ -187,7 +188,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController ); $item->setVisitorId($visitor->getId())->setProductId(1)->save(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Log\Model\Visitor' + 'Magento\Customer\Model\Visitor' )->load( $visitor->getId() ); @@ -195,8 +196,9 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController protected function _requireVisitorWithNoProducts() { - /** @var $visitor \Magento\Log\Model\Visitor */ - $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Log\Model\Visitor'); + /** @var $visitor \Magento\Customer\Model\Visitor */ + $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() @@ -205,7 +207,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController $visitor->setSessionId(md5(time()) . md5(microtime()))->setLastVisitAt($dateTime->now())->save(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Log\Model\Visitor' + 'Magento\Customer\Model\Visitor' )->load( $visitor->getId() ); @@ -215,8 +217,9 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController protected function _requireVisitorWithTwoProducts() { - /** @var $visitor \Magento\Log\Model\Visitor */ - $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Log\Model\Visitor'); + /** @var $visitor \Magento\Customer\Model\Visitor */ + $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Framework\Stdlib\DateTime'); @@ -235,7 +238,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController $item->setVisitorId($visitor->getId())->setProductId(2)->save(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Log\Model\Visitor' + 'Magento\Customer\Model\Visitor' )->load( $visitor->getId() ); @@ -271,9 +274,9 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController ->get('Magento\Customer\Model\Session'); $session->setCustomerId(1); - /** @var $visitor \Magento\Log\Model\Visitor */ + /** @var $visitor \Magento\Customer\Model\Visitor */ $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Log\Model\Visitor'); + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Framework\Stdlib\DateTime'); @@ -296,7 +299,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController ->setProductId(2) ->save(); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor') ->load($visitor->getId()); $this->_assertCompareListEquals(array(1, 2)); @@ -316,7 +319,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController $compareItems->useProductItem(true); // important $compareItems->setVisitorId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor')->getId() + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor')->getId() ); $actualProductIds = array(); foreach ($compareItems as $compareItem) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php index 7ccf67c76c489a5322c276e5d91f532eb64803c8..6b90f42df52df560bc9811162dee39696e5d2d63 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php @@ -232,7 +232,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->helper->isUsingStaticUrlsAllowed()); $this->helper->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ); $this->assertTrue($this->helper->isUsingStaticUrlsAllowed()); @@ -253,7 +253,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->helper->isUrlDirectivesParsingAllowed()); $this->helper->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ); $this->assertFalse($this->helper->isUrlDirectivesParsingAllowed()); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/ImageTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/ImageTest.php index 9178ab60097cbb790733c1715a403d87db841100..fb3748e49514268e20ca3a0a90347991e4d82713 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/ImageTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/ImageTest.php @@ -63,7 +63,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase // watermark fixture mkdir( $fixtureMediaDir . '/watermark/stores/' . $objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), 0777, true @@ -71,7 +71,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase copy( "{$fixtureDir}/watermark.jpg", $fixtureMediaDir . '/watermark/stores/' . $objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() . '/watermark.jpg' ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php index 3d03920b91488feefdb7f7c958a9c46201e7408e..3973c36cff917afaf63e854cea86c6dce0a197b6 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php @@ -155,7 +155,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->assertSame( $store, \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore() ); } @@ -164,7 +164,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { $ids = $this->_model->getWebsiteStoreIds(); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(); $this->assertEquals(array($storeId => $storeId), $ids); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php index e292e1ac09d1c7e7fe8eecaddb3ee385b029efe0..283efafec1b98b0c88f3cdc5ce942cd5814fa241 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php @@ -47,12 +47,12 @@ class CategoryImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_oldLogActive = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getConfig( 'dev/log/active' ); $this->_oldExceptionFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getConfig( 'dev/log/exception_file' ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php index 3e30cf4c7b4141baecd9cbe508d657264ad0bfbe..5465f19b8a1cd6285943c4ff38e375778eb14b20 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php @@ -63,8 +63,8 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - /** @var $storeManager \Magento\Store\Model\StoreManagerInterface */ - $storeManager = self::$_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + /** @var $storeManager \Magento\Framework\StoreManagerInterface */ + $storeManager = self::$_objectManager->get('Magento\Framework\StoreManagerInterface'); $this->_store = $storeManager->getStore(); $this->_model = self::$_objectManager->create('Magento\Catalog\Model\Category'); } @@ -139,7 +139,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase /* id from fixture */ $this->assertContains( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $this->_model->getStoreIds() ); @@ -149,7 +149,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $this->_model->getStoreId() ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php index 22ed5a1c7c02644cc66a50caccb909363347691a..d4ad93bc741f008ce5d509be0939214913ad9e40 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php @@ -169,7 +169,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase { $this->assertSame( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore(), $this->_model->getCurrentStore() ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php index 57f39e17b427dd1fed5051a0af3107a3411871ed..cf125e7e7d16a4057f5ae6705f34637f3bf5b19e 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php @@ -97,7 +97,7 @@ class PriceTest extends \PHPUnit_Framework_TestCase $product->getId(), $this->_model->getAttribute()->getId(), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php index 00e57c0ff3055bdcb8d57eaf8ed5ede21a339ab5..16d5e004a7a15baff84565ebda1850d44e000654 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php @@ -159,10 +159,10 @@ class TierpriceTest extends \PHPUnit_Framework_TestCase public function testAfterSaveEmpty() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->setCurrentStore( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( \Magento\Store\Model\Store::DEFAULT_STORE_ID ) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php index c145e1483017878501841e1f3eb5390efebb164e..f664846e97d41f9dafab54f2b33c9c315dfcf5da 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php @@ -36,7 +36,7 @@ class ListCompareTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ protected $_visitor; @@ -49,7 +49,7 @@ class ListCompareTest extends \PHPUnit_Framework_TestCase $this->_session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Customer\Model\Session'); $this->_visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Log\Model\Visitor'); + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Framework\Stdlib\DateTime'); @@ -57,7 +57,7 @@ class ListCompareTest extends \PHPUnit_Framework_TestCase ->setLastVisitAt($dateTime->now()) ->save(); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Catalog\Model\Product\Compare\ListCompare', ['logVisitor' => $this->_visitor]); + ->create('Magento\Catalog\Model\Product\Compare\ListCompare', ['customerVisitor' => $this->_visitor]); } protected function tearDown() diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductExternalTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductExternalTest.php index 452afac3beb536eb6130b60290754f89b8a12c0e..ea43aa2b92d0becbad6ad217d352ad7b11ca12af 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductExternalTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductExternalTest.php @@ -49,7 +49,7 @@ class ProductExternalTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $this->_model->getStoreId() ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php index ecd81605f2585b32681f8d5861a69ec93bcfe12f..ce6fc4da174040062f3d0cdbc9a4c068308e15cb 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php @@ -218,7 +218,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected function _undo($duplicate) { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setId( \Magento\Store\Model\Store::DEFAULT_STORE_ID ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products.php index f19bccb25912f4e067b418d2fde1ec2f4c9e1d35..0e68315937c140cd6f5ece4e4034bb906073645d 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/products.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products.php @@ -23,37 +23,26 @@ */ /** @var $product \Magento\Catalog\Model\Product */ -$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); -$product->setTypeId( - 'simple' -)->setId( - 1 -)->setAttributeSetId( - 4 -)->setWebsiteIds( - array(1) -)->setName( - 'Simple Product' -)->setSku( - 'simple' -)->setPrice( - 10 -)->setMetaTitle( - 'meta title' -)->setMetaKeyword( - 'meta keyword' -)->setMetaDescription( - 'meta description' -)->setVisibility( - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH -)->setStatus( - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED -)->setStockData( - array('use_config_manage_stock' => 0) -)->save(); +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product + ->setTypeId('simple') + ->setId(1) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Simple Product') + ->setSku('simple') + ->setPrice(10) + ->setMetaTitle('meta title') + ->setMetaKeyword('meta keyword') + ->setMetaDescription('meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData(array('use_config_manage_stock' => 0)) + ->save(); + +$customDesignProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product', array('data' => $product->getData())); -$customDesignProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\Product', - array('data' => $product->getData()) -); $customDesignProduct->setId(2)->setCustomDesign('Magento/blank')->save(); + diff --git a/app/code/Magento/Install/Controller/Wizard/BeginPost.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/second_product_simple.php similarity index 56% rename from app/code/Magento/Install/Controller/Wizard/BeginPost.php rename to dev/tests/integration/testsuite/Magento/Catalog/_files/second_product_simple.php index 098c2501a2cf9da768191311c8c23462f0026ba1..4d2c4684a76b1fb50208b229749512e3c000c57c 100644 --- a/app/code/Magento/Install/Controller/Wizard/BeginPost.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/second_product_simple.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,24 +21,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class BeginPost extends \Magento\Install\Controller\Wizard -{ - /** - * Process begin step POST data - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); +/** @var $product2 \Magento\Catalog\Model\Product */ +$product2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product2 + ->setTypeId('simple') + ->setId(6) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Simple Product2') + ->setSku('simple2') + ->setPrice(10) + ->setMetaTitle('meta title2') + ->setMetaKeyword('meta keyword2') + ->setMetaDescription('meta description2') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData(array('use_config_manage_stock' => 0)) + ->save(); - $agree = $this->getRequest()->getPost('agree'); - if ($agree && ($step = $this->_getWizard()->getStepByName('begin'))) { - $this->getResponse()->setRedirect($step->getNextUrl()); - } else { - $this->_redirect('install'); - } - } -} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php b/dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php index d3ee0fbc146db2531cdad01988557d78806b2a11..b7b19ccb7bef5efca8341a7db1881246b1aba796 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php @@ -44,7 +44,7 @@ $productOne->setId( )->setAttributeSetId( 4 )->setWebsiteIds( - array($obectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId()) + array($obectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId()) )->setSku( 'simple_product_1' )->setName( @@ -85,7 +85,7 @@ $productTwo->setId( )->setAttributeSetId( 4 )->setWebsiteIds( - array($obectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId()) + array($obectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId()) )->setSku( 'simple_product_2' )->setName( diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 5e4747d7632a06fd2cc9ea0ec7909e6f62f616c3..d58d379f96635d9923ef96203722250805fbf843 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -764,7 +764,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase $product->load($id); $this->assertEquals('1', $product->getHasOptions()); - $objectManager->get('Magento\Store\Model\StoreManagerInterface')->setCurrentStore('fixturestore'); + $objectManager->get('Magento\Framework\StoreManagerInterface')->setCurrentStore('fixturestore'); /** @var \Magento\Catalog\Model\Product $simpleProduct */ $simpleProduct = $objectManager->create('Magento\Catalog\Model\Product'); diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Helper/DataTest.php index a519a4f0a5b787deb18c82291ce184946b3e8d95..90444c6427fff7cfd1aa682f48c0a1a3941a2e2c 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Helper/DataTest.php @@ -75,7 +75,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $objectManager->get('Magento\CatalogSearch\Model\QueryFactory'), $objectManager->get('Magento\Framework\Escaper'), $objectManager->get('Magento\Framework\Filter\FilterManager'), - $objectManager->get('Magento\Store\Model\StoreManagerInterface') + $objectManager->get('Magento\Framework\StoreManagerInterface') ) ); $catalogSearchHelper->expects( diff --git a/dev/tests/integration/testsuite/Magento/Centinel/CreateOrderTest.php b/dev/tests/integration/testsuite/Magento/Centinel/CreateOrderTest.php index e32afba7425f241844915710c80830f192ff894f..bb76f02b78aef5d0b8de3583cde0a151eb36446c 100644 --- a/dev/tests/integration/testsuite/Magento/Centinel/CreateOrderTest.php +++ b/dev/tests/integration/testsuite/Magento/Centinel/CreateOrderTest.php @@ -53,7 +53,7 @@ class CreateOrderTest extends \Magento\Backend\Utility\Controller ); $quote = $order->addProducts(array(1 => array('qty' => 1)))->getQuote(); $defaultStoreId = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( 'default' )->getId(); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php index 7b3cc4b2839396397949af83f57890c19bcbda8c..5f3835fa99a75c3e1bc383bb275d03b229d66ac7 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -401,7 +401,8 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** Execute SUT */ $result = $this->_model->saveBilling($customerData, $customerAddressId); $validationErrors = array( - '"First Name" is a required value.' + '"First Name" is a required value.', + '"First Name" length must be equal or greater than 1 characters.' ); $this->assertEquals( array('error' => 1, 'message' => $validationErrors), @@ -513,7 +514,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** Execute SUT */ $result = $this->_model->saveBilling($customerData, $customerAddressId); - $validationErrors = 'Please correct this email address: "invalidemail".'; + $validationErrors = '"Email" is not a valid email address.'; $this->assertEquals( array('error' => -1, 'message' => $validationErrors), $result, diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent.php index 35d69af53759a9085c3894cb9c420cf4e912f5ad..60daa59df93830fa825fbc9c47bc0214494c88b0 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent.php @@ -32,7 +32,7 @@ $data = array( 'is_active' => true, 'website_ids' => array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getWebsiteId() ), 'customer_group_ids' => array(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID), diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php index abed80acca2fdc6605edd149b5b655301075cbc3..19250bb5ea0a7820fe4a6430bea3f923707998c3 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php @@ -42,13 +42,12 @@ class RouterTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Framework\Event\ObserverFactory', array(), array(), '', false) ), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\UrlInterface'), - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\StateInterface'), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Cms\Model\PageFactory'), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' ), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' ) ); } diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/block.php b/dev/tests/integration/testsuite/Magento/Cms/_files/block.php index 4bb701e9a2406fc005659bd7d6f442a67994956f..ff51d31ef82cda4fbdbdeae2bb2ad6218baa9bd3 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/_files/block.php +++ b/dev/tests/integration/testsuite/Magento/Cms/_files/block.php @@ -39,7 +39,7 @@ $block->setTitle( )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php index 4a2493c24e7378bf8b647c0a373505bd8f4d63fd..f64a5ac189e7fa940f7db5022db915f7a62b9488 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php @@ -54,7 +54,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\View\DesignInterface' ); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId(); // fixture design_change $designChange = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( @@ -121,7 +121,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase ->create('Magento\Framework\Stdlib\DateTime'); $date = $dateTime->now(true); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId(); // fixture design_change @@ -184,7 +184,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase } $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $storeCode ); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Layout/UpdateTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Layout/UpdateTest.php index 6036cfa367bf5231917ac54c83b9b6ecade7a566..38255371ea485cdda126bd604d5b62e2dbd70606 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Layout/UpdateTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Layout/UpdateTest.php @@ -51,7 +51,7 @@ class UpdateTest extends \PHPUnit_Framework_TestCase 'test_handle', $theme, \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore() ); $this->assertEquals('not_temporary', $result); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php index 2e1ffc286c3135a1b43a54ad60bc800dc3afb7fa..77409fe8521aff511fd45fec20058d4a3d83e671 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php @@ -148,7 +148,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase public function testGetConfigurationDesignThemeStore() { $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(); $this->assertEquals('one', $this->_model->getConfigurationDesignTheme()); $this->assertEquals('one', $this->_model->getConfigurationDesignTheme(null, array('store' => $storeId))); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/design_change.php b/dev/tests/integration/testsuite/Magento/Core/_files/design_change.php index c6bb52325693a24ec73eec3128cdfcc704a32b6a..482c141a72c52cec7f2e4a4bae03f098b88c7700 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/design_change.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/design_change.php @@ -23,7 +23,7 @@ */ $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId(); /** @var $change \Magento\Core\Model\Design */ $change = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Core\Model\Design'); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/design_change_timezone.php b/dev/tests/integration/testsuite/Magento/Core/_files/design_change_timezone.php index f941c7799d62d5ebee6ae25c4c71f12a88e665f5..ce6f9360d452d6a881a6e7dbdebb9f13b96f1466 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/design_change_timezone.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/design_change_timezone.php @@ -32,7 +32,7 @@ $designChanges = array( ); foreach ($designChanges as $designChangeData) { $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $designChangeData['store'] )->getId(); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php b/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php index 4a3c0e3491f35056b764fb8208dc139765d2bce2..a8ff0e3b33f868e4e8c44b03dc8a4d046de2be0e 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php @@ -49,5 +49,5 @@ $store->save(); /* Refresh stores memory cache */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/store.php b/dev/tests/integration/testsuite/Magento/Core/_files/store.php index 77bcb314ef9924166b323793ea6659d26ab88d5c..f9cc8d29b3537f02105bfdb47667f3a328aa83a8 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/store.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/store.php @@ -24,10 +24,10 @@ $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); $websiteId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getId(); $groupId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getDefaultGroupId(); $store->setCode( 'fixturestore' @@ -46,5 +46,5 @@ $store->save(); /* Refresh stores memory cache */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php index b4733b969f928d65cf1b2cbf39b92ef66f2739b6..676fc88037124ea4526cc11745884f40cea3828f 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php @@ -40,7 +40,7 @@ class CartTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Registry */ private $_coreRegistry; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ private $_storeManager; /** @var Cart */ diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6284845a4b6b9aa4f34d20507971bb7eac2f0aef --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php @@ -0,0 +1,276 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; +use Magento\Customer\Service\V1\Data\Customer; +use Magento\Customer\Service\V1\Data\CustomerBuilder; + +/** + * Magento\Customer\Block\Adminhtml\Edit\Tab\View + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @magentoAppArea adminhtml + */ +class PersonalInfoTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Backend\Block\Template\Context */ + private $_context; + + /** @var \Magento\Framework\Registry */ + private $_coreRegistry; + + /** @var CustomerBuilder */ + private $_customerBuilder; + + /** @var CustomerAccountServiceInterface */ + private $_customerAccountService; + + /** @var CustomerGroupServiceInterface */ + private $_groupService; + + /** @var \Magento\Framework\StoreManagerInterface */ + private $_storeManager; + + /** @var \Magento\Framework\ObjectManager */ + private $_objectManager; + + /** @var PersonalInfo */ + private $_block; + + /** + * @var \Magento\Framework\Stdlib\DateTime + */ + protected $dateTime; + + public function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $this->_storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); + $this->_context = $this->_objectManager->get( + 'Magento\Backend\Block\Template\Context', + array('storeManager' => $this->_storeManager) + ); + + $this->_customerBuilder = $this->_objectManager->get('Magento\Customer\Service\V1\Data\CustomerBuilder'); + $this->_coreRegistry = $this->_objectManager->get('Magento\Framework\Registry'); + $this->_customerAccountService = $this->_objectManager->get( + 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' + ); + $this->_groupService = $this->_objectManager->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); + $this->dateTime = $this->_objectManager->get('\Magento\Framework\Stdlib\DateTime'); + + $this->_block = $this->_objectManager->get( + 'Magento\Framework\View\LayoutInterface' + )->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo', + '', + array( + 'context' => $this->_context, + 'groupService' => $this->_groupService, + 'registry' => $this->_coreRegistry + ) + ); + } + + public function tearDown() + { + $this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetCustomer() + { + $this->assertEquals($this->_loadCustomer(), $this->_block->getCustomer()); + } + + public function testGetCustomerEmpty() + { + $this->assertEquals($this->_createCustomer(), $this->_block->getCustomer()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetGroupName() + { + $groupName = $this->_groupService->getGroup($this->_loadCustomer()->getGroupId())->getCode(); + $this->assertEquals($groupName, $this->_block->getGroupName()); + } + + public function testGetGroupNameNull() + { + $this->_createCustomer(); + $this->assertNull($this->_block->getGroupName()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetCreateDate() + { + $createdAt = $this->_block->formatDate( + $this->_loadCustomer()->getCreatedAt(), + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, + true + ); + $this->assertEquals($createdAt, $this->_block->getCreateDate()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetStoreCreateDate() + { + $customer = $this->_loadCustomer(); + $date = $this->_context->getLocaleDate()->scopeDate( + $customer->getStoreId(), + $this->dateTime->toTimestamp($customer->getCreatedAt()), + true + ); + $storeCreateDate = $this->_block->formatDate( + $date, + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, + true + ); + $this->assertEquals($storeCreateDate, $this->_block->getStoreCreateDate()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetStoreCreateDateTimezone() + { + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface $defaultTimeZonePath + */ + $defaultTimeZonePath = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->getDefaultTimezonePath(); + $timezone = $this->_context->getScopeConfig()->getValue( + $defaultTimeZonePath, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->_loadCustomer()->getStoreId() + ); + $this->assertEquals($timezone, $this->_block->getStoreCreateDateTimezone()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testIsConfirmedStatusConfirmed() + { + $this->_loadCustomer(); + $this->assertEquals('Confirmed', $this->_block->getIsConfirmedStatus()); + } + + /** + * @magentoDbIsolation enabled + */ + public function testIsConfirmedStatusConfirmationIsNotRequired() + { + /** @var Customer $customer */ + $customer = $this->_customerBuilder->setConfirmation( + true + )->setFirstname( + 'firstname' + )->setLastname( + 'lastname' + )->setEmail( + 'email@email.com' + )->create(); + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + /** @var \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder */ + $customerDetailsBuilder = $objectManager->create('Magento\Customer\Service\V1\Data\CustomerDetailsBuilder'); + $customerDetails = $customerDetailsBuilder->setCustomer($customer)->create(); + $customer = $this->_customerAccountService->createCustomer($customerDetails); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); + $this->assertEquals('Confirmation Not Required', $this->_block->getIsConfirmedStatus()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetCreatedInStore() + { + $storeName = $this->_storeManager->getStore($this->_loadCustomer()->getStoreId())->getName(); + $this->assertEquals($storeName, $this->_block->getCreatedInStore()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + */ + public function testGetBillingAddressHtml() + { + $this->_loadCustomer(); + $html = $this->_block->getBillingAddressHtml(); + $this->assertContains('John Smith<br/>', $html); + $this->assertContains('Green str, 67<br />', $html); + $this->assertContains('CityM, Alabama, 75477<br/>', $html); + } + + public function testGetBillingAddressHtmlNoDefaultAddress() + { + $this->_createCustomer(); + $this->assertEquals( + __('The customer does not have default billing address.'), + $this->_block->getBillingAddressHtml() + ); + } + + /** + * @return Customer + */ + private function _createCustomer() + { + /** @var \Magento\Customer\Service\V1\Data\Customer $customer */ + $customer = $this->_customerBuilder->setFirstname( + 'firstname' + )->setLastname( + 'lastname' + )->setEmail( + 'email@email.com' + )->create(); + $data = array('account' => $customer->__toArray()); + $this->_context->getBackendSession()->setCustomerData($data); + return $customer; + } + + /** + * @return Customer + */ + private function _loadCustomer() + { + $customer = $this->_customerAccountService->getCustomer(1); + $data = array('account' => $customer->__toArray()); + $this->_context->getBackendSession()->setCustomerData($data); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); + return $customer; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php index d896b8a20933df0cd36d058418ec72132c46f4dd..befb58195da3be0500ec9017e9405b4f9095f8eb 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php @@ -49,10 +49,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase /** @var CustomerAccountServiceInterface */ private $_customerAccountService; - /** @var CustomerGroupServiceInterface */ - private $_groupService; - - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ private $_storeManager; /** @var \Magento\Framework\ObjectManager */ @@ -61,11 +58,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase /** @var View */ private $_block; - /** - * @var \Magento\Framework\Stdlib\DateTime - */ - protected $_dateTime; - public function setUp() { $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -81,7 +73,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase $this->_customerAccountService = $this->_objectManager->get( 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' ); - $this->_groupService = $this->_objectManager->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $this->_block = $this->_objectManager->get( 'Magento\Framework\View\LayoutInterface' @@ -90,12 +81,9 @@ class ViewTest extends \PHPUnit_Framework_TestCase '', array( 'context' => $this->_context, - 'groupService' => $this->_groupService, 'registry' => $this->_coreRegistry ) ); - - $this->_dateTime = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime'); } public function tearDown() @@ -103,153 +91,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase $this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); } - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetCustomer() - { - $this->assertEquals($this->_loadCustomer(), $this->_block->getCustomer()); - } - - public function testGetCustomerEmpty() - { - $this->assertEquals($this->_createCustomer(), $this->_block->getCustomer()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetGroupName() - { - $groupName = $this->_groupService->getGroup($this->_loadCustomer()->getGroupId())->getCode(); - $this->assertEquals($groupName, $this->_block->getGroupName()); - } - - public function testGetGroupNameNull() - { - $this->_createCustomer(); - $this->assertNull($this->_block->getGroupName()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetCreateDate() - { - $createdAt = $this->_block->formatDate( - $this->_loadCustomer()->getCreatedAt(), - \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, - true - ); - $this->assertEquals($createdAt, $this->_block->getCreateDate()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetStoreCreateDate() - { - $customer = $this->_loadCustomer(); - $date = $this->_context->getLocaleDate() - ->scopeDate($customer->getStoreId(), $this->_dateTime->toTimestamp($customer->getCreatedAt()), true); - $storeCreateDate = $this->_block->formatDate( - $date, - \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, - true - ); - $this->assertEquals($storeCreateDate, $this->_block->getStoreCreateDate()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetStoreCreateDateTimezone() - { - /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface $defaultTimeZonePath - */ - $defaultTimeZonePath = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\TimezoneInterface') - ->getDefaultTimezonePath(); - $timezone = $this->_context->getScopeConfig()->getValue( - $defaultTimeZonePath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->_loadCustomer()->getStoreId() - ); - $this->assertEquals($timezone, $this->_block->getStoreCreateDateTimezone()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testIsConfirmedStatusConfirmed() - { - $this->_loadCustomer(); - $this->assertEquals('Confirmed', $this->_block->getIsConfirmedStatus()); - } - - /** - * @magentoDbIsolation enabled - */ - public function testIsConfirmedStatusConfirmationIsNotRequired() - { - /** @var Customer $customer */ - $customer = $this->_customerBuilder->setConfirmation( - true - )->setFirstname( - 'firstname' - )->setLastname( - 'lastname' - )->setEmail( - 'email@email.com' - )->create(); - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder */ - $customerDetailsBuilder = $objectManager->create('Magento\Customer\Service\V1\Data\CustomerDetailsBuilder'); - $customerDetails = $customerDetailsBuilder->setCustomer($customer)->create(); - $customer = $this->_customerAccountService->createCustomer($customerDetails); - $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); - $this->assertEquals('Confirmation Not Required', $this->_block->getIsConfirmedStatus()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetCreatedInStore() - { - $storeName = $this->_storeManager->getStore($this->_loadCustomer()->getStoreId())->getName(); - $this->assertEquals($storeName, $this->_block->getCreatedInStore()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetStoreId() - { - $this->assertEquals($this->_loadCustomer()->getStoreId(), $this->_block->getStoreId()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_address.php - */ - public function testGetBillingAddressHtml() - { - $this->_loadCustomer(); - $html = $this->_block->getBillingAddressHtml(); - $this->assertContains('John Smith<br/>', $html); - $this->assertContains('Green str, 67<br />', $html); - $this->assertContains('CityM, Alabama, 75477<br/>', $html); - } - - public function testGetBillingAddressHtmlNoDefaultAddress() - { - $this->_createCustomer(); - $this->assertEquals( - __('The customer does not have default billing address.'), - $this->_block->getBillingAddressHtml() - ); - } - public function testGetTabLabel() { $this->assertEquals(__('Customer View'), $this->_block->getTabLabel()); diff --git a/dev/tests/integration/testsuite/Magento/Log/Model/VisitorTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Log/Model/VisitorTest.php rename to dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php index 32a078a66c8e7e81162822ddc536a657cf83537c..f7ec83eb8bd87c6c03aaba2d7974e8e93f96b7f7 100644 --- a/dev/tests/integration/testsuite/Magento/Log/Model/VisitorTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Log\Model; +namespace Magento\Customer\Model; use Magento\TestFramework\Helper\Bootstrap; @@ -33,8 +33,8 @@ class VisitorTest extends \PHPUnit_Framework_TestCase */ public function testBindCustomerLogin() { - /** @var \Magento\Log\Model\Visitor $visitor */ - $visitor = Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor'); + /** @var \Magento\Customer\Model\Visitor $visitor */ + $visitor = Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor'); $visitor->unsCustomerId(); $visitor->unsDoCustomerLogin(); @@ -56,8 +56,8 @@ class VisitorTest extends \PHPUnit_Framework_TestCase */ public function testBindCustomerLogout() { - /** @var \Magento\Log\Model\Visitor $visitor */ - $visitor = Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor'); + /** @var \Magento\Customer\Model\Visitor $visitor */ + $visitor = Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor'); $this->_loginCustomer('customer@example.com', 'password'); $visitor->setCustomerId(1); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php index 59ee976b74ab3f2f2cb3cd97083545b5f8f30c9e..328bfeb7f0246e81ec671cd8ee74b802c1ed22c4 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -1502,8 +1502,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase */ public function getValidEmailDataProvider() { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface'); $defaultWebsiteId = $storeManager->getStore()->getWebsiteId(); return [ 'valid email' => ['customer@example.com', null], diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerGroupServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerGroupServiceTest.php index 90053a700c367da98f381026af0fa75f260cc7f8..572f8770bf19c8173a4c5b0e509638bfb3379723 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerGroupServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerGroupServiceTest.php @@ -194,8 +194,8 @@ class CustomerGroupServiceTest extends \PHPUnit_Framework_TestCase */ public function getDefaultGroupDataProvider() { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface'); $defaultStoreId = $storeManager->getStore()->getId(); return [ 'no store id' => [['id' => 1, 'code' => 'General', 'tax_class_id' => 3], null], @@ -207,8 +207,8 @@ class CustomerGroupServiceTest extends \PHPUnit_Framework_TestCase * @magentoDataFixture Magento/Core/_files/second_third_store.php */ public function testGetDefaultGroupWithNonDefaultStoreId() - { /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface'); + { /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface'); $nonDefaultStore = $storeManager->getStore('secondstore'); $nonDefaultStoreId = $nonDefaultStore->getId(); /** @var \Magento\Framework\App\MutableScopeConfig $scopeConfig */ diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_rollback.php new file mode 100644 index 0000000000000000000000000000000000000000..023157234cd472fc72d38b99eecbce30e76b9dd1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_rollback.php @@ -0,0 +1,26 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Attribute'); +$model->load('address_user_attribute', 'attribute_code')->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php index 420b91aeb304df05c32eab51ae693dd78e25743b..f62f77505a2d7c7c77eb23492daaa289ce1ef846 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php @@ -44,6 +44,8 @@ $model->setName( 'text' )->setFrontendLabel( FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_FRONTEND_LABEL +)->setSortOrder( + 1221 ); $model->save(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer_rollback.php new file mode 100644 index 0000000000000000000000000000000000000000..c3c1f261dcaa68a9c928363f961ed098b026128c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer_rollback.php @@ -0,0 +1,26 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +$model =\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Attribute'); +$model->load('user_attribute', 'attribute_code')->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php b/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php index 503e61b801dde3737d9291addfd4549bfdaff013..d9906b263ccef7d78f4d9addaab46a49800e9321 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php @@ -57,7 +57,7 @@ $quoteItem = $quote->setCustomerId( 1 )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test01' diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/AddressTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/AddressTest.php index c4e5f27ade947c1a2978c7f301a7904788d25800..9454488506859735cc8f6764ea0fbae24d9c149c 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/AddressTest.php @@ -51,7 +51,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase ); $websites = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsites( true ); diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php index 6db81937cd7a4183a921983b8fcd6da52c15b24c..8713392f0e86c43b5d37827d1cbdac9170a41bef 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php @@ -200,7 +200,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase 'email' => 'example.com', 'created_at' => array($createdAtDate, ''), 'store_id' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) ); diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php index ba9abad609030e8ba0ba835c6c963ec87414bf17..57e9706eeac50bfea5337a49c36c14eeac02756a 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php @@ -83,7 +83,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase $this->assertSame($filter, $this->_model->getTemplateFilter()); $this->assertEquals( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $filter->getStoreId() ); @@ -124,7 +124,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase array( 'area' => 'frontend', 'store' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( 'fixturestore' )->getId() @@ -190,7 +190,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase array( 'area' => 'frontend', 'store' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( 'fixturestore' )->getId() @@ -230,7 +230,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase public function setDesignConfigExceptionDataProvider() { $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId(); + ->get('Magento\Framework\StoreManagerInterface')->getStore()->getId(); return array( array(array()), array(array('area' => 'frontend')), diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/FilesystemTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/FilesystemTest.php index e797f4ca93d2c57ad28c15cde79ef53309e2a74a..f3a996c6b9614012661b6f1ed0ce802e086d4d65 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/App/FilesystemTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/App/FilesystemTest.php @@ -25,8 +25,6 @@ */ namespace Magento\Framework\App; -use Magento\TestFramework\Helper\Bootstrap; - /** * Class FilesystemTest * Test for Magento\Framework\App\Filesystem class @@ -41,7 +39,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesystem = Bootstrap::getObjectManager()->create('Magento\Framework\App\Filesystem'); + $this->filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Framework\App\Filesystem'); } /** diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/FrontController/Plugin/InstallTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/FrontController/Plugin/InstallTest.php deleted file mode 100644 index d060656055f104053075412283e45f3e88074ea6..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/App/FrontController/Plugin/InstallTest.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\FrontController\Plugin; - -class InstallTest extends \Magento\TestFramework\TestCase\AbstractController -{ - /** - * @var \Magento\Framework\ObjectManager - */ - protected $_objectManager; - - /** - * @var \Magento\Framework\Module\Setup - */ - protected $_model; - - protected function setUp() - { - $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Module\Setup', - array('resourceName' => 'default_setup', 'moduleName' => 'Magento_Core') - ); - } - - public function testApplyAllDataUpdates() - { - /*reset versions*/ - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Module\ResourceInterface' - )->setDbVersion( - 'adminnotification_setup', - false - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Module\ResourceInterface' - )->setDataVersion( - 'adminnotification_setup', - false - ); - $this->_model->deleteTableRow('core_resource', 'code', 'adminnotification_setup'); - $this->_model->getConnection()->dropTable($this->_model->getTable('adminnotification_inbox')); - $this->_model->getConnection()->dropTable($this->_model->getTable('admin_system_messages')); - /** @var \Magento\Framework\Cache\FrontendInterface $cache */ - $cache = $this->_objectManager->get('Magento\Framework\App\Cache\Type\Config'); - $cache->clean(); - - try { - /* This triggers plugin to be executed */ - $this->dispatch('index/index'); - } catch (\Exception $e) { - $this->fail("Impossible to continue other tests, because database is broken: {$e}"); - } - - try { - $tableData = $this->_model->getConnection()->describeTable( - $this->_model->getTable('adminnotification_inbox') - ); - $this->assertNotEmpty($tableData); - } catch (\Exception $e) { - $this->fail("Impossible to continue other tests, because database is broken: {$e}"); - } - - $this->assertNotEmpty( - $this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'version') - ); - $this->assertNotEmpty( - $this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'data_version') - ); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php b/dev/tests/integration/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e95a00a5f96339f04ff0b6c6ab24f8dc5f07824b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Module\Plugin; + +class DbStatusValidatorTest extends \Magento\TestFramework\TestCase\AbstractController +{ + public function testValidationUpToDateDb() + { + $this->dispatch('index/index'); + } + + public function testValidationOutdatedDb() + { + $resourceName = 'adminnotification_setup'; + /*reset versions*/ + /** @var \Magento\Framework\Module\ResourceInterface $resource */ + $resource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Framework\Module\ResourceInterface' + ); + $dbVersion = $resource->getDbVersion($resourceName); + $dbDataVersion = $resource->getDataVersion($resourceName); + try { + $resource->setDbVersion($resourceName, '0.1'); + $resource->setDataVersion($resourceName, '0.1'); + /** @var \Magento\Framework\Cache\FrontendInterface $cache */ + $cache = $this->_objectManager->get('Magento\Framework\App\Cache\Type\Config'); + $cache->clean(); + + try { + /* This triggers plugin to be executed */ + $this->dispatch('index/index'); + } catch (\Magento\Framework\Module\Exception $e) { + if ($e->getMessage() != 'Looks like database is outdated. Please, use setup tool to perform update') { + $failureMessage = "DB status validation doesn't work properly. Caught exception message is '" + . $e->getMessage() ."'"; + } + } + } catch (\Exception $e) { + $failureMessage = "Impossible to continue other tests, because database is broken: {$e}"; + } + + $resource->setDbVersion($resourceName, $dbVersion); + $resource->setDataVersion($resourceName, $dbDataVersion); + + if (isset($failureMessage)) { + $this->fail($failureMessage); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_merged.xml b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_merged.xml index e3a7e38e9d5c10a3c4679f171be78f5d79933213..5917a1bee538f6c0baf90573c3ef759acccb7a00 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_merged.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_merged.xml @@ -23,9 +23,9 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\UpdaterOne" /> - <preference for="Magento\Framework\Module\UpdaterInterfaceTwo" type="Magento\Framework\Module\UpdaterTwo"/> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\Framework\Module\SomeInterface" type="Magento\Framework\Module\ClassOne" /> + <preference for="Magento\Framework\Module\SomeInterfaceTwo" type="Magento\Framework\Module\ClassTwo" /> <type name="Magento\Framework\App\Arguments\Loader" shared="false"> <arguments> <argument name="customFile" xsi:type="init_parameter">Magento\Framework\App\Arguments\Loader::PARAM_CUSTOM_FILE</argument> diff --git a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_one.xml b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_one.xml index a838cf287834b78d9394fe8cdd6a6005f7e192ac..944d99020e00a1b86c2fa5c1b0149b523b65a738 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_one.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_one.xml @@ -23,8 +23,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\Updater" /> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\Framework\Module\SomeInterface" type="Magento\Framework\Module\ClassOne" /> <type name="Magento\Framework\App\Arguments\Loader"> <arguments> <argument name="customFile" xsi:type="init_parameter">Magento\Framework\App\Arguments\Loader::PARAM_CUSTOM_FILE</argument> diff --git a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_two.xml b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_two.xml index ce4dd60f27287276895b436fa30512d4fe8e8fc1..bf599564574bc50966bef6da1661b7390330de52 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_two.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_two.xml @@ -23,9 +23,9 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Framework\Module\UpdaterInterfaceTwo" type="Magento\Framework\Module\UpdaterTwo" /> - <preference for="Magento\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\UpdaterOne" /> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\Framework\Module\SomeInterface" type="Magento\Framework\Module\ClassOne" /> + <preference for="Magento\Framework\Module\SomeInterfaceTwo" type="Magento\Framework\Module\ClassTwo" /> <type name="Magento\Framework\App\Arguments\Loader" shared="false"> <arguments> <argument name="customFile" xsi:type="init_parameter">Magento\Framework\App\Arguments\Loader::PARAM_CUSTOM_FILE</argument> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7c63a2eb0c46e641d68a0d0c19c3c4535b5211ed --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php @@ -0,0 +1,324 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\TestFramework\Helper\Bootstrap; + +class AdapterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Adapter + */ + private $adapter; + + /** + * @var \Magento\Framework\Search\RequestFactory + */ + private $requestFactory; + + /** + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + + /** @var \Magento\Framework\Search\Request\Config\Converter $converter */ + $converter = $this->objectManager->create('Magento\Framework\Search\Request\Config\Converter'); + + $document = new \DOMDocument(); + $document->load(__DIR__ . '/../../_files/requests.xml'); + $requestConfig = $converter->convert($document); + + /** @var \Magento\Framework\Search\Request\Config $config */ + $config = $this->objectManager->create('Magento\Framework\Search\Request\Config'); + $config->merge($requestConfig); + + /** @var \Magento\Framework\Search\RequestFactory $requestFactory */ + $this->requestFactory = $this->objectManager->create( + 'Magento\Framework\Search\RequestFactory', + ['config' => $config] + ); + + $this->adapter = $this->objectManager->create('Magento\Framework\Search\Adapter\Mysql\Adapter'); + } + + /** + * Sample test + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testMatchQuery() + { + $bindValues = [ + '%request.title%' => 'socks', + ]; + $requestName = 'one_match'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(1, $queryResponse->count()); + } + + /** + * Sample test + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testMatchQueryFilters() + { + $bindValues = [ + '%request.title%' => 'socks', + '%pidm_from%' => 1, + '%pidm_to%' => 3, + '%pidsh%' => 4 + ]; + $requestName = 'one_match_filters'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(1, $queryResponse->count()); + } + + /** + * Range filter test with all fields filled + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testRangeFilterWithAllFields() + { + $bindValues = [ + '%request.product_id.from%' => 1, + '%request.product_id.to%' => 3, + ]; + $requestName = 'range_filter'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(2, $queryResponse->count()); + } + + /** + * Range filter test with all fields filled + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testRangeFilterWithoutFromField() + { + $bindValues = [ + '%request.product_id.to%' => 4, + ]; + $requestName = 'range_filter_without_from_field'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(3, $queryResponse->count()); + } + + /** + * Range filter test with all fields filled + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testRangeFilterWithoutToField() + { + $bindValues = [ + '%request.product_id.from%' => 2, + ]; + $requestName = 'range_filter_without_to_field'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(4, $queryResponse->count()); + } + + /** + * Term filter test + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testTermFilter() + { + $id = 4; + + $bindValues = [ + '%request.product_id%' => $id, + ]; + $requestName = 'term_filter'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(1, $queryResponse->count()); + $this->assertEquals($id, $queryResponse->getIterator()->offsetGet(0)->getId()); + } + + /** + * Bool filter test + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testBoolFilter() + { + /* + * TODO: Remove test skipping after fixing issue + */ + $this->markTestSkipped('Bool filter doesn\'t work correctly and we have issue in bug tracker'); + $expectedIds = [2, 3]; + $bindValues = [ + '%request.must.range_filter1.from%' => 1, + '%request.must.range_filter1.to%' => 5, + '%request.should.term_filter1%' => 1, + '%request.should.term_filter2%' => 2, + '%request.should.term_filter3%' => 3, + '%request.should.term_filter4%' => 4, + '%request.not.term_filter1%' => 1, + '%request.not.term_filter2%' => 4, + ]; + $requestName = 'bool_filter'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(count($expectedIds), $queryResponse->count()); + $actualIds = []; + foreach ($queryResponse as $document) { + /** @var \Magento\Framework\Search\Document $document */ + $actualIds[] = $document->getId(); + } + $this->assertEquals($expectedIds, $actualIds); + } + + /** + * Sample Advanced search request test + * + * @dataProvider advancedSearchDataProvider + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testSimpleAdvancedSearch($bindValues, $expectedRecorsCount) + { + $requestName = 'advanced_search_test'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals($expectedRecorsCount, $queryResponse->count()); + } + + /** + * @return array + */ + public function advancedSearchDataProvider() + { + return array( + [ + [ + '%request.name%' => 'white', + '%request.description%' => 'shorts', + '%request.store_id%' => '1', + '%request.from_product_id%' => '3', + '%request.to_product_id%' => '4', + ], + 0 // Record is not in filter range + ], + [ + [ + '%request.name%' => 'white', + '%request.description%' => 'shorts', + '%request.store_id%' => '1', + '%request.from_product_id%' => '1', + '%request.to_product_id%' => '4', + ], + 1 // One record is expected + ], + [ + [ + '%request.name%' => 'white', + '%request.description%' => 'shorts', + '%request.store_id%' => '5', + '%request.from_product_id%' => '1', + '%request.to_product_id%' => '4', + ], + 0 // store_id filter is invalid + ], + [ + [ + '%request.name%' => 'black', + '%request.description%' => 'tshirts', + '%request.store_id%' => '1', + '%request.from_product_id%' => '1', + '%request.to_product_id%' => '5', + ], + 0 // Non existing search terms + ], + ); + } + + private function executeQuery($requestName, $bindValues) + { + $this->reindexAll(); + + /** @var \Magento\Framework\Search\Request $queryRequest */ + $queryRequest = $this->requestFactory->create($requestName, $bindValues); + + $queryResponse = $this->adapter->query($queryRequest); + + return $queryResponse; + } + + private function reindexAll() + { + /** @var \Magento\Indexer\Model\Indexer[] $indexerList */ + $indexerList = $this->objectManager->get('\Magento\Indexer\Model\Indexer\CollectionFactory') + ->create() + ->getItems(); + + foreach ($indexerList as $indexer) { + $indexer->reindexAll(); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php new file mode 100644 index 0000000000000000000000000000000000000000..30bb7fa1d3f1f137eab2055e9605811f98deee19 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Builder\Query; + +use Magento\Framework\App\Resource\Config; +use Magento\Framework\Search\Request\Query\Bool; +use Magento\TestFramework\Helper\Bootstrap; + +class MatchTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + } + + public function testBuildQuery() + { + $expectedSql = "SELECT `table`.* FROM `table` WHERE (MATCH (with_boost) AGAINST ('-wb' IN BOOLEAN MODE)) " . + "AND (MATCH (without_boost) AGAINST ('-wob' IN BOOLEAN MODE))"; + + /** @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder $scoreBuilder */ + $scoreBuilder = $this->objectManager->create('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder'); + /** @var \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match $match */ + $match = $this->objectManager->create('Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match'); + /** @var \Magento\Framework\Search\Request\Query\Match $query */ + $query = $this->objectManager->create( + 'Magento\Framework\Search\Request\Query\Match', + [ + 'name' => 'Match query', + 'boost' => 3.14, + 'matches' => [ + ['field' => 'with_boost', 'value' => 'wb', 'boost' => 2.15], + ['field' => 'without_boost', 'value' => 'wob'] + ] + ] + ); + /** @var \Magento\Framework\App\Resource $resource */ + $resource = $this->objectManager->create('Magento\Framework\App\Resource'); + /** @var \Magento\Framework\DB\Select $select */ + $select = $resource->getConnection(Config::DEFAULT_SETUP_CONNECTION)->select(); + $select->from('table'); + + $resultSelect = $match->build($scoreBuilder, $select, $query, Bool::QUERY_CONDITION_NOT); + $this->assertEquals($expectedSql, $resultSelect->assemble()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php index cbea998933115544373f092b793b7616f695d152..836b89dbfd100d0d6366f329e97cb7412c76e0c7 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php @@ -40,6 +40,8 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $document->load(__DIR__ . '../../../_files/search_request.xml'); $result = $this->object->convert($document); $expected = include __DIR__ . '/../../_files/search_request_config.php'; + sort($expected); + sort($result); $this->assertEquals($expected, $result); } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php index eb75216b09172e97e3caca22ae0f5038d0c76591..7cd6139834cdf427b5b65def589476a3bcf8951e 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php @@ -42,7 +42,7 @@ class MapperTest extends \PHPUnit_Framework_TestCase 'queries' => $request['queries'], 'rootQueryName' => 'suggested_search_container', 'filters' => $request['filters'], - 'aggregation' => $request['aggregation'], + 'aggregations' => $request['aggregations'], ] ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/products.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/products.php new file mode 100644 index 0000000000000000000000000000000000000000..00802d2848eccc05816aa307ea0fa9a5532ec929 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/products.php @@ -0,0 +1,345 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(1) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Green socks') + ->setSku('green_socks') + ->setPrice(10) + ->setWeight(1) + ->setShortDescription("Unisex green socks for some good peoples") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Unisex <b>green socks</b> for some good peoples') + ->setMetaTitle('green socks metadata') + ->setMetaKeyword('green,socks,unisex') + ->setMetaDescription('green socks metadata description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->setCanSaveCustomOptions(true) + ->setProductOptions( + array( + array( + 'id' => 1, + 'option_id' => 0, + 'previous_group' => 'text', + 'title' => 'Stone', + 'type' => 'field', + 'is_require' => 1, + 'sort_order' => 0, + 'price' => 1, + 'price_type' => 'fixed', + 'sku' => 'stone-1', + 'max_characters' => 100 + ) + ) + ) + ->setHasOptions(true) + ->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(2) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('White shorts') + ->setSku('white_shorts') + ->setPrice(12) + ->setWeight(2) + ->setShortDescription("Small white shorts for your children") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Small <b>white shorts</b> for your children') + ->setMetaTitle('white shorts for your children metadata') + ->setMetaKeyword('white,shorts,children') + ->setMetaDescription('white shorts for your children metadata description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->setCanSaveCustomOptions(true) + ->setProductOptions( + array( + array( + 'id' => 2, + 'option_id' => 0, + 'previous_group' => 'text', + 'title' => 'Gold', + 'type' => 'field', + 'is_require' => 1, + 'sort_order' => 0, + 'price' => 1, + 'price_type' => 'fixed', + 'sku' => 'Gold', + 'max_characters' => 100 + ) + ) + ) + ->setHasOptions(true) + ->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(3) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Red trousers') + ->setSku('red_trousers') + ->setPrice(14) + ->setWeight(3) + ->setShortDescription("Red pants for men") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Red pants for <b>men</b>') + ->setMetaTitle('Red trousers meta title') + ->setMetaKeyword('red,trousers,meta,men') + ->setMetaDescription('Red trousers meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->setCanSaveCustomOptions(true) + ->setProductOptions( + array( + array( + 'id' => 3, + 'option_id' => 0, + 'previous_group' => 'text', + 'title' => 'Silver', + 'type' => 'field', + 'is_require' => 1, + 'sort_order' => 0, + 'price' => 1, + 'price_type' => 'fixed', + 'sku' => 'silver', + 'max_characters' => 100 + ) + ) + ) + ->setHasOptions(true) + ->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(4) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Blue briefs') + ->setSku('blue_briefs') + ->setPrice(14) + ->setWeight(3) + ->setShortDescription("Blue briefs for Russian men") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Blue briefs for <b>men</b>') + ->setMetaTitle('Blue briefs meta title') + ->setMetaKeyword('blue,briefs,meta,men') + ->setMetaDescription('Blue briefs meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(5) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Grey shorts') + ->setSku('grey_shorts') + ->setPrice(14) + ->setWeight(3) + ->setShortDescription("Grey shorts for all peoples") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Grey shorts for <b>peoples</b>') + ->setMetaTitle('Grey shorts meta title') + ->setMetaKeyword('grey,shorts,meta,men') + ->setMetaDescription('Grey shorts meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/requests.xml b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/requests.xml new file mode 100644 index 0000000000000000000000000000000000000000..24391d4c77f0d51e05bf6af81cf490a03f0038b0 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/requests.xml @@ -0,0 +1,223 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <request query="one_match" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="boolQuery" name="one_match" boost="2"> + <queryReference clause="must" ref="fulltext_search_query" /> + </query> + + <query xsi:type="matchQuery" name="fulltext_search_query" boost="5"> + <match field="data_index" value="%request.title%" boost="2" /> + </query> + </queries> + <from>10</from> + <size>10</size> + </request> + <request query="one_match_filters" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="boolQuery" name="one_match_filters" boost="2"> + <queryReference clause="must" ref="fulltext_search_query" /> + <queryReference clause="must" ref="fulltext_search_query2" /> + </query> + + <query xsi:type="matchQuery" name="fulltext_search_query" boost="5"> + <match field="data_index" value="%request.title%" boost="2" /> + </query> + + <query xsi:type="filteredQuery" name="fulltext_search_query2"> + <filterReference ref="pid" /> + </query> + </queries> + <filters> + <filter xsi:type="boolFilter" name="pid"> + <filterReference clause="should" ref="pidm" /> + <filterReference clause="should" ref="pidsh" /> + </filter> + <filter name="pidm" xsi:type="rangeFilter" field="product_id" from="%pidm_from%" to="%pidm_to%" /> + <filter name="pidsh" xsi:type="termFilter" field="product_id" value="%pidsh%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="range_filter" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="range_filter"> + <filterReference ref="range_filter" /> + </query> + </queries> + <filters> + <filter name="range_filter" + xsi:type="rangeFilter" + field="product_id" + from="%request.product_id.from%" + to="%request.product_id.to%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="range_filter_without_from_field" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="range_filter_without_from_field"> + <filterReference ref="range_filter_without_from_field" /> + </query> + </queries> + <filters> + <filter name="range_filter_without_from_field" + xsi:type="rangeFilter" + field="product_id" + to="%request.product_id.to%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="range_filter_without_to_field" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="range_filter_without_to_field"> + <filterReference ref="range_filter_without_to_field" /> + </query> + </queries> + <filters> + <filter name="range_filter_without_to_field" + xsi:type="rangeFilter" + field="product_id" + from="%request.product_id.from%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="term_filter" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="term_filter"> + <filterReference ref="term_filter" /> + </query> + </queries> + <filters> + <filter name="term_filter" xsi:type="termFilter" field="product_id" value="%request.product_id%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="bool_filter" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="bool_filter"> + <filterReference ref="bool_filter" /> + </query> + </queries> + <filters> + <filter xsi:type="boolFilter" name="bool_filter"> + <filterReference clause="must" ref="must_range_filter1" /> + <filterReference clause="should" ref="should_term_filter1" /> + <filterReference clause="should" ref="should_term_filter2" /> + <filterReference clause="not" ref="not_term_filter1" /> + <filterReference clause="not" ref="not_term_filter2" /> + </filter> + <filter name="must_range_filter1" + xsi:type="rangeFilter" + field="product_id" + from="%request.must.range_filter1.from%" + to="%request.must.range_filter1.to%" /> + <filter name="should_term_filter1" + xsi:type="termFilter" + field="product_id" + value="%request.should.term_filter1%" /> + <filter name="should_term_filter2" + xsi:type="termFilter" + field="product_id" + value="%request.should.term_filter2%" /> + <filter name="should_term_filter3" + xsi:type="termFilter" + field="product_id" + value="%request.should.term_filter3%" /> + <filter name="should_term_filter4" + xsi:type="termFilter" + field="product_id" + value="%request.should.term_filter4%" /> + <filter name="not_term_filter1" + xsi:type="termFilter" + field="product_id" + value="%request.not.term_filter1%" /> + <filter name="not_term_filter2" + xsi:type="termFilter" + field="product_id" + value="%request.not.term_filter2%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="advanced_search_test" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="boolQuery" name="advanced_search_test" boost="1"> + <queryReference clause="should" ref="name_query" /> + <queryReference clause="should" ref="description_query" /> + <queryReference clause="should" ref="query_filter" /> + </query> + <query xsi:type="matchQuery" name="name_query"> + <match field="data_index" value="%request.name%" boost="1" /> + </query> + <query xsi:type="matchQuery" name="description_query"> + <match field="data_index" value="%request.description%" boost="1" /> + </query> + <query xsi:type="filteredQuery" name="query_filter"> + <filterReference ref="filter" /> + </query> + </queries> + <filters> + <filter xsi:type="boolFilter" name="filter"> + <filterReference clause="must" ref="store_filter" /> + <filterReference clause="must" ref="product_id_filter" /> + </filter> + <filter name="store_filter" xsi:type="termFilter" field="store_id" value="%request.store_id%" /> + <filter name="product_id_filter" xsi:type="rangeFilter" field="product_id" from="%request.from_product_id%" to="%request.to_product_id%" /> + </filters> + <from>10</from> + <size>10</size> + </request> +</requests> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml index c5b97e2e6e6af7f7cc9926315c6d4051059e9d09..7d7125a42d549f4c6048e4a3270cf8eb9aeb4d28 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml @@ -51,7 +51,7 @@ <filter xsi:type="rangeFilter" field="promoted_boost" name="price_name" from="10" to="100" /> <filter xsi:type="termFilter" name="price_name1" field="price_name" value="$name" /> </filters> - <aggregation> + <aggregations> <bucket xsi:type="termBucket" name="category_bucket" field="category"> <metrics> <metric type="sum" /> @@ -73,7 +73,7 @@ <range from="100" to=""/> </ranges> </bucket> - </aggregation> + </aggregations> <from>10</from> <size>10</size> </request> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php index 84066fed20ac512893aeae8b2762e4ebdac71c7f..06a33a142c9380df284807e1e3c6ed70fd0b3434 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php @@ -100,7 +100,7 @@ return [ "type" => "termFilter" ] ], - "aggregation" => [ + "aggregations" => [ "category_bucket" => [ "name" => "category_bucket", "field" => "category", @@ -159,4 +159,4 @@ return [ "query" => "suggested_search_container", "index" => "product" ] -]; \ No newline at end of file +]; diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php index 562b23072a92fc524216da4c9227fa5b81f26ac0..8299a35ba92e43c193d0464c0033e6299a9a41ab 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php @@ -35,9 +35,17 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase */ protected $_sidResolver; + /** + * @var string + */ + protected $sessionName; + protected function setUp() { + $this->sessionName = 'frontEndSession'; + ini_set('session.use_only_cookies', '0'); + ini_set('session.name', $this->sessionName); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -58,6 +66,13 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase ); } + public function testSessionNameFromIni() + { + $this->_model->start(); + $this->assertSame($this->sessionName, $this->_model->getName()); + $this->_model->destroy(); + } + public function testSessionUseOnlyCookies() { $expectedValue = '1'; @@ -129,7 +144,7 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase public function testGetSessionIdForHost() { $_SERVER['HTTP_HOST'] = 'localhost'; - $this->_model->start('test'); + $this->_model->start(); $this->assertEmpty($this->_model->getSessionIdForHost('localhost')); $this->assertNotEmpty($this->_model->getSessionIdForHost('test')); $this->_model->destroy(); @@ -138,7 +153,7 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase public function testIsValidForHost() { $_SERVER['HTTP_HOST'] = 'localhost'; - $this->_model->start('test'); + $this->_model->start(); $reflection = new \ReflectionMethod($this->_model, '_addHost'); $reflection->setAccessible(true); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php index aa72cde5eece8526c0fcfe35c5f88416ba2155de..409158bb2cde8e66fb98d6131f263c18f600a2fe 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php @@ -46,9 +46,18 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase public function testGetSensitiveCookieMetadataEmpty() { + $serverVal = $_SERVER; + $_SERVER['HTTPS'] = 'on'; $cookieScope = $this->createCookieScope(); - $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray()); + + $_SERVER = $serverVal; } public function testGetPublicCookieMetadataEmpty() @@ -72,7 +81,15 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase 'cookieMetadata' => null ] ); - $this->assertEquals($defaultValues, $cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_PATH => 'default path', + SensitiveCookieMetadata::KEY_DOMAIN => 'default domain', + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => false, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray() + ); } public function testGetPublicCookieMetadataDefaults() @@ -126,7 +143,14 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase ] ); $override = $this->createSensitiveMetadata($overrideValues); - $this->assertEquals($overrideValues, $cookieScope->getSensitiveCookieMetadata($override)->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_PATH => 'override path', + SensitiveCookieMetadata::KEY_DOMAIN => 'override domain', + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => false, + ], + $cookieScope->getSensitiveCookieMetadata($override)->__toArray()); } public function testGetPublicCookieMetadataOverrides() diff --git a/dev/tests/integration/testsuite/Magento/Framework/Translate/InlineTest.php b/dev/tests/integration/testsuite/Magento/Framework/Translate/InlineTest.php index 31e02a8a85646af6c4809950b0e8857f2186ffc4..b15f4a5661a269d3a27359fe904a6f79287feb46 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Translate/InlineTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Translate/InlineTest.php @@ -61,7 +61,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase ); /* Called getConfig as workaround for setConfig bug */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $this->_storeId )->getConfig( @@ -84,7 +84,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->assertTrue( $this->_model->isAllowed( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $this->_storeId ) @@ -96,7 +96,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->assertFalse( $this->_model->isAllowed( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $this->_storeId ) diff --git a/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php b/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php index f22f6966426a6c11ebf70a55527eb2293f37bc18..c35734a149ab9663199ec94cdf3faa1ac274ef5f 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php @@ -82,7 +82,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase 'Magento\Core\Model\View\Design', array('getDesignTheme'), array( - $objectManager->get('Magento\Store\Model\StoreManagerInterface'), + $objectManager->get('Magento\Framework\StoreManagerInterface'), $objectManager->get('Magento\Framework\View\Design\Theme\FlyweightFactory'), $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface'), $objectManager->get('Magento\Core\Model\ThemeFactory'), diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php index 6d2759d74182047eb06d5df44bfb01950e1e0d3b..d87651088ab036e2c7044585e1d72b7f07c88c3b 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php @@ -31,7 +31,7 @@ abstract class AbstractStubEntity extends \Magento\ImportExport\Model\Export\Abs { public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, array $data = array() diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php index 083a641ff8f914dc5fa65ea3432abddc5fec4119..702c2162c0d4bee3dd7db43db37c689a439e0d4b 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php @@ -125,7 +125,7 @@ abstract class Stub_Magento_ImportExport_Model_Export_AbstractEntity { public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, array $data = array() diff --git a/dev/tests/integration/testsuite/Magento/Install/Controller/WizardTest.php b/dev/tests/integration/testsuite/Magento/Install/Controller/WizardTest.php deleted file mode 100644 index 99ab68df0559c239da391bbf3ebc3da298f1965e..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Install/Controller/WizardTest.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Controller; - -class WizardTest extends \Magento\TestFramework\TestCase\AbstractController -{ - /** - * @var string - */ - protected static $_tmpDir; - - /** - * @var array - */ - protected static $_params = array(); - - public static function setUpBeforeClass() - { - /** @var \Magento\Framework\App\Filesystem $filesystem */ - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\Filesystem'); - $varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR); - $tmpDir = 'WizardTest'; - $varDirectory->delete($tmpDir); - // deliberately create a file instead of directory to emulate broken access to static directory - $varDirectory->touch($tmpDir); - - self::$_tmpDir = $varDirectory->getAbsolutePath($tmpDir); - } - - public function testPreDispatch() - { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure( - array( - 'preferences' => array( - 'Magento\Framework\App\RequestInterface' => 'Magento\TestFramework\Request', - 'Magento\Framework\App\Response\Http' => 'Magento\TestFramework\Response' - ) - ) - ); - /** @var $appState \Magento\Framework\App\State */ - $appState = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\State'); - $appState->setInstallDate(false); - $this->dispatch('install/wizard'); - $this->assertEquals(302, $this->getResponse()->getHttpResponseCode()); - $appState->setInstallDate(date('r', strtotime('now'))); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Install/Model/Installer/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Install/Model/Installer/ConfigTest.php deleted file mode 100644 index bb712f651c91d4dda51a0ca159361e6ab14bd6d4..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Install/Model/Installer/ConfigTest.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Model\Installer; - -class ConfigTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected static $_tmpDir = ''; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write - */ - protected static $_varDirectory; - - public static function setUpBeforeClass() - { - /** @var \Magento\Framework\App\Filesystem $filesystem */ - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\Filesystem'); - self::$_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR); - self::$_tmpDir = self::$_varDirectory->getAbsolutePath('ConfigTest'); - self::$_varDirectory->create(self::$_varDirectory->getRelativePath(self::$_tmpDir)); - } - - public static function tearDownAfterClass() - { - self::$_varDirectory->delete(self::$_varDirectory->getRelativePath(self::$_tmpDir)); - } - - public function testInstall() - { - file_put_contents(self::$_tmpDir . '/local.xml.template', "test; {{date}}; {{base_url}}; {{unknown}}"); - $expectedFile = self::$_tmpDir . '/local.xml'; - - $request = $this->getMock('Magento\Framework\App\Request\Http', array('getDistroBaseUrl'), array(), '', false); - - $request->expects($this->once())->method('getDistroBaseUrl')->will($this->returnValue('http://example.com/')); - $expectedContents = "test; <![CDATA[d-d-d-d-d]]>; <![CDATA[http://example.com/]]>; {{unknown}}"; - - $this->assertFileNotExists($expectedFile); - - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $directoryList = $objectManager->create( - 'Magento\Framework\App\Filesystem\DirectoryList', - array( - 'root' => self::$_tmpDir, - 'directories' => array(\Magento\Framework\App\Filesystem::CONFIG_DIR => array('path' => self::$_tmpDir)) - ) - ); - $objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList\Configuration')->configure($directoryList); - $filesystem = $objectManager->create( - 'Magento\Framework\App\Filesystem', - array('directoryList' => $directoryList) - ); - $model = $objectManager->create( - 'Magento\Install\Model\Installer\Config', - array('request' => $request, 'filesystem' => $filesystem) - ); - - $model->install(); - $this->assertFileExists($expectedFile); - $this->assertStringEqualsFile($expectedFile, $expectedContents); - } - - public function testGetFormData() - { - /** @var $model \Magento\Install\Model\Installer\Config */ - $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Install\Model\Installer\Config' - ); - /** @var $result \Magento\Framework\Object */ - $result = $model->getFormData(); - $this->assertInstanceOf('Magento\Framework\Object', $result); - $data = $result->getData(); - $this->assertArrayHasKey('db_host', $data); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php b/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php deleted file mode 100644 index 854aff32a1691ab4ca1e5fa7c5cec42d49cb8e4e..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Model; - -class InstallerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected static $_tmpDir = ''; - - /** - * @var string - */ - protected static $_tmpConfigFile = ''; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write - */ - protected static $_varDirectory; - - public static function setUpBeforeClass() - { - /** @var \Magento\Framework\App\Filesystem $filesystem */ - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\Filesystem'); - self::$_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR); - self::$_tmpDir = self::$_varDirectory->getAbsolutePath('InstallerTest'); - self::$_tmpConfigFile = self::$_tmpDir . '/local.xml'; - self::$_varDirectory->create(self::$_varDirectory->getRelativePath(self::$_tmpDir)); - } - - public static function tearDownAfterClass() - { - self::$_varDirectory->delete(self::$_varDirectory->getRelativePath(self::$_tmpDir)); - } - - /** - * Emulate configuration directory for the installer config model. - * Method usage should be accompanied with '@magentoAppIsolation enabled' because of the object manager pollution. - * - * @param bool $emulateConfig - * @return \Magento\Install\Model\Installer - */ - protected function _getModel($emulateConfig = false) - { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $directoryList = $objectManager->create( - 'Magento\Framework\App\Filesystem\DirectoryList', - array( - 'root' => __DIR__, - 'directories' => array(\Magento\Framework\App\Filesystem::CONFIG_DIR => array('path' => self::$_tmpDir)) - ) - ); - $objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList\Configuration')->configure($directoryList); - $filesystem = $objectManager->create( - 'Magento\Framework\App\Filesystem', - array('directoryList' => $directoryList) - ); - - if ($emulateConfig) { - $installerConfig = new \Magento\Install\Model\Installer\Config( - $objectManager->get('Magento\Install\Model\Installer'), - $objectManager->get('Magento\Framework\App\RequestInterface'), - $filesystem, - $objectManager->get('Magento\Store\Model\StoreManager'), - $objectManager->get('Magento\Framework\Message\Manager') - ); - $objectManager->addSharedInstance($installerConfig, 'Magento\Install\Model\Installer\Config'); - } - return $objectManager->create('Magento\Install\Model\Installer'); - } - - /** - * @magentoDbIsolation enabled - * @magentoAppArea install - */ - public function testCreateAdministrator() - { - $userName = 'installer_test'; - $userPassword = '123123q'; - $userData = array( - 'username' => $userName, - 'firstname' => 'First Name', - 'lastname' => 'Last Name', - 'email' => 'installer_test@example.com' - ); - - /** @var $user \Magento\User\Model\User */ - $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); - $user->loadByUsername($userName); - $this->assertEmpty($user->getId()); - - $this->_getModel()->createAdministrator($userData + array('password' => $userPassword)); - - $user->loadByUsername($userName); - $this->assertNotEmpty($user->getId()); - $this->assertEquals($userData, array_intersect_assoc($user->getData(), $userData)); - $this->assertNotEmpty($user->getPassword(), 'Password hash is expected to be loaded.'); - $this->assertNotEquals( - $userPassword, - $user->getPassword(), - 'Original password should not be stored/loaded as is for security reasons.' - ); - $this->assertInstanceOf('Magento\Authorization\Model\Role', $user->getRole()); - $this->assertEquals(1, $user->getRole()->getId(), 'User has to have admin privileges.'); - } - - /** - * @magentoAppIsolation enabled - */ - public function testInstallEncryptionKey() - { - $keyPlaceholder = \Magento\Install\Model\Installer\Config::TMP_ENCRYPT_KEY_VALUE; - $fixtureConfigData = "<key>{$keyPlaceholder}</key>"; - $expectedConfigData = '<key>d41d8cd98f00b204e9800998ecf8427e</key>'; - - file_put_contents(self::$_tmpConfigFile, $fixtureConfigData); - $this->assertEquals($fixtureConfigData, file_get_contents(self::$_tmpConfigFile)); - $this->_getModel(true)->installEncryptionKey('d41d8cd98f00b204e9800998ecf8427e'); - $this->assertEquals($expectedConfigData, file_get_contents(self::$_tmpConfigFile)); - } - - /** - * @magentoAppIsolation enabled - * @expectedException \Magento\Framework\Exception - * @expectedExceptionMessage Key must not exceed - */ - public function testInstallEncryptionKeySizeViolation() - { - $this->_getModel(true)->installEncryptionKey(str_repeat('a', 57)); - } - - /** - * @magentoAppIsolation enabled - */ - public function testGetValidEncryptionKey() - { - $validKey = 'abcdef1234567890'; - $this->assertEquals($validKey, $this->_getModel()->getValidEncryptionKey($validKey)); - } - - /** - * @magentoAppIsolation enabled - * @expectedException \Magento\Framework\Exception - * @expectedExceptionMessage Key must not exceed - */ - public function testGetValidEncryptionKeySizeViolation() - { - $this->_getModel()->getValidEncryptionKey(str_repeat('1', 57)); - } - - /** - * @magentoAppIsolation enabled - */ - public function testGetValidEncryptionKeyRandom() - { - $model = $this->_getModel(); - $actualKey = $model->getValidEncryptionKey(); - $this->assertRegExp('/^[a-f0-9]{32}$/', $actualKey); - $this->assertNotEquals($actualKey, $model->getValidEncryptionKey()); - } - - /** - * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Backend/controllers/_files/cache/all_types_disabled.php - */ - public function testFinish() - { - $configFile = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInstallDir() . '/etc/local.xml'; - copy($configFile, self::$_tmpConfigFile); - - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - - /** - * @var $cache \Magento\Framework\App\Cache - */ - $cache = $objectManager->create('Magento\Framework\App\Cache'); - /** - * @var $appState \Magento\Framework\App\State - */ - $appState = $objectManager->get('Magento\Framework\App\State'); - - $cache->save('testValue', 'testName'); - $this->assertEquals('testValue', $cache->load('testName')); - - //to test it works - set state to uninstalled - $appState->setInstallDate(null); - $this->assertFalse($appState->isInstalled()); - - $this->_getModel(true)->finish(); - - $this->assertFalse($cache->load('testName'), 'Cache was not cleaned'); - $this->assertTrue( - $appState->isInstalled(), - 'In-memory application installation state was not changed right after finishing installation phase' - ); - - /** @var $cacheState \Magento\Framework\App\Cache\StateInterface */ - $cacheState = $objectManager->create('Magento\Framework\App\Cache\StateInterface'); - - /** @var \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList */ - $cacheTypeList = $objectManager->create('Magento\Framework\App\Cache\TypeListInterface'); - $types = array_keys($cacheTypeList->getTypes()); - foreach ($types as $type) { - $this->assertTrue( - $cacheState->isEnabled($type), - "'{$type}' cache type has not been enabled after installation" - ); - } - } -} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..62b254d97e38ce4cb53b635242374db11039fc71 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php @@ -0,0 +1,130 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Integration\Service\V1; + +use Magento\Framework\Exception\InputException; +use Magento\Integration\Model\Oauth\Token as TokenModel; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\User\Model\User as UserModel; + +/** + * Test class for \Magento\Integration\Service\V1\AdminTokenService. + */ +class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AdminTokenServiceInterface + */ + private $tokenService; + + /** + * @var TokenModel + */ + private $tokenModel; + + /** + * @var UserModel + */ + private $userModel; + + /** + * Setup AdminTokenService + */ + public function setUp() + { + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); + $this->tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); + $this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); + } + + /** + * @magentoDataFixture Magento/User/_files/user_with_role.php + */ + public function testCreateAdminAccessToken() + { + $adminUserNameFromFixture = 'adminUser'; + $accessToken = $this->tokenService->createAdminAccessToken( + $adminUserNameFromFixture, + \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD + ); + $adminUserId = $this->userModel->loadByUsername($adminUserNameFromFixture)->getId(); + /** @var $token TokenModel */ + $token = $this->tokenModel + ->loadByAdminId($adminUserId) + ->getToken(); + $this->assertEquals($accessToken, $token); + } + + /** + * @dataProvider validationDataProvider + */ + public function testCreateAdminAccessTokenEmptyOrNullCredentials($username, $password) + { + try { + $this->tokenService->createAdminAccessToken($username, $password); + } catch (InputException $e) { + $this->assertInputExceptionMessages($e); + } + } + + /** + * @expectedException \Magento\Framework\Exception\AuthenticationException + * @expectedExceptionMessage Please correct the user name or password. + */ + public function testCreateAdminAccessTokenInvalidCustomer() + { + $adminUserName = 'invalid'; + $password = 'invalid'; + $this->tokenService->createAdminAccessToken($adminUserName, $password); + } + + /** + * Provider to test input validation + * + * @return array + */ + public function validationDataProvider() + { + return [ + 'Check for empty credentials' => ['', ''], + 'Check for null credentials' => [null, null] + ]; + } + + /** + * Assert for presence of Input exception messages + * + * @param InputException $e + */ + private function assertInputExceptionMessages($e) + { + $this->assertEquals(InputException::DEFAULT_MESSAGE, $e->getMessage()); + $errors = $e->getErrors(); + $this->assertCount(2, $errors); + $this->assertEquals('username is a required field.', $errors[0]->getLogMessage()); + $this->assertEquals('password is a required field.', $errors[1]->getLogMessage()); + } +} + diff --git a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php similarity index 68% rename from dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php rename to dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php index d92a18de977ecbab6be87d89f7daf141667a9d22..672c77c41b37227552196d0407c7c566faefbc3b 100644 --- a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php @@ -28,15 +28,14 @@ use Magento\Customer\Service\V1\CustomerAccountService; use Magento\Framework\Exception\InputException; use Magento\Integration\Model\Oauth\Token as TokenModel; use Magento\TestFramework\Helper\Bootstrap; -use Magento\User\Model\User as UserModel; /** - * Test class for \Magento\Integration\Service\V1\TokenService. + * Test class for \Magento\Integration\Service\V1\CustomerTokenService. */ -class TokenServiceTest extends \PHPUnit_Framework_TestCase +class CustomerTokenServiceTest extends \PHPUnit_Framework_TestCase { /** - * @var TokenServiceInterface + * @var CustomerTokenServiceInterface */ private $tokenService; @@ -51,21 +50,15 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase private $tokenModel; /** - * @var UserModel - */ - private $userModel; - - /** - * Setup TokenService + * Setup CustomerTokenService */ public function setUp() { - $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\TokenService'); + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\CustomerTokenService'); $this->customerAccountService = Bootstrap::getObjectManager()->get( 'Magento\Customer\Service\V1\CustomerAccountService' ); $this->tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); - $this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); } /** @@ -105,47 +98,6 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase $this->tokenService->createCustomerAccessToken($customerUserName, $password); } - /** - * @magentoDataFixture Magento/User/_files/user_with_role.php - */ - public function testCreateAdminAccessToken() - { - $adminUserNameFromFixture = 'adminUser'; - $accessToken = $this->tokenService->createAdminAccessToken( - $adminUserNameFromFixture, - \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD - ); - $adminUserId = $this->userModel->loadByUsername($adminUserNameFromFixture)->getId(); - /** @var $token TokenModel */ - $token = $this->tokenModel - ->loadByAdminId($adminUserId) - ->getToken(); - $this->assertEquals($accessToken, $token); - } - - /** - * @dataProvider validationDataProvider - */ - public function testCreateAdminAccessTokenEmptyOrNullCredentials($username, $password) - { - try { - $this->tokenService->createAdminAccessToken($username, $password); - } catch (InputException $e) { - $this->assertInputExceptionMessages($e); - } - } - - /** - * @expectedException \Magento\Framework\Exception\AuthenticationException - * @expectedExceptionMessage Please correct the user name or password. - */ - public function testCreateAdminAccessTokenInvalidCustomer() - { - $adminUserName = 'invalid'; - $password = 'invalid'; - $this->tokenService->createAdminAccessToken($adminUserName, $password); - } - /** * Provider to test input validation * diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/OnlineTest.php b/dev/tests/integration/testsuite/Magento/Log/Block/Adminhtml/OnlineTest.php similarity index 87% rename from dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/OnlineTest.php rename to dev/tests/integration/testsuite/Magento/Log/Block/Adminhtml/OnlineTest.php index e5a4604cf93a99e5672efd7973a439b288fb3c4b..91265277f7c80b2d173e855650cbba7b0022dadc 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/OnlineTest.php +++ b/dev/tests/integration/testsuite/Magento/Log/Block/Adminhtml/OnlineTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Customer\Block\Adminhtml; +namespace Magento\Log\Block\Adminhtml; /** * @magentoAppArea adminhtml @@ -38,8 +38,8 @@ class OnlineTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\View\Layout', array('area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) ); - /** @var $block \Magento\Customer\Block\Adminhtml\Online */ - $block = $layout->createBlock('Magento\Customer\Block\Adminhtml\Online', 'block'); + /** @var $block \Magento\Log\Block\Adminhtml\Online */ + $block = $layout->createBlock('Magento\Log\Block\Adminhtml\Online', 'block'); $this->assertNotEmpty($block->getFilterFormHtml()); } } diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/_files/queue.php b/dev/tests/integration/testsuite/Magento/Newsletter/_files/queue.php index 8e6f043b9c074b15a8905d0afed0b6b72944c3ed..e28c3ab432874cf8ceb4eef32098da67a719c8e7 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/_files/queue.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/_files/queue.php @@ -32,8 +32,8 @@ $template = $objectManager->create('Magento\Newsletter\Model\Template'); $template->load('fixture_tpl', 'template_code'); $templateId = $template->getId(); -$currentStore = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId(); -$otherStore = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore('fixturestore')->getId(); +$currentStore = $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getId(); +$otherStore = $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore('fixturestore')->getId(); /** @var $queue \Magento\Newsletter\Model\Queue */ $queue = $objectManager->create('Magento\Newsletter\Model\Queue'); diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php index 9b1eb01ff59f65d37032c946380f7c5b672ef8dd..2d472eff6dfd26412bb712442968b09898923c10 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php @@ -26,10 +26,10 @@ require __DIR__ . '/../../../Magento/Core/_files/store.php'; require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; $currentStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(); $otherStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( 'fixturestore' )->getId(); diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php index 6199eb72d84c4b16d1dc0ba70c2e1fb7dbef0526..e509a02ff56ca9fb7bcd2db0b95f7e824864857c 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php @@ -158,6 +158,6 @@ class ObserverTest extends \PHPUnit_Framework_TestCase protected function _resetConfig() { $this->_objectManager->get('Magento\Framework\App\Config\ReinitableConfigInterface')->reinit(); - $this->_objectManager->create('Magento\Store\Model\StoreManagerInterface')->reinitStores(); + $this->_objectManager->create('Magento\Framework\StoreManagerInterface')->reinitStores(); } } diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php index 78541ca25939e1efa227b2b53e3fe7f72abbca9c..3d9dcf86892d20d800b4ac17be8ec5d5c18165f7 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php @@ -24,7 +24,6 @@ namespace Magento\Paypal\Model\Express; -use Magento\Customer\Model\Customer; use Magento\TestFramework\Helper\Bootstrap; use Magento\Checkout\Model\Type\Onepage; use Magento\Sales\Model\Quote; diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php index 00de2fc305a6fa6de728edae3dc7e23be243264a..306aacaf5701f7d964c64367422d6c685e8186f4 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php @@ -40,7 +40,7 @@ class VoidTest extends \PHPUnit_Framework_TestCase $logAdapterFactory = $objectManager->get('Magento\Framework\Logger\AdapterFactory'); $localeDate = $objectManager->get('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); $centinelService = $objectManager->get('Magento\Centinel\Model\Service'); - $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $objectManager->get('Magento\Framework\StoreManagerInterface'); $configFactory = $objectManager->get('Magento\Paypal\Model\ConfigFactory'); $mathRandom = $objectManager->get('Magento\Framework\Math\Random'); $httpClientFactoryMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClientFactory') diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php index 50f11548e50c2dd6eb9e9f1be1da4ae9955eed62..5a69fa2a8d8fba5a41d59bdfc219585d0d2ea9d0 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php @@ -92,7 +92,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test02' diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php index 72a9700cda5e6e78c392285269663909e0fc6458..99bedc37ef59b7ff19d1e386342227ebd4cbad11 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php @@ -84,7 +84,7 @@ $quote->setCustomerIsGuest(false) ->setCustomerId($customer->getId()) ->setCustomer($customer) ->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface') ->getStore()->getId() ) ->setReservedOrderId('test02') diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php index 231953582f4132fd9d1de1b9ab6123471d13a2aa..ff87ee92e4df68c96b7ec46b3763d606b0b44ef6 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php @@ -101,7 +101,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test02' diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php index b8a57762a80a3b4b58bb23bbe73f3564fbb7adb9..308e524ab2f605ad9bf30fade97f7879d837254d 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php @@ -100,7 +100,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test01' diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php b/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php index cf504e159461b67b91125d1f0922b6a998d5bebc..3528c8e08188983902be37c30a9d0fb96775ae4e 100644 --- a/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php +++ b/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php @@ -44,11 +44,11 @@ $review ->setEntityPkValue($product->getId()) ->setStatusId(\Magento\Review\Model\Review::STATUS_PENDING) ->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface') ->getStore()->getId() ) ->setStores([ - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface') ->getStore()->getId() ]) ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/different_reviews.php b/dev/tests/integration/testsuite/Magento/Review/_files/different_reviews.php index 56298e0f746b87ad41b6a15d58d6140dc7c6bceb..eeb5c17d4b083e945972123e01ea0e90c8d2726d 100644 --- a/dev/tests/integration/testsuite/Magento/Review/_files/different_reviews.php +++ b/dev/tests/integration/testsuite/Magento/Review/_files/different_reviews.php @@ -36,12 +36,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_PENDING )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); @@ -58,12 +58,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_APPROVED )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); @@ -80,12 +80,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_APPROVED )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/review_xss.php b/dev/tests/integration/testsuite/Magento/Review/_files/review_xss.php index 1dd4bfbf0fdb9d75e36d008b2a8e44f38c6c80d5..c13b65fb37bbc17a06135b47ccd550d2909454e1 100644 --- a/dev/tests/integration/testsuite/Magento/Review/_files/review_xss.php +++ b/dev/tests/integration/testsuite/Magento/Review/_files/review_xss.php @@ -33,12 +33,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_PENDING )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->setNickname( diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/reviews.php b/dev/tests/integration/testsuite/Magento/Review/_files/reviews.php index ada86ae042292e58c2f5f7653ec780f38e09305f..94bc83aee40b38cdae81a03c47f38e7b2cc26634 100644 --- a/dev/tests/integration/testsuite/Magento/Review/_files/reviews.php +++ b/dev/tests/integration/testsuite/Magento/Review/_files/reviews.php @@ -36,12 +36,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_PENDING )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); diff --git a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php index 00ee0805c2b8392a753e613f96e0ab7209407880..56f1ffeaf384dc0f2e6bbc9c15022aad036c227c 100644 --- a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php +++ b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php @@ -148,7 +148,7 @@ class CatalogTest extends \Magento\TestFramework\TestCase\AbstractController $this->getRequest()->setParam( 'cid', \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getRootCategoryId() ); $this->dispatch('rss/catalog/category'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/AbstractTest.php deleted file mode 100644 index 631e2ba7c9c97b04137ea13203396b2b55947853..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/AbstractTest.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Model; - -class AbstractTest extends \PHPUnit_Framework_TestCase -{ - /** - * @magentoDataFixture Magento/Sales/_files/order.php - */ - public function testAfterCommitCallbackOrderGrid() - { - $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Resource\Order\Grid\Collection' - ); - $this->assertEquals(1, $collection->count()); - foreach ($collection as $order) { - $this->assertInstanceOf('Magento\Sales\Model\Order', $order); - $this->assertEquals('100000001', $order->getIncrementId()); - } - } - - public function testAfterCommitCallbackOrderGridNotInvoked() - { - $adapter = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\App\Resource' - )->getConnection( - 'core_write' - ); - $this->assertEquals(0, $adapter->getTransactionLevel(), 'This test must be outside a transaction.'); - - $localOrderModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Order' - ); - $resource = $localOrderModel->getResource(); - $resource->beginTransaction(); - try { - /** @var $order \Magento\Sales\Model\Order */ - require __DIR__ . '/../_files/order.php'; - $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Resource\Order\Grid\Collection' - ); - $this->assertEquals(0, $collection->count()); - $resource->rollBack(); - } catch (\Exception $e) { - $resource->rollBack(); - throw $e; - } - } -} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order.php index 2f0c89bd1acc11bb9066c9b6943ac2f43270f296..ce9377140c59cb4407c4d39b951eb29cf5faecbe 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order.php @@ -66,7 +66,7 @@ $order->setIncrementId( )->setShippingAddress( $shippingAddress )->setStoreId( - $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId() + $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getId() )->addItem( $orderItem )->setPayment( diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php index 292e40f8f4303cb8d87e15b63260334b5b42b179..bb857360024cd33f5ca8c63c3b95508cbfe14ded 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php @@ -63,7 +63,7 @@ $order->setIncrementId( )->setShippingAddress( $shippingAddress )->setStoreId( - $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore('fixturestore')->getId() + $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore('fixturestore')->getId() )->addItem( $orderItem )->setPayment( diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php index 4d8d86ba287ab5d6e28809a44f601d3c1cde2917..e3986009163039dd9817b00baf1de14edc4fe8de 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php @@ -63,7 +63,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test01' diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php index c7f27e00b37340448a9d7799603521791fe64baf..8bbac47f430e7616d6fe6163207720beb7a435ee 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php @@ -53,7 +53,7 @@ $order->setIncrementId( $shippingAddress )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setPayment( $payment diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php index 5a66eb4642d036acca3f5eb38da689a9b219b02a..27d01be37d78bf38293a201b1e838429c6155905 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php @@ -67,7 +67,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test01' diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off.php index 46e8f8be7791be40842aac204d55aea38b7fc522..f66536c45a006af3bdd00dab5213af6cb0aea125 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off.php @@ -43,7 +43,7 @@ $salesRule->setData( 'stop_rules_processing' => 1, 'website_ids' => array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getId() ) ) diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off.php index 6142194f77042fc8d9b8fdd62d042832c5db8b9d..88215b2e0519eb0ea9089e50df12b7649135aaf3 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off.php @@ -43,7 +43,7 @@ $salesRule->setData( 'stop_rules_processing' => 1, 'website_ids' => array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getId() ) ) diff --git a/dev/tests/integration/testsuite/Magento/Store/Model/GroupTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/GroupTest.php index e6ed4ae093e32e27e4ceb88b9280cd9c3ac3f5c6..2b12a989efecb2e45620ec35f812115d33a7d4c8 100644 --- a/dev/tests/integration/testsuite/Magento/Store/Model/GroupTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/GroupTest.php @@ -40,7 +40,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testSetGetWebsite() { $this->assertFalse($this->_model->getWebsite()); - $website = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface')->getWebsite(); + $website = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface')->getWebsite(); $this->_model->setWebsite($website); $actualResult = $this->_model->getWebsite(); $this->assertSame($website, $actualResult); @@ -52,7 +52,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testGetWebsiteDefault() { $this->assertFalse($this->_model->getWebsite()); - $website = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface')->getWebsite(); + $website = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface')->getWebsite(); $this->_model->setWebsite($website); // Empty string should get treated like no parameter $actualResult = $this->_model->getWebsite(''); diff --git a/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php index cc861ac6958a348d6c3c0d437e2e7f6483083bc5..ba812c310c4c83b46b8944b6e8a2695158e381eb 100644 --- a/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php @@ -28,16 +28,22 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** * @var array */ - protected $_modelParams; + protected $modelParams; /** * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject */ - protected $_model; + protected $model; + + /** + * @var array + */ + protected $existingCookies; protected function setUp() { - $this->_model = $this->_getStoreModel(); + $this->model = $this->_getStoreModel(); + $this->existingCookies = $_COOKIE; } /** @@ -46,7 +52,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function _getStoreModel() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_modelParams = [ + $this->modelParams = array( 'context' => $objectManager->get('Magento\Framework\Model\Context'), 'registry' => $objectManager->get('Magento\Framework\Registry'), 'resource' => $objectManager->get('Magento\Store\Model\Resource\Store'), @@ -65,14 +71,40 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'session' => $objectManager->get('Magento\Framework\Session\SessionManagerInterface'), 'currencyFactory' => $objectManager->get('Magento\Directory\Model\CurrencyFactory'), 'currencyInstalled' => 'system/currency/installed', - ]; + ); - return $this->getMock('Magento\Store\Model\Store', ['getUrl'], $this->_modelParams); + return $this->getMock('Magento\Store\Model\Store', array('getUrl'), $this->modelParams); } protected function tearDown() { - $this->_model = null; + $this->model = null; + $_COOKIE = $this->existingCookies; + } + + public function testSetCookie() + { + $storeCode = 'store code'; + $this->assertArrayNotHasKey(Store::COOKIE_NAME, $_COOKIE); + $this->model->setCode($storeCode); + $this->model->setCookie(); + $this->assertEquals($storeCode, $_COOKIE[Store::COOKIE_NAME]); + } + + public function testGetStoreCodeFromCookie() + { + $storeCode = 'store code'; + $_COOKIE[Store::COOKIE_NAME] = $storeCode; + $this->assertEquals($storeCode, $this->model->getStoreCodeFromCookie()); + } + + public function testDeleteCookie() + { + $storeCode = 'store code'; + $_COOKIE[Store::COOKIE_NAME] = $storeCode; + $this->assertArrayHasKey(Store::COOKIE_NAME, $_COOKIE); + $this->model->deleteCookie(); + $this->assertArrayNotHasKey(Store::COOKIE_NAME, $_COOKIE); } /** @@ -80,8 +112,8 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testLoad($loadId, $expectedId) { - $this->_model->load($loadId); - $this->assertEquals($expectedId, $this->_model->getId()); + $this->model->load($loadId); + $this->assertEquals($expectedId, $this->model->getId()); } /** @@ -89,28 +121,28 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function loadDataProvider() { - return [[1, 1], ['default', 1], ['nostore', null]]; + return array(array(1, 1), array('default', 1), array('nostore', null)); } public function testSetGetWebsite() { - $this->assertFalse($this->_model->getWebsite()); + $this->assertFalse($this->model->getWebsite()); $website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite(); - $this->_model->setWebsite($website); - $actualResult = $this->_model->getWebsite(); + $this->model->setWebsite($website); + $actualResult = $this->model->getWebsite(); $this->assertSame($website, $actualResult); } public function testSetGetGroup() { - $this->assertFalse($this->_model->getGroup()); + $this->assertFalse($this->model->getGroup()); $storeGroup = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Store\Model\StoreManager' )->getGroup(); - $this->_model->setGroup($storeGroup); - $actualResult = $this->_model->getGroup(); + $this->model->setGroup($storeGroup); + $actualResult = $this->model->getGroup(); $this->assertSame($storeGroup, $actualResult); } @@ -127,7 +159,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testGetBaseUrl($type, $useRewrites, $useStoreCode, $expected) { /* config operations require store to be loaded */ - $this->_model->load('default'); + $this->model->load('default'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\App\Config\MutableScopeConfigInterface' )->setValue( @@ -143,7 +175,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); - $actual = $this->_model->getBaseUrl($type); + $actual = $this->model->getBaseUrl($type); $this->assertEquals($expected, $actual); } @@ -152,28 +184,28 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getBaseUrlDataProvider() { - return [ - [\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, false, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, true, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, false, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, true, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/default/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'], - [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'], - [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'], - [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'], - [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'], - [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'], - [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'], - [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/'] - ]; + return array( + array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, false, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, true, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, false, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, true, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/default/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/') + ); } /** @@ -182,22 +214,22 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testGetBaseUrlInPub() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize( - [ - \Magento\Framework\App\Filesystem::PARAM_APP_DIRS => [ - \Magento\Framework\App\Filesystem::PUB_DIR => ['uri' => ''] - ] - ] + array( + \Magento\Framework\App\Filesystem::PARAM_APP_DIRS => array( + \Magento\Framework\App\Filesystem::PUB_DIR => array('uri' => '') + ) + ) ); - $this->_model = $this->_getStoreModel(); - $this->_model->load('default'); + $this->model = $this->_getStoreModel(); + $this->model->load('default'); $this->assertEquals( 'http://localhost/pub/static/', - $this->_model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_STATIC) + $this->model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_STATIC) ); $this->assertEquals( 'http://localhost/pub/media/', - $this->_model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) + $this->model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) ); } @@ -214,7 +246,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testGetBaseUrlForCustomEntryPoint($type, $useCustomEntryPoint, $useStoreCode, $expected) { /* config operations require store to be loaded */ - $this->_model->load('default'); + $this->model->load('default'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\App\Config\MutableScopeConfigInterface' )->setValue( @@ -233,11 +265,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase // emulate custom entry point $_SERVER['SCRIPT_FILENAME'] = 'custom_entry.php'; if ($useCustomEntryPoint) { - $property = new \ReflectionProperty($this->_model, '_isCustomEntryPoint'); + $property = new \ReflectionProperty($this->model, '_isCustomEntryPoint'); $property->setAccessible(true); - $property->setValue($this->_model, $useCustomEntryPoint); + $property->setValue($this->model, $useCustomEntryPoint); } - $actual = $this->_model->getBaseUrl($type); + $actual = $this->model->getBaseUrl($type); $this->assertEquals($expected, $actual); } @@ -246,38 +278,38 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getBaseUrlForCustomEntryPointDataProvider() { - return [ - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'], - [ + return array( + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'), + array( \Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/custom_entry.php/default/' - ], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'], - [ + ), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'), + array( \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/custom_entry.php/' - ], - [ + ), + array( \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/custom_entry.php/' - ], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/'] - ]; + ), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/') + ); } public function testGetDefaultCurrency() { /* currency operations require store to be loaded */ - $this->_model->load('default'); - $this->assertEquals($this->_model->getDefaultCurrencyCode(), $this->_model->getDefaultCurrency()->getCode()); + $this->model->load('default'); + $this->assertEquals($this->model->getDefaultCurrencyCode(), $this->model->getDefaultCurrency()->getCode()); } /** @@ -285,25 +317,25 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testGetPriceFilter() { - $this->_model->load('default'); - $this->assertInstanceOf('Magento\Directory\Model\Currency\Filter', $this->_model->getPriceFilter()); + $this->model->load('default'); + $this->assertInstanceOf('Magento\Directory\Model\Currency\Filter', $this->model->getPriceFilter()); } public function testIsCanDelete() { - $this->assertFalse($this->_model->isCanDelete()); - $this->_model->load(1); - $this->assertFalse($this->_model->isCanDelete()); - $this->_model->setId(100); - $this->assertTrue($this->_model->isCanDelete()); + $this->assertFalse($this->model->isCanDelete()); + $this->model->load(1); + $this->assertFalse($this->model->isCanDelete()); + $this->model->setId(100); + $this->assertTrue($this->model->isCanDelete()); } public function testGetCurrentUrl() { - $this->_model->load('admin'); - $this->_model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php')); - $this->assertStringEndsWith('default', $this->_model->getCurrentUrl()); - $this->assertStringEndsNotWith('default', $this->_model->getCurrentUrl(false)); + $this->model->load('admin'); + $this->model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php')); + $this->assertStringEndsWith('default', $this->model->getCurrentUrl()); + $this->assertStringEndsNotWith('default', $this->model->getCurrentUrl(false)); } /** @@ -313,20 +345,18 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testCRUD() { - $this->_model->setData( - [ + $this->model->setData( + array( 'code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1 - ] + ) ); $crud = new \Magento\TestFramework\Entity( - $this->_model, - ['name' => 'new name'], - 'Magento\Store\Model\Store' + $this->model, array('name' => 'new name'), 'Magento\Store\Model\Store' ); $crud->testCrud(); } @@ -342,17 +372,17 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testSaveValidation($badStoreData) { - $normalStoreData = [ + $normalStoreData = array( 'code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1 - ]; + ); $data = array_merge($normalStoreData, $badStoreData); - $this->_model->setData($data); - $this->_model->save(); + $this->model->setData($data); + $this->model->save(); } /** @@ -360,27 +390,26 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public static function saveValidationDataProvider() { - return [ - 'empty store name' => [['name' => '']], - 'empty store code' => [['code' => '']], - 'invalid store code' => [['code' => '^_^']] - ]; + return array( + 'empty store name' => array(array('name' => '')), + 'empty store code' => array(array('code' => '')), + 'invalid store code' => array(array('code' => '^_^')) + ); } /** * @dataProvider isUseStoreInUrlDataProvider */ - public function testIsUseStoreInUrl($isInstalled, $storeInUrl, $disableStoreInUrl, $expectedResult) + public function testIsUseStoreInUrl($storeInUrl, $disableStoreInUrl, $expectedResult) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $configMock = $this->getMock('Magento\Framework\App\Config\ReinitableConfigInterface'); - $appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false, false); - $appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue($isInstalled)); + $appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false, false); - $params = $this->_modelParams; + $params = $this->modelParams; $params['context'] = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Framework\Model\Context', - ['appState' => $appStateMock] + array('appState' => $appStateMock) ); $configMock->expects( @@ -404,12 +433,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function isUseStoreInUrlDataProvider() { - return [ - [true, true, null, true], - [false, true, null, false], - [true, false, null, false], - [true, true, true, false], - [true, true, false, true] - ]; + return array( + array(true, null, true), + array(false, null, false), + array(true, true, false), + array(true, false, true) + ); } } diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php b/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php index bbba87052bfb7d2e55e152b7d5b1f5fb1910729d..3182708e1e1e6c2a385adbc0ae827edb13ebd896 100644 --- a/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php +++ b/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php @@ -24,10 +24,10 @@ $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); $websiteId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getId(); $groupId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getDefaultGroupId(); $store->setCode( 'fixture_second_store' @@ -46,5 +46,5 @@ $store->save(); /* Refresh stores memory cache */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php b/dev/tests/integration/testsuite/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportTest.php similarity index 87% rename from dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php rename to dev/tests/integration/testsuite/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportTest.php index 1f638fecf47a7706de3a4042bbefaa48443950bd..8c921d57cfeff2a78fdf49640af47d8c40209add 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php +++ b/dev/tests/integration/testsuite/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Tax\Block\Adminhtml\Rate; +namespace Magento\TaxImportExport\Block\Adminhtml\Rate; class ImportExportTest extends \PHPUnit_Framework_TestCase { @@ -36,7 +36,7 @@ class ImportExportTest extends \PHPUnit_Framework_TestCase ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\View\LayoutInterface' - )->createBlock('Magento\Tax\Block\Adminhtml\Rate\ImportExport'); + )->createBlock('Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport'); } protected function tearDown() @@ -46,7 +46,7 @@ class ImportExportTest extends \PHPUnit_Framework_TestCase public function testCreateBlock() { - $this->assertInstanceOf('Magento\Tax\Block\Adminhtml\Rate\ImportExport', $this->_block); + $this->assertInstanceOf('Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport', $this->_block); } public function testFormExists() diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php similarity index 97% rename from dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php rename to dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php index 4fe351867310dc350b7dbdc1b13d4f0af770f6f1..66fdc3353c856aa49de0db6e39d1f7ede289f1d0 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php +++ b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Tax\Model\Rate; +namespace Magento\TaxImportExport\Model\Rate; class CsvImportHandlerTest extends \PHPUnit_Framework_TestCase { @@ -33,7 +33,7 @@ class CsvImportHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_importHandler = $objectManager->create('Magento\Tax\Model\Rate\CsvImportHandler'); + $this->_importHandler = $objectManager->create('Magento\TaxImportExport\Model\Rate\CsvImportHandler'); } protected function tearDown() diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/_files/correct_rates_import_file.csv b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/_files/correct_rates_import_file.csv similarity index 100% rename from dev/tests/integration/testsuite/Magento/Tax/Model/Rate/_files/correct_rates_import_file.csv rename to dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/_files/correct_rates_import_file.csv diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/_files/rates_import_file_incorrect_country.csv b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/_files/rates_import_file_incorrect_country.csv similarity index 100% rename from dev/tests/integration/testsuite/Magento/Tax/Model/Rate/_files/rates_import_file_incorrect_country.csv rename to dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/_files/rates_import_file_incorrect_country.csv diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php index 95ba3db70c0a1b663f838640c3c4d8030141acf7..4804bd35d66e7b8c23436b7f41a4066ea58083dd 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php @@ -43,7 +43,7 @@ class MethodsTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\View\Element\BlockFactory' ); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(); /** @var $model \Magento\Payment\Model\MethodInterface */ if (empty($methodClass)) { @@ -78,20 +78,20 @@ class MethodsTest extends \PHPUnit_Framework_TestCase if ($model->canUseInternal()) { try { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setId( \Magento\Store\Model\Store::DEFAULT_STORE_ID ); $block->setArea('adminhtml'); $this->assertFileExists($block->getTemplateFile(), $message); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setId( $storeId ); } catch (\Exception $e) { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setId( $storeId ); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php index b6a643dfc05d950f0edce1d740e30685be88fac5..67001f2fa0122e2e955687cc5ec67e290924b3fb 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php @@ -70,7 +70,7 @@ class BlockInstantiationTest extends \Magento\TestFramework\TestCase\AbstractInt try { /** @var $website \Magento\Store\Model\Website */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setWebsiteId( 0 ); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php index 0030df52d92b0564e9eb266d53d00b739ff1f6c2..309a216fa2cb41d052c9d41580410b61733014f4 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php @@ -65,7 +65,7 @@ class TemplateFilesTest extends \Magento\TestFramework\TestCase\AbstractIntegrit try { /** @var $website \Magento\Store\Model\Website */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setWebsiteId( 0 ); diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php index e1296c78835dcc2661a11c9dfb704a8580bc1bfb..777fdc92956cf3caea6532677bcdf03939762331 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php @@ -47,7 +47,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase $context->setValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH, false, false); $block = $objectManager->get('Magento\Framework\View\LayoutInterface') ->createBlock('Magento\Theme\Block\Html\Footer'); - $storeId = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId(); + $storeId = $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getId(); $this->assertEquals( array('PAGE_FOOTER', $storeId, 0, $this->_theme->getId(), null), $block->getCacheKeyInfo() diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php index 554c89593c7a5c66c5e47f6f6226a2014cc6e340..5e39f9fe90cce2b230d434a3d2e6e7accff74f27 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php @@ -68,7 +68,7 @@ class HtmlTest extends \PHPUnit_Framework_TestCase array('scopeConfig' => $scopeConfig, 'urlBuilder' => $urlBuilder) ); $storeManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' ); $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Theme\Block\Html', diff --git a/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php b/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php index a37e0df01ef15c375866d693025811fb84b11ec2..56f9149e2e8e067ad776ece2f7c344be56cba2e8 100644 --- a/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php @@ -44,7 +44,7 @@ class InlineParserTest extends \PHPUnit_Framework_TestCase ); /* Called getConfig as workaround for setConfig bug */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $this->_storeId )->getConfig( diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php index 1eb5581561931ff6fadd36ad0c70616d608489b4..72055d052de3eed469e1f3bd3fc7dec1df8f399b 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php @@ -54,7 +54,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase { $this->model->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( 'fancy/url.html' @@ -72,7 +72,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase ); $read->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->loadByRequestPath( 'fancy/url.html' @@ -98,7 +98,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase { $this->model->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( 'product1.html' @@ -118,7 +118,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase ); $read->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->loadByIdPath( 'product/1' @@ -194,14 +194,8 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase $scopeConfig = $this->objectManager->create( '\Magento\Framework\App\Config\ScopeConfigInterface' ); - $cookieMetadataFactory = $this->objectManager->create( - '\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' - ); - $cookieManager = $this->objectManager->create( - '\Magento\Framework\Stdlib\CookieManager' - ); $storeManager = $this->objectManager->create( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' ); $httpContext = $this->objectManager->create( '\Magento\Framework\App\Http\Context' @@ -211,8 +205,6 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase 'context' => $context, 'registry' => $registry, 'scopeConfig' => $scopeConfig, - 'cookieMetadataFactory' => $cookieMetadataFactory, - 'cookieManager' => $cookieManager, 'storeManager' => $storeManager, 'httpContext' => $httpContext, ]; @@ -275,7 +267,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase $request = $this->objectManager ->create('Magento\Framework\App\RequestInterface'); $_GET['___from_store'] = $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getCode(); $this->assertFalse($this->model->rewrite($request)); } @@ -298,7 +290,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase { $this->model->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( 'fancy/url.html' diff --git a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/InvalidateTokenTest.php b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/InvalidateTokenTest.php index c3ea6e96a155573972ebca8e08b68fa4f72267a5..d3b1da48c79d180d123d8a2fa911f2223148f212 100644 --- a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/InvalidateTokenTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/InvalidateTokenTest.php @@ -37,8 +37,8 @@ class InvalidateTokenTest extends \Magento\Backend\Utility\Controller */ public function testInvalidateSingleToken() { - /** @var \Magento\Integration\Service\V1\TokenService $tokenService */ - $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\TokenService'); + /** @var \Magento\Integration\Service\V1\AdminTokenService $tokenService */ + $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); /** @var \Magento\Integration\Model\Oauth\Token $tokenModel */ $tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); /** @var \Magento\User\Model\User $userModel */ @@ -63,8 +63,14 @@ class InvalidateTokenTest extends \Magento\Backend\Utility\Controller */ public function testInvalidateMultipleTokens() { - /** @var \Magento\Integration\Service\V1\TokenService $tokenService */ - $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\TokenService'); + /** @var \Magento\Integration\Service\V1\AdminTokenService $tokenService */ + $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); + + /** @var \Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory $tokenModelCollectionFactory */ + $tokenModelCollectionFactory = Bootstrap::getObjectManager()->get( + 'Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory' + ); + /** @var \Magento\User\Model\User $userModel */ $userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); @@ -84,7 +90,7 @@ class InvalidateTokenTest extends \Magento\Backend\Utility\Controller // invalidate tokens $this->getRequest()->setParam('user_id', $adminUserId); $this->dispatch('backend/admin/user/invalidateToken'); - foreach ($tokenService->tokenModelCollectionFactory->create()->addFilterByAdminId($adminUserId) as $token) { + foreach ($tokenModelCollectionFactory->create()->addFilterByAdminId($adminUserId) as $token) { $this->assertEquals(1, $token->getRevoked()); } } diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/PathProcessorTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/PathProcessorTest.php index 447326e29d4a534a40e85885f67e22bbb1eb30f6..e4b6488d628265bafbfa122cd1eac7ccb14d00ff 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/PathProcessorTest.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/PathProcessorTest.php @@ -27,7 +27,7 @@ namespace Magento\Webapi\Model; class PathProcessorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -40,7 +40,7 @@ class PathProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $objectManager->get('Magento\Framework\StoreManagerInterface'); $this->pathProcessor = $objectManager->get('\Magento\Webapi\Model\PathProcessor'); } diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php index 0ec54eb5fa68f560fa29df78f09cf039bdda6fbe..40b7c49e07e7764601d850abcc86ae403e9cc01b 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php @@ -46,7 +46,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store */ protected $_storeMock; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManagerMock; /** @var \Magento\Webapi\Model\Soap\Server\Factory */ diff --git a/dev/tests/performance/framework/Magento/TestFramework/Application.php b/dev/tests/performance/framework/Magento/TestFramework/Application.php index 6fac19c1850736b7381b549889ca7ceb6cbfafc8..5bd1efb22436422b51d3f6ce71101d0c3b87abbc 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Application.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Application.php @@ -29,11 +29,6 @@ namespace Magento\TestFramework; class Application { - /** - * Area code - */ - const AREA_CODE = 'install'; - /** * Configuration object * @@ -46,7 +41,14 @@ class Application * * @var string */ - protected $_installerScript; + protected $_installScript; + + /** + * Path to shell uninstaller script + * + * @var string + */ + protected $_uninstallScript; /** * @var \Magento\Framework\Shell @@ -76,18 +78,35 @@ class Application * Constructor * * @param \Magento\TestFramework\Performance\Config $config + * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\Shell $shell + */ + public function __construct( + \Magento\TestFramework\Performance\Config $config, + \Magento\Framework\ObjectManager $objectManager, + \Magento\Framework\Shell $shell + ) { + $shellDir = $config->getApplicationBaseDir() . '/dev/shell'; + $this->_objectManager = $objectManager; + $this->_installScript = $this->_assertPath($shellDir . '/install.php'); + $this->_uninstallScript = $this->_assertPath($shellDir . '/uninstall.php'); + $this->_config = $config; + $this->_shell = $shell; + } + + /** + * Asserts that a file exists and returns its real path + * + * @param string $path + * @return string * @throws \Magento\Framework\Exception */ - public function __construct(\Magento\TestFramework\Performance\Config $config, \Magento\Framework\Shell $shell) + private function _assertPath($path) { - $installerScript = $config->getApplicationBaseDir() . '/dev/shell/install.php'; - if (!is_file($installerScript)) { - throw new \Magento\Framework\Exception("File '{$installerScript}' is not found."); + if (!is_file($path)) { + throw new \Magento\Framework\Exception("File '{$path}' is not found."); } - $this->_installerScript = realpath($installerScript); - $this->_config = $config; - $this->_shell = $shell; + return realpath($path); } /** @@ -139,7 +158,7 @@ class Application */ protected function _uninstall() { - $this->_shell->execute('php -f %s -- --uninstall', array($this->_installerScript)); + $this->_shell->execute('php -f %s', array($this->_uninstallScript)); $this->_isInstalled = false; $this->_fixtures = array(); @@ -169,7 +188,7 @@ class Application } $installCmd = 'php -f %s --'; - $installCmdArgs = array($this->_installerScript); + $installCmdArgs = array($this->_installScript); foreach ($installOptions as $optionName => $optionValue) { $installCmd .= " --{$optionName} %s"; $installCmdArgs[] = $optionValue; @@ -195,30 +214,6 @@ class Application $varDirectory->changePermissions('', 0777); } - /** - * Bootstrap application, so it is possible to use its resources - * - * @return \Magento\TestFramework\Application - */ - protected function _bootstrap() - { - $this->getObjectManager()->configure( - $this->getObjectManager()->get('Magento\Framework\App\ObjectManager\ConfigLoader')->load(self::AREA_CODE) - ); - $this->getObjectManager()->get('Magento\Framework\Config\ScopeInterface')->setCurrentScope(self::AREA_CODE); - return $this; - } - - /** - * Bootstrap - * - * @return Application - */ - public function bootstrap() - { - return $this->_bootstrap(); - } - /** * Work on application, so that it has all and only $fixtures applied. May require reinstall, if * excessive fixtures has been applied before. @@ -237,7 +232,6 @@ class Application return; } - $this->_bootstrap(); foreach ($fixturesToApply as $fixtureFile) { $this->applyFixture($fixtureFile); } @@ -274,24 +268,8 @@ class Application * * @return \Magento\Framework\ObjectManager */ - public function getObjectManager() + protected function getObjectManager() { - if (!$this->_objectManager) { - $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory(); - $this->_objectManager = $locatorFactory->create(BP, $_SERVER); - $this->_objectManager->get('Magento\Framework\App\State')->setAreaCode(self::AREA_CODE); - } return $this->_objectManager; } - - /** - * Reset object manager - * - * @return \Magento\Framework\ObjectManager - */ - public function resetObjectManager() - { - $this->_objectManager = null; - return $this; - } } diff --git a/dev/tests/performance/framework/Magento/TestFramework/Performance/Bootstrap.php b/dev/tests/performance/framework/Magento/TestFramework/Performance/Bootstrap.php index dd3dff154c901b4d897b05ddcdf1b7ade176d1df..bceec3ed950495c8c43b043e75b208c066b8c4e9 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Performance/Bootstrap.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Performance/Bootstrap.php @@ -29,25 +29,37 @@ namespace Magento\TestFramework\Performance; class Bootstrap { + /** + * The real application bootstrap + * + * @var \Magento\Framework\App\Bootstrap + */ + private $appBootstrap; + + /** + * Tests base directory + * + * @var string + */ + private $testsBaseDir; + /** * Tests configuration holder * * @var \Magento\TestFramework\Performance\Config */ - protected $_config; + private $config; /** * Constructor * + * @param \Magento\Framework\App\Bootstrap $appBootstrap * @param string $testsBaseDir - * @param string $appBaseDir */ - public function __construct($testsBaseDir, $appBaseDir) + public function __construct(\Magento\Framework\App\Bootstrap $appBootstrap, $testsBaseDir) { - $configFile = "{$testsBaseDir}/config.php"; - $configFile = file_exists($configFile) ? $configFile : "{$configFile}.dist"; - $configData = require $configFile; - $this->_config = new \Magento\TestFramework\Performance\Config($configData, $testsBaseDir, $appBaseDir); + $this->appBootstrap = $appBootstrap; + $this->testsBaseDir = $testsBaseDir; } /** @@ -57,7 +69,7 @@ class Bootstrap */ public function cleanupReports() { - $reportDir = $this->_config->getReportDir(); + $reportDir = $this->getConfig()->getReportDir(); try { $filesystemAdapter = new \Magento\Framework\Filesystem\Driver\File(); if ($filesystemAdapter->isExists($reportDir)) { @@ -71,6 +83,35 @@ class Bootstrap mkdir($reportDir, 0777, true); } + /** + * Test framework application factory method + * + * @param \Magento\Framework\Shell $shell + * @return \Magento\TestFramework\Application + */ + public function createApplication(\Magento\Framework\Shell $shell) + { + return new \Magento\TestFramework\Application( + $this->getConfig(), + $this->appBootstrap->getObjectManager(), + $shell + ); + } + + /** + * Test suite factory method + * + * @param \Magento\TestFramework\Application $application + * @param \Magento\TestFramework\Performance\Scenario\HandlerInterface $scenarioHandler + * @return Testsuite + */ + public function createTestSuite( + \Magento\TestFramework\Application $application, + \Magento\TestFramework\Performance\Scenario\HandlerInterface $scenarioHandler + ) { + return new Testsuite($this->getConfig(), $application, $scenarioHandler); + } + /** * Return configuration for the tests * @@ -78,6 +119,12 @@ class Bootstrap */ public function getConfig() { - return $this->_config; + if (null === $this->config) { + $configFile = "{$this->testsBaseDir}/config.php"; + $configFile = file_exists($configFile) ? $configFile : "{$configFile}.dist"; + $configData = require $configFile; + $this->config = new Config($configData, $this->testsBaseDir, $this->appBootstrap->getDirList()->getRoot()); + } + return $this->config; } } diff --git a/dev/tests/performance/framework/Magento/TestFramework/Performance/Testsuite.php b/dev/tests/performance/framework/Magento/TestFramework/Performance/Testsuite.php index 602d9d7d3a0ffd83fd884944992f556abea4af13..e605ee820455cc1b141a3c5f0817aeca2b0d5968 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Performance/Testsuite.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Performance/Testsuite.php @@ -93,16 +93,6 @@ class Testsuite $this->_scenarioHandler = $scenarioHandler; } - /** - * Get test framework application instance - * - * @return \Magento\TestFramework\Application - */ - public function getApplication() - { - return $this->_application; - } - /** * Run entire test suite of scenarios */ diff --git a/dev/tests/performance/framework/bootstrap.php b/dev/tests/performance/framework/bootstrap.php index f383f8470d7c0afc6f296887ab2f3ccc228e97ca..77bdec73559dd5626ce906f75366dfa9a0bfb02a 100644 --- a/dev/tests/performance/framework/bootstrap.php +++ b/dev/tests/performance/framework/bootstrap.php @@ -24,12 +24,10 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -$testsBaseDir = realpath(__DIR__ . '/..'); -$magentoBaseDir = realpath($testsBaseDir . '/../../../'); - -require_once "{$magentoBaseDir}/app/bootstrap.php"; -(new \Magento\Framework\Autoload\IncludePath())->addIncludePath("{$testsBaseDir}/framework"); - -$bootstrap = new \Magento\TestFramework\Performance\Bootstrap($testsBaseDir, $magentoBaseDir); +$testsBaseDir = dirname(__DIR__); +require __DIR__ . '/../../../../app/bootstrap.php'; +$appBootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); +(new \Magento\Framework\Autoload\IncludePath())->addIncludePath($testsBaseDir . '/framework'); +$bootstrap = new \Magento\TestFramework\Performance\Bootstrap($appBootstrap, $testsBaseDir); $bootstrap->cleanupReports(); -return $bootstrap->getConfig(); +return $bootstrap; diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php index 0739198d3f0cc4ef8a0bff868424787996fef72e..d72682dbfcd8cf3c86ee882c23966a03ac54494a 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php @@ -49,6 +49,11 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase */ protected $_installerScript; + /** + * @var string + */ + protected $_uninstallScript; + /** * @var string */ @@ -67,7 +72,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $this->_fixtureDir = __DIR__ . '/Performance/_files'; $this->_fixtureConfigData = require $this->_fixtureDir . '/config_data.php'; - $this->_installerScript = realpath($this->_fixtureDir . '/app_base_dir//dev/shell/install.php'); + $this->_installerScript = realpath($this->_fixtureDir . '/app_base_dir/dev/shell/install.php'); + $this->_uninstallScript = substr($this->_installerScript, 0, -11) . 'uninstall.php'; $this->_config = new \Magento\TestFramework\Performance\Config( $this->_fixtureConfigData, @@ -75,13 +81,15 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $this->_fixtureDir . '/app_base_dir' ); $this->_shell = $this->getMock('Magento\Framework\Shell', array('execute'), array(), '', false); + $objectManager = $this->getMockForAbstractClass('\Magento\Framework\ObjectManager'); $this->_object = $this->getMock( 'Magento\TestFramework\Application', - array('_bootstrap', '_cleanupMage', '_reindex', '_updateFilesystemPermissions'), - array($this->_config, $this->_shell) + array('_cleanupMage', '_reindex', '_updateFilesystemPermissions', 'getObjectManager'), + array($this->_config, $objectManager, $this->_shell) ); $this->_object->expects($this->any())->method('_reindex')->will($this->returnValue($this->_object)); + $this->_object->expects($this->any())->method('getObjectManager')->will($this->returnValue($objectManager)); // For fixture testing $this->_object->applied = array(); @@ -97,24 +105,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase unset($this->_object); } - /** - * Constructor test - * - * @expectedException \Magento\Framework\Exception - */ - public function testConstructorException() - { - $invalidAppDir = __DIR__; - new \Magento\TestFramework\Application( - new \Magento\TestFramework\Performance\Config( - $this->_fixtureConfigData, - $this->_fixtureDir, - $invalidAppDir - ), - $this->_shell - ); - } - /** * Apply fixtures test * @@ -212,8 +202,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->stringContains('--uninstall'), - $this->contains($this->_installerScript) + $this->anything(), + $this->contains($this->_uninstallScript) ); $this->_shell->expects( @@ -221,7 +211,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->logicalNot($this->stringContains('--uninstall')), + $this->anything(), $this->contains($this->_installerScript) ); @@ -253,8 +243,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->stringContains('--uninstall'), - $this->contains($this->_installerScript) + $this->anything(), + $this->contains($this->_uninstallScript) ); $this->_shell->expects( @@ -262,7 +252,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->logicalNot($this->stringContains('--uninstall')), + $this->anything(), $this->contains($this->_installerScript) ); @@ -271,8 +261,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->stringContains('--uninstall'), - $this->contains($this->_installerScript) + $this->anything(), + $this->contains($this->_uninstallScript) ); $this->_shell->expects( @@ -280,7 +270,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->logicalNot($this->stringContains('--uninstall')), + $this->anything(), $this->contains($this->_installerScript) ); diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/BootstrapTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/BootstrapTest.php index 4677947c1fef2aa94d219fbd361302d8a8d62ddc..3e784f15ba6d739f802d73bf893892ae813ac229 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/BootstrapTest.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/BootstrapTest.php @@ -25,6 +25,23 @@ namespace Magento\Test\Performance; class BootstrapTest extends \PHPUnit_Framework_TestCase { + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $appBootstrap; + + protected function setUp() + { + $this->appBootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $dirList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $dirList->expects($this->any())->method('getRoot')->will($this->returnValue(BP)); + $this->appBootstrap->expects($this->any())->method('getDirList')->will($this->returnValue($dirList)); + $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManager'); + $this->appBootstrap->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($objectManager)); + } + protected function tearDown() { // Delete a directory, where tests do some temporary work @@ -43,8 +60,8 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase public function testConfigLoad($fixtureDir, $expectedUrl) { $bootstrap = new \Magento\TestFramework\Performance\Bootstrap( - $fixtureDir, - $this->_getBaseFixtureDir() . '/app_base_dir' + $this->appBootstrap, + $fixtureDir ); $config = $bootstrap->getConfig(); $this->assertInstanceOf('Magento\TestFramework\Performance\Config', $config); @@ -76,7 +93,7 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase public function testCleanupReportsCreatesDirectory() { $fixtureDir = $this->_getBaseFixtureDir() . '/config_dist'; - $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($fixtureDir, $fixtureDir); + $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($this->appBootstrap, $fixtureDir); $reportDir = $fixtureDir . '/tmp/subdirectory/report'; @@ -88,7 +105,7 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase public function testCleanupReportsRemovesFiles() { $fixtureDir = $this->_getBaseFixtureDir() . '/config_dist'; - $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($fixtureDir, $fixtureDir); + $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($this->appBootstrap, $fixtureDir); $reportDir = $fixtureDir . '/tmp/subdirectory/report'; mkdir($reportDir, 0777, true); @@ -99,4 +116,18 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase $bootstrap->cleanupReports(); $this->assertFileNotExists($reportFile); } + + public function testCreateApplicationTestSuite() + { + $shell = $this->getMock('Magento\Framework\Shell', [], [], '', false); + $bootstrap = new \Magento\TestFramework\Performance\Bootstrap( + $this->appBootstrap, + $this->_getBaseFixtureDir() . '/config_dist' + ); + $application = $bootstrap->createApplication($shell); + $this->assertInstanceOf('Magento\TestFramework\Application', $application); + $handler = $this->getMockForAbstractClass('Magento\TestFramework\Performance\Scenario\HandlerInterface'); + $testSuite = $bootstrap->createTestSuite($application, $handler); + $this->assertInstanceOf('Magento\TestFramework\Performance\Testsuite', $testSuite); + } } diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php index a4e44bc4bd7dd43c013032e6e1086a3cb3a85b08..bc3b4a178f1e07e98b38cf6b33eee2e38465f070 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php @@ -81,7 +81,7 @@ class TestsuiteTest extends \PHPUnit_Framework_TestCase $this->_application = $this->getMock( 'Magento\TestFramework\Application', array('applyFixtures'), - array($this->_config, $shell) + array($this->_config, $this->getMockForAbstractClass('Magento\Framework\ObjectManager'), $shell) ); $this->_handler = $this->getMockForAbstractClass( 'Magento\TestFramework\Performance\Scenario\HandlerInterface' @@ -288,12 +288,4 @@ class TestsuiteTest extends \PHPUnit_Framework_TestCase { $this->_object->onScenarioFailure(array($this, 'invalid_callback')); } - - /** - * Test get application - */ - public function testGetApplication() - { - $this->assertEquals(true, $this->_object->getApplication() instanceof \Magento\TestFramework\Application); - } } diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/app_base_dir/dev/shell/uninstall.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/app_base_dir/dev/shell/uninstall.php new file mode 100644 index 0000000000000000000000000000000000000000..5956af5ae0dbbcf7f23d4272dbf9f3720d9cc4bf --- /dev/null +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/app_base_dir/dev/shell/uninstall.php @@ -0,0 +1,25 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/* Magento console uninstaller stub */ diff --git a/dev/tests/performance/run_scenarios.php b/dev/tests/performance/run_scenarios.php index 409fe3aa5297e768ee2532561e3b4efec071c116..322da4627218548a60c93e2334cfaa18acc6b13f 100644 --- a/dev/tests/performance/run_scenarios.php +++ b/dev/tests/performance/run_scenarios.php @@ -24,8 +24,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $config \Magento\TestFramework\Performance\Config */ -$config = require_once __DIR__ . '/framework/bootstrap.php'; +/** @var $bootstrap \Magento\TestFramework\Performance\Bootstrap */ +$bootstrap = require_once __DIR__ . '/framework/bootstrap.php'; $logWriter = new \Zend_Log_Writer_Stream('php://output'); $logWriter->setFormatter(new \Zend_Log_Formatter_Simple('%message%' . PHP_EOL)); @@ -41,13 +41,10 @@ $scenarioHandler->register( new \Magento\TestFramework\Performance\Scenario\Handler\Php($shell) ); -$testsuite = new \Magento\TestFramework\Performance\Testsuite( - $config, - new \Magento\TestFramework\Application($config, $shell), - $scenarioHandler -); +$application = $bootstrap->createApplication($shell); +$testsuite = $bootstrap->createTestSuite($application, $scenarioHandler); -$scenarioTotalCount = count($config->getScenarios()); +$scenarioTotalCount = count($bootstrap->getConfig()->getScenarios()); $scenarioCount = 1; $scenarioFailCount = 0; $testsuite->onScenarioRun( diff --git a/dev/tests/performance/testsuite/fixtures/catalog_200_categories_80k_products.php b/dev/tests/performance/testsuite/fixtures/catalog_200_categories_80k_products.php index d96a51a0ee1ad70e69d135ae71bbefcdfbafe5e1..e2467c58b9c314f5e4afa1fd68561e19e50af705 100644 --- a/dev/tests/performance/testsuite/fixtures/catalog_200_categories_80k_products.php +++ b/dev/tests/performance/testsuite/fixtures/catalog_200_categories_80k_products.php @@ -33,7 +33,7 @@ $anchorStep = 2; $nestingLevel = 1; $parentCategoryId = $defaultParentCategoryId = $this->getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getRootCategoryId(); $nestingPath = "1/{$parentCategoryId}"; $categoryPath = ''; diff --git a/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php b/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php index 3b51484bf168021b68e48885304d0ea851690cf6..f97738ae61d8e08d5fe038eea0fdbc3fb2d79237 100644 --- a/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php +++ b/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php @@ -61,7 +61,7 @@ $order->setBaseSubtotal( \Magento\Sales\Model\Order::STATE_NEW, true )->setStoreId( - $this->getObjectManager()->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId() + $this->getObjectManager()->get('Magento\Framework\StoreManagerInterface')->getStore()->getId() ); for ($i = 1; $i <= 100000; $i++) { diff --git a/dev/tests/static/framework/bootstrap.php b/dev/tests/static/framework/bootstrap.php index f4e680ce2286f9a610ce27c8c43e8a3d3b5853f7..e67cf580dbb731b8a24553fdec139e5f1defdf50 100644 --- a/dev/tests/static/framework/bootstrap.php +++ b/dev/tests/static/framework/bootstrap.php @@ -22,8 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -define('BP', str_replace('\\', '/', realpath(__DIR__ . '/../../../../'))); -require BP . '/app/autoload.php'; +require __DIR__ . '/../../../../app/autoload.php'; (new \Magento\Framework\Autoload\IncludePath())->addIncludePath( array(__DIR__, dirname(__DIR__) . '/testsuite', BP . '/lib/internal') ); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php index b85b880e4f1078eb56370e33cf91aa712d0d06a7..d8d1ec63cae5678785097d988cf386458070e1d4 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php @@ -86,7 +86,6 @@ class ConfigTest extends \Magento\TestFramework\Integrity\AbstractConfig explode( "\n", " -Element 'from': This element is not expected. Expected is ( filters ). No match found for key-sequence ['sugegsted_search_container'] of keyref 'requestQueryReference'. Element 'queryReference': No match found for key-sequence ['fulltext_search_query4'] of keyref 'queryReference'. " diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php index 2c1e544dcbec5791ae1736cdb20eb17bb10de94e..3a875897abe7b7772228cd232aff5dc70f5379bf 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php @@ -163,6 +163,7 @@ return array( 'customer_entity_int' => 'Magento_Customer', 'customer_entity_text' => 'Magento_Customer', 'customer_entity_varchar' => 'Magento_Customer', + 'customer_visitor' => 'Magento_Customer', 'directory_country' => 'Magento_Directory', 'directory_country_format' => 'Magento_Directory', 'directory_country_name' => 'Magento_Directory', diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index f0db8227cbb93da50a8a30f99f9e37df755f9c46..4a278c7b43105ed4c343b27af97c64f10a98f71b 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -843,8 +843,8 @@ return array( array('Mage_Core_Model_Session_Abstract_Varien'), array('Mage_Core_Model_Session_Abstract_Zend'), array('Magento\Core\Model\Source\Email\Variables', 'Magento\Email\Model\Source\Variables'), - array('Magento\Core\Model\Store\ListInterface', 'Magento\Store\Model\StoreManagerInterface'), - array('Magento\Core\Model\Store\StorageInterface', 'Magento\Store\Model\StoreManagerInterface'), + array('Magento\Core\Model\Store\ListInterface', 'Magento\Framework\StoreManagerInterface'), + array('Magento\Core\Model\Store\StorageInterface', 'Magento\Framework\StoreManagerInterface'), array('Mage_Core_Model_Store_Group_Limitation'), array('Mage_Core_Model_Store_Limitation'), array('Magento\Core\Model\Variable\Observer'), @@ -2122,7 +2122,7 @@ return array( array('Recurring\Profile', 'Recurring\Payment'), // recurring profile was renamed to recurring payment array('Magento\Catalog\Helper\Product\Flat'), array('Magento\Catalog\Helper\Flat\AbstractFlat'), - array('Magento\Core\App\Action\Plugin\Install', 'Magento\Install\App\Action\Plugin\Install'), + array('Magento\Core\App\Action\Plugin\Install', 'Magento\Framework\App\Bootstrap'), array('Magento\Core\App\Action\Plugin\Session', 'Magento\Core\Block\RequireCookie'), array( 'Magento\Core\Model\LocaleInterface', @@ -2307,8 +2307,8 @@ return array( ['Magento\Framework\App\Locale\ScopeConfigInterface', 'Magento\Framework\App\Config\ScopeConfigInterface'], ['Magento\Core\App\Action\Plugin\StoreCheck', 'Magento\Store\App\Action\Plugin\StoreCheck'], [ - 'Magento\Core\App\FrontController\Plugin\DispatchExceptionHandler', - 'Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler' + 'Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler', + 'Magento\Framework\App\Bootstrap' ], [ 'Magento\Core\App\FrontController\Plugin\RequestPreprocessor', @@ -2333,14 +2333,14 @@ return array( ['Magento\Core\Model\Resource\Website\Grid\Collection', 'Magento\Store\Model\Resource\Website\Grid\Collection'], ['Magento\Core\Model\ScopeInterface', 'Magento\Store\Model\ScopeInterface'], ['Magento\Core\Model\Store', 'Magento\Store\Model\Store'], - ['Magento\Core\Model\Store\Exception', 'Magento\Store\Model\Exception'], + ['Magento\Store\Model\Exception', 'Magento\Framework\Model\Exception, Magento\Framework\App\InitException'], ['Magento\Core\Model\Store\Group', 'Magento\Store\Model\Group'], ['Magento\Core\Model\Store\Group\Factory', 'Magento\Store\Model\GroupFactory'], ['Magento\Core\Model\Store\Storage\Db', 'Magento\Store\Model\Storage\Db'], ['Magento\Core\Model\Store\Storage\DefaultStorage', 'Magento\Store\Model\Storage\DefaultStorage'], ['Magento\Core\Model\Store\StorageFactory', 'Magento\Store\Model\StorageFactory'], ['Magento\Core\Model\StoreManager', 'Magento\Store\Model\StoreManager'], - ['Magento\Core\Model\StoreManagerInterface', 'Magento\Store\Model\StoreManagerInterface'], + ['Magento\Core\Model\StoreManagerInterface', 'Magento\Framework\StoreManagerInterface'], ['Magento\Core\Model\System\Store', 'Magento\Store\Model\System\Store'], ['Magento\Core\Model\Website', 'Magento\Store\Model\Website'], ['Magento\Core\Model\Website\Factory', 'Magento\Store\Model\WebsiteFactory'], @@ -2549,7 +2549,8 @@ return array( ['Magento\OsInfo', 'Magento\Framework\OsInfo'], ['Magento\Registry', 'Magento\Framework\Registry'], ['Magento\Util', 'Magento\Framework\Util'], - ['Magento\BootstrapException', 'Magento\Framework\BootstrapException'], + ['Magento\BootstrapException', 'Magento\Framework\App\InitException'], + ['Magento\Framework\BootstrapException', 'Magento\Framework\App\InitException'], ['Magento\Checkout\Helper\Url'], [ 'Magento\Customer\Service\V1\CustomerCurrentService', @@ -2735,8 +2736,66 @@ return array( ['Magento\Catalog\Model\Observer\Reindex'], ['Magento\CatalogSearch\Model\Fulltext\Observer'], ['Magento\CatalogSearch\Model\Resource\Indexer\Fulltext'], + [ + 'Magento\Tax\Block\Adminhtml\Rate\Grid\Renderer\Country', + 'Magento\TaxImportExport\Block\Adminhtml\Rate\Grid\Renderer\Country' + ], + ['Magento\Tax\Block\Adminhtml\Rate\ImportExport', 'Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport'], + [ + 'Magento\Tax\Block\Adminhtml\Rate\ImportExportHeader', + 'Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExportHeader' + ], + ['Magento\Tax\Controller\Adminhtml\Rate\ExportCsv', 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportCsv'], + [ + 'Magento\Tax\Controller\Adminhtml\Rate\ExportPost', + 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportPost' + ], + ['Magento\Tax\Controller\Adminhtml\Rate\ExportXml', 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportXml'], + [ + 'Magento\Tax\Controller\Adminhtml\Rate\ImportExport', + 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ImportExport' + ], + [ + 'Magento\Tax\Controller\Adminhtml\Rate\ImportPost', + 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ImportPost' + ], + ['Magento\Tax\Model\Rate\CsvImportHandler', 'Magento\TaxImportExport\Model\Rate\CsvImportHandler'], ['\Magento\Theme\Helper\Layout'], ['Magento\Framework\Stdlib\Cookie', 'Magento\Framework\Stdlib\CookieManager'], + ['Magento\Framework\View\Design\Theme\Provider'], + ['Magento\Install\Controller\Index'], + ['Magento\Install\Controller\Wizard'], + ['Magento\Install\Controller\Wizard\Administrator'], + ['Magento\Install\Controller\Wizard\AdministratorPost'], + ['Magento\Install\Controller\Wizard\Begin'], + ['Magento\Install\Controller\Wizard\BeginPost'], + ['Magento\Install\Controller\Wizard\Config'], + ['Magento\Install\Controller\Wizard\ConfigPost'], + ['Magento\Install\Controller\Wizard\Download'], + ['Magento\Install\Controller\Wizard\DownloadAuto'], + ['Magento\Install\Controller\Wizard\DownloadManual'], + ['Magento\Install\Controller\Wizard\DownloadPost'], + ['Magento\Install\Controller\Wizard\End'], + ['Magento\Install\Controller\Wizard\Index'], + ['Magento\Install\Controller\Wizard\Install'], + ['Magento\Install\Controller\Wizard\InstallDb'], + ['Magento\Install\Controller\Wizard\Locale'], + ['Magento\Install\Controller\Wizard\LocaleChange'], + ['Magento\Install\Controller\Wizard\LocalePost'], + ['Magento\Install\App\Action\Plugin\Dir'], + ['\Magento\Framework\App\EntryPoint\EntryPoint', '\Magento\Framework\App\Bootstrap'], + ['\Magento\Framework\App\EntryPointInterface', '\Magento\Framework\App\Bootstrap'], + ['Magento\Framework\Module\FrontController\Plugin\Install', '\Magento\Framework\Module\Plugin\DbStatusValidator'], + ['Magento\Framework\Module\UpdaterInterface'], + ['Magento\Framework\App\EntryPoint\EntryPoint', 'Magento\Framework\App\Bootstrap'], + ['Magento\Framework\App\EntryPointInterface', 'Magento\Framework\App\Bootstrap'], + ['Magento\Install\Model\Installer\AbstractInstaller', 'Magento\Install\Model\Installer\Console'], + ['Magento\Install\App\Action\Plugin\Install', 'Magento\Framework\App\Bootstrap'], + ['\Magento\Cron\App\Cron\Plugin\ApplicationInitializer', 'Magento\Framework\App\Bootstrap'], + ['Magento\Framework\App\Error\Handler', 'Magento\Framework\App\Http'], + ['Magento\Framework\App\State\MaintenanceMode', 'Magento\Framework\App\MaintenanceMode'], + ['Magento\Framework\Error\Handler', 'Magento\Framework\App\ErrorHandler'], + ['Magento\Framework\Error\HandlerInterface', 'Magento\Framework\App\ErrorHandler'], ['\Magento\Framework\Service\Data\Eav\AbstractObject', 'Magento\Framework\Service\Data\AbstractExtensibleObject'], ['\Magento\Framework\Service\Data\AbstractObject', 'Magento\Framework\Service\Data\AbstractSimpleObject'], [ @@ -2747,4 +2806,5 @@ return array( '\Magento\Framework\Service\Data\AbstractObjectBuilder', 'Magento\Framework\Service\Data\AbstractSimpleObjectBuilder' ], + ['\Magento\Sales\Model\Observer'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 7d70048ad83bbe54ddc063cc81871bc789bd6464..4881dc984770d49470c880273c8c718180e72ad1 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -1035,8 +1035,8 @@ return array( array('getMigrationInstance', 'Magento\Customer\Model\Resource\Setup', '$this->_migrationFactory->create()'), array('turnOnReadCommittedMode', 'Magento\Backup\Model\Resource\Db'), array('turnOnSerializableMode', 'Magento\Backup\Model\Resource\Db', 'prepareTransactionIsolationLevel'), - array('turnOnMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\State::turnOnMaintenanceMode'), - array('turnOffMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\State::turnOffMaintenanceMode'), + array('turnOnMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\MaintenanceMode::set'), + array('turnOffMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\MaintenanceMode::set'), array('getMaintenanceFlagFilePath', 'Magento\Backup\Helper\Data',), array('_getResourceModel', '\Magento\Webapi\Model\Source\Acl\Role', '$this->_resource'), array('_getSession', '\Magento\GiftMessage\Model\Save', '$this->_session'), @@ -1688,9 +1688,9 @@ return array( 'getRatingSummary', 'Magento\Catalog\Model\Product' ), - ['getCurrentStore', 'Magento\Store\Model\StoreManagerInterface'], - ['getAnyStoreView', 'Magento\Store\Model\StoreManagerInterface'], - ['throwStoreException', 'Magento\Store\Model\StoreManagerInterface'], + ['getCurrentStore', 'Magento\Framework\StoreManagerInterface'], + ['getAnyStoreView', 'Magento\Framework\StoreManagerInterface'], + ['throwStoreException', 'Magento\Framework\StoreManagerInterface'], ['getCustomer', 'Magento\ProductAlert\Helper\Data'], ['addCustomerFilter', 'Magento\ProductAlert\Model\Resource\Stock\Collection'], ['addCustomerFilter', 'Magento\ProductAlert\Model\Resource\Price\Collection'], @@ -1804,6 +1804,7 @@ return array( ['getCalculator', '\Magento\Tax\Helper\Data'], ['getRatesForAllProductTaxClasses', 'Magento\Tax\Model\Calculation'], ['getRatesForAllCustomerTaxClasses', 'Magento\Tax\Model\Calculation'], + ['getMaxRecipients', 'Magento\Catalog\Block\Product\Send'], ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Observer'], ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Resource\Stock\Status'], ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Stock\Status'], @@ -1916,4 +1917,5 @@ return array( ['addTag', 'Magento\UrlRewrite\Model\UrlRewrite'], ['loadByTags', 'Magento\UrlRewrite\Model\UrlRewrite'], ['getMethodFormBlock', 'Magento\Centinel\Helper\Data'], + ['login', 'Magento\Customer\Model\Session'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php index 5756c6e27efc0cdf3d81bdfddbb2466baf7de921..5b203315d30ae454f6cc0c1c2a81bb3cadc08f7c 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php @@ -205,7 +205,6 @@ return array( array('_filesystem', 'Magento\Index\Model\Lock\Storage'), array('_coreDir', 'Magento\Sales\Model\Order\Pdf\AbstractPdf'), array('_coreDir', 'Magento\ScheduledImportExport\Model\Scheduled\Operation'), - array('_dir', 'Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler'), array('_dirs', 'Magento\Core\Block\Template'), array('_applicationDirs', 'Magento\Framework\App\Config\FileResolver'), array('_dir', 'Magento\Core\Model\File\Storage'), @@ -343,4 +342,7 @@ return array( ['_usageFactory', 'Magento\SalesRule\Model\Validator', 'Magento\SalesRule\Model\Validator\Utility'], ['_couponFactory', 'Magento\SalesRule\Model\Validator', 'Magento\SalesRule\Model\Validator\Utility'], ['_customerFactory', 'Magento\SalesRule\Model\Validator', 'Magento\SalesRule\Model\Validator\Utility'], + ['_skipModuleUpdate', '\Magento\Framework\Module\Updater'], + ['_factory', 'Magento\Framework\Module\Updater'], + ['_resourceList', 'Magento\Framework\Module\Updater'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php index 273663ecf30ef6c605044db1ec56f74c28190410..3e71f00bc9ee666ddd9534231c85e7da1dc1cf33 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php @@ -41,6 +41,11 @@ class LiveCodeTest extends PHPUnit_Framework_TestCase */ protected static $reportDir = ''; + /** + * @var string + */ + protected static $pathToSource = ''; + /** * @var array */ @@ -58,7 +63,8 @@ class LiveCodeTest extends PHPUnit_Framework_TestCase */ public static function setUpBeforeClass() { - self::$reportDir = Utility\Files::init()->getPathToSource() . '/dev/tests/static/report'; + self::$pathToSource = Utility\Files::init()->getPathToSource(); + self::$reportDir = self::$pathToSource . '/dev/tests/static/report'; if (!is_dir(self::$reportDir)) { mkdir(self::$reportDir, 0777); } @@ -163,23 +169,59 @@ class LiveCodeTest extends PHPUnit_Framework_TestCase /** * Run mess detector on code * + * @param array $whiteList * @return void + * @dataProvider whiteListDataProvider */ - public function testCodeMess() + public function testCodeMess($whiteList) { - $reportFile = self::$reportDir . '/phpmd_report.xml'; + if (count($whiteList) == 1) { + $formattedPath = preg_replace('~/~', '_', preg_replace('~' . self::$pathToSource . '~', '', $whiteList[0])); + } else { + $formattedPath = '_app_lib'; + } + $reportFile = self::$reportDir . '/phpmd_report' . $formattedPath . '.xml'; $codeMessDetector = new CodeMessDetector(realpath(__DIR__ . '/_files/phpmd/ruleset.xml'), $reportFile); if (!$codeMessDetector->canRun()) { $this->markTestSkipped('PHP Mess Detector is not available.'); } - self::setupFileLists(); $this->assertEquals( PHP_PMD_TextUI_Command::EXIT_SUCCESS, - $codeMessDetector->run(self::$whiteList, self::$blackList), + $codeMessDetector->run($whiteList, self::$blackList), "PHP Code Mess has found error(s): See detailed report in {$reportFile}" ); + + // delete empty reports + unlink($reportFile); + } + + /** + * To improve the test execution performance the whitelist is split into smaller parts: + * - in case of dev code (tests, tools, etc) each whitelist entry is fed separately to phpmd + * - app/lib code is still being executed within a single whitelist to make sure that all design + * metrics (depth of inheritance, number of children, etc.) are being calculated in a correct way. + * @return array + */ + public function whiteListDataProvider() + { + $whiteList = array(); + $testCodePattern = '~' . self::$pathToSource . '/dev/~'; + $nonTestCode = array(); + + self::setupFileLists(); + + foreach (self::$whiteList as $path) { + if (!preg_match($testCodePattern, $path)) { + $nonTestCode[] = $path; + } else { + $whiteList[] = array(array($path)); + } + } + $whiteList[] = array($nonTestCode); + + return $whiteList; } /** diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt index d3afb38c3ad3f02f440bf7b2ae3c6bdff35f9aef..e232e29d8656bb8fb639739db506905a75adadf3 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt @@ -55,6 +55,8 @@ app/code/Magento/Directory/Helper app/code/Magento/Customer/Block app/code/Magento/Customer/Controller app/code/Magento/Customer/Helper +app/code/Magento/Customer/Model/Visitor.php +app/code/Magento/Customer/Model/Resource/Visitor.php app/code/Magento/Customer/Model/Address/Config app/code/Magento/Customer/Model/Address/Config.php app/code/Magento/Customer/Service @@ -111,6 +113,7 @@ app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php app/code/Magento/Sales/Model/Observer app/code/Magento/Sales/Model/Quote/Address/*Interface.php app/code/Magento/SalesRule/Model/Plugin +app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.php app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/Invoice.php app/code/Magento/Shipping/Model/Observer.php app/code/Magento/Shipping/Model/Order/Track.php @@ -123,12 +126,14 @@ app/code/Magento/UrlRedirect app/code/Magento/Wishlist/Block/Link.php dev/shell dev/tests/functional -dev/tests/integration +dev/tests/integration/* dev/tests/js dev/tests/performance dev/tests/static -dev/tests/unit +dev/tests/unit/framework +dev/tests/unit/testsuite/Magento/* dev/tools +lib/internal/Magento/Framework/App lib/internal/Magento/Framework/Backup/Db lib/internal/Magento/Framework/Backup/Factory.php lib/internal/Magento/Framework/Cache/Core.php @@ -136,13 +141,10 @@ lib/internal/Magento/Framework/Convert lib/internal/Magento/Framework/Exception lib/internal/Magento/Framework/Stdlib/DateTime.php lib/internal/Magento/Framework/Object.php -lib/internal/Magento/Framework/App lib/internal/Magento/Framework/Data/Argument lib/internal/Magento/Framework/ObjectManager lib/internal/Magento/Framework/Service lib/internal/Magento/Framework/Url/SecurityInfoInterface.php lib/internal/Magento/Framework/View -lib/internal/Magento/Framework/App/AbstractShell.php lib/internal/Magento/Framework/Locale/Validator.php lib/internal/Magento/Framework/Notification -lib/internal/Magento/Framework/App/Config diff --git a/dev/tests/unit/framework/bootstrap.php b/dev/tests/unit/framework/bootstrap.php index 0c1c92c6fb547445a03e65d8b216b8f546e3933d..ece247a7124fd4121b813d1ece68f8d97f048fe8 100755 --- a/dev/tests/unit/framework/bootstrap.php +++ b/dev/tests/unit/framework/bootstrap.php @@ -23,12 +23,10 @@ */ if (!defined('TESTS_TEMP_DIR')) { - define('BP', realpath(__DIR__ . '/../../../../')); define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp'); } - +require __DIR__ . '/../../../../app/autoload.php'; require BP . '/app/functions.php'; -require BP . '/app/autoload.php'; (new \Magento\Framework\Autoload\IncludePath())->addIncludePath( array( __DIR__, diff --git a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php index 4caf84c382a9cf5339f79b5f4dc618ad7611a760..da98e1d5f05ba60e7ed65ee79d266f7fdd951f0a 100644 --- a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php +++ b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php @@ -66,7 +66,7 @@ class BaseurlTest extends \PHPUnit_Framework_TestCase $this->_configMock = $this->getMock('Magento\Framework\App\Config', array(), array(), '', false); $this->_urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface'); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $configFactoryMock = $this->getMock( 'Magento\Framework\App\Config\ValueFactory', array('create'), diff --git a/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php b/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php index 2033b7d3282aa22949a2180c45f78e03772350a5..b82649a3438a6569eeee8a7d6658cd46f6d3a944 100644 --- a/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php +++ b/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php @@ -24,16 +24,41 @@ namespace Magento\Authorization\Model; +use Magento\TestFramework\Helper\ObjectManager; +use \Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + class CompositeUserContextTest extends \PHPUnit_Framework_TestCase { /** * @var CompositeUserContext */ - protected $_model; + protected $userContext; + + /** + * @var CompositeHelper + */ + protected $compositeHelperMock; + + /** + * @var ObjectManager + */ + protected $objectManager; protected function setUp() { - $this->_model = new CompositeUserContext(); + $this->objectManager = new ObjectManager($this); + $this->compositeHelperMock = $this->getMockBuilder('Magento\Framework\ObjectManager\Helper\Composite') + ->disableOriginalConstructor() + ->setMethods(['filterAndSortDeclaredComponents']) + ->getMock(); + $this->compositeHelperMock + ->expects($this->any()) + ->method('filterAndSortDeclaredComponents') + ->will($this->returnArgument(0)); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock] + ); } public function testConstructor() @@ -45,7 +70,10 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $model = new CompositeUserContext($contexts); + $model = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); $this->verifyUserContextIsAdded($model, $userContextMock); } @@ -63,8 +91,11 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $this->_model = new CompositeUserContext($contexts); - $actualUserId = $this->_model->getUserId(); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); + $actualUserId = $this->userContext->getUserId(); $this->assertEquals($expectedUserId, $actualUserId, 'User ID is defined incorrectly.'); } @@ -82,8 +113,11 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $this->_model = new CompositeUserContext($contexts); - $actualUserType = $this->_model->getUserType(); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); + $actualUserType = $this->userContext->getUserType(); $this->assertEquals($expectedUserType, $actualUserType, 'User Type is defined incorrectly.'); } @@ -103,11 +137,14 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $this->_model = new CompositeUserContext($contexts); - $this->_model->getUserId(); - $this->_model->getUserId(); - $this->_model->getUserType(); - $this->_model->getUserType(); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); + $this->userContext->getUserId(); + $this->userContext->getUserId(); + $this->userContext->getUserType(); + $this->userContext->getUserType(); } public function testEmptyUserContext() @@ -123,45 +160,11 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $this->_model = new CompositeUserContext($contexts); - $actualUserId = $this->_model->getUserId(); - $this->assertEquals($expectedUserId, $actualUserId, 'User ID is defined incorrectly.'); - } - - public function testUserContextOrder() - { - $expectedUserId = null; - $userContextMock1 = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') - ->disableOriginalConstructor()->setMethods(['getUserType'])->getMock(); - $userContextMock1->expects($this->once())->method('getUserType')->will($this->returnValue(null)); - - $userContextMock2 = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') - ->disableOriginalConstructor()->setMethods(['getUserType'])->getMock(); - $userContextMock2->expects($this->once())->method('getUserType')->will($this->returnValue(null)); - - $expectedUserType = 'Customer'; - $expectedUserId = 1234; - $userContextMock3 = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') - ->disableOriginalConstructor()->setMethods(['getUserType', 'getUserId'])->getMock(); - $userContextMock3->expects($this->once())->method('getUserType')->will($this->returnValue($expectedUserType)); - $userContextMock3->expects($this->exactly(2))->method('getUserId')->will($this->returnValue($expectedUserId)); - - $contexts = [ - [ - 'sortOrder' => 20, - 'type' => $userContextMock1 - ], - [ - 'sortOrder' => 30, - 'type' => $userContextMock3, - ], - [ - 'sortOrder' => 10, - 'type' => $userContextMock2 - ], - ]; - $this->_model = new CompositeUserContext($contexts); - $actualUserId = $this->_model->getUserId(); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); + $actualUserId = $this->userContext->getUserId(); $this->assertEquals($expectedUserId, $actualUserId, 'User ID is defined incorrectly.'); } diff --git a/dev/tests/unit/testsuite/Magento/Authorizenet/Model/Directpost/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Authorizenet/Model/Directpost/ObserverTest.php index 6334978d52bd862f8dc6979be73b6ae245937551..5c21e4ed6eb64b5d282a468a6aeb2d0bc121a297 100644 --- a/dev/tests/unit/testsuite/Magento/Authorizenet/Model/Directpost/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Authorizenet/Model/Directpost/ObserverTest.php @@ -45,7 +45,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->coreRegistry = $this->getMock('Magento\Framework\Registry', array()); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $payment = $this->getMock('Magento\Authorizenet\Model\Directpost', null, array(), '', false); $this->coreData = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php index a0dbec84e0534bfc8d334540cc12f5d32fdbc9a5..aa990ca1064046e628a21fa1af0fea15d8e886b1 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php @@ -22,14 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Test class for \Magento\Backend\AdminConfig - */ namespace Magento\Backend; -use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; +/** + * Test class for \Magento\Backend\AdminConfig + * + */ class AdminConfigTest extends \PHPUnit_Framework_TestCase { /** @@ -38,9 +38,9 @@ class AdminConfigTest extends \PHPUnit_Framework_TestCase private $requestMock; /** - * @var \Magento\Framework\App\State + * @var \Magento\TestFramework\Helper\ObjectManager */ - private $appState; + private $objectManager; protected function setUp() @@ -61,9 +61,7 @@ class AdminConfigTest extends \PHPUnit_Framework_TestCase )->will( $this->returnValue('init.host') ); - $this->appState = $this->getMock('\Magento\Framework\App\State', - ['isInstalled'], [], '', false, false); - $this->appState->expects($this->atLeastOnce())->method('isInstalled')->will($this->returnValue(true)); + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); } public function testSetCookiePathNonDefault() @@ -72,20 +70,35 @@ class AdminConfigTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $mockFrontNameResolver + $mockFrontNameResolver->expects($this->once()) ->method('getFrontName') ->will($this->returnValue('backend')); - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $adminConfig = $objectManager->getObject( + $adminConfig = $this->objectManager->getObject( 'Magento\Backend\AdminConfig', [ 'request' => $this->requestMock, - 'appState' => $this->appState, 'frontNameResolver' => $mockFrontNameResolver, ] ); $this->assertEquals('/backend', $adminConfig->getCookiePath()); } + + /** + * Test for setting session name for admin + * + */ + public function testSetSessionNameByConstructor() + { + $sessionName = 'admin'; + $adminConfig = $this->objectManager->getObject( + 'Magento\Backend\AdminConfig', + [ + 'request' => $this->requestMock, + 'sessionName' => $sessionName + ] + ); + $this->assertSame($sessionName, $adminConfig->getName()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php index a4bbdaf3b6edc02c9c35c0311e809c1f9a01be56..ee7a5c05ea7bfdf8285714e5b1c6b530ad2a5096 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php @@ -67,7 +67,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_localeMock = $this->getMock('Magento\Framework\Locale\CurrencyInterface'); $this->_requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php index e3f89ef42253a0c49a056527c97aff85d92ce3e8..1b33c677fd2bf937ffa23264bc38a6b126922637 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php @@ -66,7 +66,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected $_dataFactoryMock; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -130,7 +130,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase false ); - $this->_storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $this->_model = new \Magento\Backend\Model\Config( $this->_appConfigMock, diff --git a/dev/tests/unit/testsuite/Magento/Backup/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Backup/Helper/DataTest.php index a15a786a7db12ac29a822c22c43ac987c2fe1763..7bd62bd4ec65fe7f546bc64e41753e5420c758ba 100644 --- a/dev/tests/unit/testsuite/Magento/Backup/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Backup/Helper/DataTest.php @@ -24,7 +24,7 @@ namespace Magento\Backup\Helper; use Magento\Framework\App\Filesystem; -use Magento\Framework\App\State\MaintenanceMode; +use Magento\Framework\App\MaintenanceMode; class DataTest extends \PHPUnit_Framework_TestCase { @@ -92,7 +92,7 @@ class DataTest extends \PHPUnit_Framework_TestCase [ '.git', '.svn', - 'var/maintenance.flag', + 'var/' . MaintenanceMode::FLAG_FILENAME, Filesystem::SESSION_DIR, Filesystem::CACHE_DIR, Filesystem::LOG_DIR, @@ -119,7 +119,7 @@ class DataTest extends \PHPUnit_Framework_TestCase [ '.svn', '.git', - 'var/maintenance.flag', + 'var/' . MaintenanceMode::FLAG_FILENAME, Filesystem::SESSION_DIR, Filesystem::LOG_DIR, Filesystem::VAR_DIR . '/locks', diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php index 81bfb88cce58caefb4caba5e8424de1bda81191a..c3910a8d66ce75b502f40e0186e0d376724b1caa 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php @@ -57,7 +57,7 @@ class CatalogPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->commonPriceMock = $this->getMock( 'Magento\Catalog\Model\Product\CatalogPrice', array(), diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php index 16b3a626b3f79af9de05810b536087f935b41f46..407ae918420116cacf3c232a9d0641fc74a7d790 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php @@ -74,7 +74,7 @@ class PriceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->localeDateMock = $this->getMock('\Magento\Framework\Stdlib\DateTime\TimezoneInterface'); $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', array(), array(), '', false); $this->eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessorTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ee717b611c0f2cf4222d8c42f8e7f9c1af0042cc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessorTest.php @@ -0,0 +1,129 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Bundle\Service\V1\Product; + +use Magento\TestFramework\Helper\ObjectManager; + +class BundleProductLoadProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Bundle\Service\V1\Product\BundleProductLoadProcessor + */ + private $model; + + /** + * @var \Magento\Catalog\Model\ProductRepository|\PHPUnit_Framework_MockObject_MockObject + */ + private $productRepository; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $product; + + /** + * @var \Magento\Bundle\Service\V1\Product\Option\ReadService|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionReadService; + + /** + * @var \Magento\Catalog\Service\V1\Data\ProductBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $productBuilder; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->productRepository = $this->getMockBuilder('Magento\Catalog\Model\ProductRepository') + ->setMethods(['get']) + ->disableOriginalConstructor() + ->getMock(); + + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['getSku', 'getTypeId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionReadService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Option\ReadService') + ->disableOriginalConstructor() + ->getMock(); + + $this->productBuilder = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductBuilder') + ->setMethods(['setCustomAttribute']) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $helper->getObject( + 'Magento\Bundle\Service\V1\Product\BundleProductLoadProcessor', + [ + 'optionReadService' => $this->optionReadService, + 'productRepository' => $this->productRepository, + ] + ); + } + + public function testLoadNotBundleProduct() + { + $productId = 'test_id'; + + $this->productRepository->expects($this->once()) + ->method('get') + ->with($productId) + ->will($this->returnValue($this->product)); + $this->product->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)); + + $this->model->load($productId, $this->productBuilder); + } + + public function testLoadBundleProduct() + { + $productId = 'test_id'; + $productSku = 'test_sku'; + + $this->productRepository->expects($this->once()) + ->method('get') + ->with($productId) + ->will($this->returnValue($this->product)); + $this->product->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + $this->product->expects($this->once()) + ->method('getSku') + ->will($this->returnValue($productSku)); + + $optionCustomAttributeValue = ['a', 'b']; + $this->optionReadService->expects($this->once()) + ->method('getList') + ->with($productSku) + ->will($this->returnValue($optionCustomAttributeValue)); + $this->productBuilder->expects($this->at(0)) + ->method('setCustomAttribute') + ->with('bundle_product_options', $optionCustomAttributeValue); + + $this->model->load($productId, $this->productBuilder); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bfde3221bccb2995fd82d0e83c01b66b40d849d0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php @@ -0,0 +1,302 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Bundle\Service\V1\Product; + +use Magento\TestFramework\Helper\ObjectManager; +use Magento\Catalog\Model\Product\Type as ProductType; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class BundleProductSaveProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Bundle\Service\V1\Product\BundleProductSaveProcessor + */ + private $saveProcessor; + + /** + * @var \Magento\Catalog\Model\ProductRepository|\PHPUnit_Framework_MockObject_MockObject + */ + private $productRepository; + + /** + * @var \Magento\Catalog\Service\V1\Data\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $productData; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $product; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Link|\PHPUnit_Framework_MockObject_MockObject + */ + private $productLink1; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Link|\PHPUnit_Framework_MockObject_MockObject + */ + private $productLink2; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Link|\PHPUnit_Framework_MockObject_MockObject + */ + private $productLink3; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $productOption1; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $productOption2; + + /** + * @var \Magento\Bundle\Service\V1\Product\Link\WriteService|\PHPUnit_Framework_MockObject_MockObject + */ + private $linkWriteService; + + /** + * @var \Magento\Bundle\Service\V1\Product\Option\WriteService|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionWriteService; + + /** + * @var \Magento\Bundle\Service\V1\Product\Link\ReadService|\PHPUnit_Framework_MockObject_MockObject + */ + private $linkReadService; + + /** + * @var \Magento\Bundle\Service\V1\Product\Option\ReadService|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionReadService; + + /** + * @var \Magento\Catalog\Service\V1\Data\ProductBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $productBuilder; + + /** + * @var \Magento\Framework\Service\Data\Eav\AttributeValue|\PHPUnit_Framework_MockObject_MockObject + */ + private $attributeValue; + + protected function setup() + { + $helper = new ObjectManager($this); + + $this->productRepository = $this->getMockBuilder('Magento\Catalog\Model\ProductRepository') + ->setMethods(['get']) + ->disableOriginalConstructor() + ->getMock(); + + $this->productData = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->setMethods(['getSku', 'getTypeId', '__wakeup', 'getCustomAttribute']) + ->disableOriginalConstructor() + ->getMock(); + + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['getSku', 'getTypeId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->productLink1 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link') + ->disableOriginalConstructor() + ->setMethods(['getId', 'getSku', 'getOptionId']) + ->getMock(); + $this->productLink1->expects($this->any()) + ->method('getSku') + ->will($this->returnValue('productLink1Sku')); + $this->productLink2 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link') + ->disableOriginalConstructor() + ->setMethods(['getId', 'getSku', 'getOptionId']) + ->getMock(); + $this->productLink2->expects($this->any()) + ->method('getSku') + ->will($this->returnValue('productLink2Sku')); + $this->productLink3 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link') + ->disableOriginalConstructor() + ->setMethods(['getId', 'getSku']) + ->getMock(); + $this->productLink3->expects($this->any()) + ->method('getSku') + ->will($this->returnValue('productLink3Sku')); + + $this->productOption1 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Option') + ->disableOriginalConstructor() + ->getMock(); + $this->productOption1->expects($this->any()) + ->method('getId') + ->will($this->returnValue('productOption1Sku')); + $this->productOption2 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Option') + ->disableOriginalConstructor() + ->getMock(); + $this->productOption2->expects($this->any()) + ->method('getId') + ->will($this->returnValue('productOption2Sku')); + + $this->linkWriteService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Link\WriteService') + ->disableOriginalConstructor() + ->getMock(); + + $this->optionWriteService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Option\WriteService') + ->disableOriginalConstructor() + ->getMock(); + + $this->linkReadService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Link\ReadService') + ->disableOriginalConstructor() + ->getMock(); + + $this->optionReadService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Option\ReadService') + ->disableOriginalConstructor() + ->getMock(); + + $this->productBuilder = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductBuilder') + ->setMethods(['setCustomAttribute']) + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeValue = $this->getMockBuilder('Magento\Framework\Service\Data\Eav\AttributeValue') + ->setMethods(['getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $this->saveProcessor = $helper->getObject( + 'Magento\Bundle\Service\V1\Product\BundleProductSaveProcessor', + [ + 'linkWriteService' => $this->linkWriteService, + 'optionWriteService' => $this->optionWriteService, + 'linkReadService' => $this->linkReadService, + 'optionReadService' => $this->optionReadService, + 'productRepository' => $this->productRepository, + ] + ); + } + + public function testCreate() + { + $productSku = 'sku'; + $productOptions = [$this->productOption1, $this->productOption2]; + + $this->product->expects($this->any()) + ->method('getSku') + ->will($this->returnValue($productSku)); + $this->product->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_BUNDLE)); + + $this->productData->expects($this->once()) + ->method('getCustomAttribute') + ->with('bundle_product_options') + ->will($this->returnValue($this->attributeValue)); + $this->attributeValue->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($productOptions)); + + $this->optionWriteService->expects($this->at(0)) + ->method('add') + ->with($productSku, $this->productOption1) + ->will($this->returnValue(1)); + $this->optionWriteService->expects($this->at(1)) + ->method('add') + ->with($productSku, $this->productOption2) + ->will($this->returnValue(2)); + + $this->assertEquals($productSku, $this->saveProcessor->create($this->product, $this->productData)); + $this->assertEquals($productSku, $this->saveProcessor->afterCreate($this->product, $this->productData)); + } + + public function testUpdate() + { + $product1Sku = 'sku1'; + $productOption1Sku = 'productOption1Sku'; + $productOption2Sku = 'productOption2Sku'; + $product1Options = [$this->productOption1, $this->productOption2]; + + $product2Options = [$this->productOption1]; + + $this->productRepository->expects($this->once()) + ->method('get') + ->with($product1Sku, true) + ->will($this->returnValue($this->product)); + $this->product->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_BUNDLE)); + + $this->optionReadService->expects($this->once()) + ->method('getList') + ->with($product1Sku) + ->will($this->returnValue($product1Options)); + $this->productData->expects($this->once()) + ->method('getCustomAttribute') + ->with('bundle_product_options') + ->will($this->returnValue($this->attributeValue)); + $this->attributeValue->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($product2Options)); + $this->productOption1->expects($this->any()) + ->method('getId') + ->will($this->returnValue($productOption1Sku)); + $this->productOption2->expects($this->any()) + ->method('getId') + ->will($this->returnValue($productOption2Sku)); + $this->optionWriteService->expects($this->once()) + ->method('remove') + ->with($product1Sku, $productOption2Sku) + ->will($this->returnValue(1)); + + $this->assertEquals($product1Sku, $this->saveProcessor->update($product1Sku, $this->productData)); + } + + public function testDelete() + { + $productSku = 'sku1'; + $productOptions = [$this->productOption1]; + $productOption1Sku = 'productOption1Sku'; + + $this->productData->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_BUNDLE)); + $this->productData->expects($this->once()) + ->method('getSku') + ->will($this->returnValue($productSku)); + $this->productData->expects($this->once()) + ->method('getCustomAttribute') + ->with('bundle_product_options') + ->will($this->returnValue($this->attributeValue)); + $this->attributeValue->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($productOptions)); + $this->optionWriteService->expects($this->once()) + ->method('remove') + ->with($productSku, $productOption1Sku) + ->will($this->returnValue(1)); + $this->saveProcessor->delete($this->productData); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/ReadServiceTest.php index 2f262ccd0ac3e7234658da5bac5dbc7eb10e8a5c..64a8228cbf056bcfe4af6c7e332ac00fe8275eaf 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/ReadServiceTest.php @@ -44,9 +44,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase private $product; /** - * @var \Magento\Bundle\Service\V1\Data\Product\Link\MetadataConverter|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Bundle\Service\V1\Data\Product\LinkConverter|\PHPUnit_Framework_MockObject_MockObject */ - private $metadataConverter; + private $linkConverter; /** * @var \Magento\Bundle\Model\Product\Type\Interceptor|\PHPUnit_Framework_MockObject_MockObject @@ -69,9 +69,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase private $option; /** - * @var \Magento\Bundle\Service\V1\Data\Product\Link\Metadata|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Bundle\Service\V1\Data\Product\Link|\PHPUnit_Framework_MockObject_MockObject */ - private $metadata; + private $link; private $storeId = 2; @@ -110,12 +110,12 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->metadata = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link\Metadata') + $this->link = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link') ->disableOriginalConstructor() ->getMock(); - $this->metadataConverter = $this->getMockBuilder( - 'Magento\Bundle\Service\V1\Data\Product\Link\MetadataConverter' + $this->linkConverter = $this->getMockBuilder( + 'Magento\Bundle\Service\V1\Data\Product\LinkConverter' ) ->setMethods(['createDataFromModel']) ->disableOriginalConstructor() @@ -125,7 +125,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase 'Magento\Bundle\Service\V1\Product\Link\ReadService', [ 'productRepository' => $this->productRepository, - 'metadataConverter' => $this->metadataConverter + 'linkConverter' => $this->linkConverter ] ); } @@ -157,11 +157,11 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->option->expects($this->any())->method('getSelections')->will($this->returnValue([$this->product])); - $this->metadataConverter->expects($this->once())->method('createDataFromModel') + $this->linkConverter->expects($this->once())->method('createDataFromModel') ->with($this->equalTo($this->product), $this->equalTo($this->product)) - ->will($this->returnValue($this->metadata)); + ->will($this->returnValue($this->link)); - $this->assertEquals([$this->metadata], $this->model->getChildren($productSku)); + $this->assertEquals([$this->link], $this->model->getChildren($productSku)); } /** @@ -177,7 +177,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->product->expects($this->once())->method('getTypeId')->will($this->returnValue('simple')); - $this->assertEquals([$this->metadata], $this->model->getChildren($productSku)); + $this->assertEquals([$this->link], $this->model->getChildren($productSku)); } private function getOptions() diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/WriteServiceTest.php index 5b8e693b8bd1ff04cc70004372a71284c2f35af6..b59a8aba9ddfb4c9f13599cb3b794e98511756d9 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/WriteServiceTest.php @@ -52,7 +52,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected $optionCollectionFactoryMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -97,7 +97,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false + '\Magento\Framework\StoreManagerInterface', array(), array(), '', false ); $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') @@ -137,8 +137,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildToNotBundleProduct() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -158,8 +159,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildNonExistingOption() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -208,9 +210,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildLinkedProductIsComposite() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -274,9 +277,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildProductAlreadyExistsInOption() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -344,9 +348,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildCouldNotSave() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -421,9 +426,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChild() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/ReadServiceTest.php index 0a6a3a975d17766e99bab9e7b915313406b356e9..e734af2def4cb608d28072ee6d960af8eecb36ff 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/ReadServiceTest.php @@ -82,7 +82,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') - ->setMethods(['__wakeup', 'getTypeId', 'getTypeInstance']) + ->setMethods(['__wakeup', 'getTypeId', 'getTypeInstance', 'getStoreId']) ->disableOriginalConstructor() ->getMock(); @@ -106,6 +106,28 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $productType = $this->getMockBuilder('Magento\Bundle\Model\Product\Type') + ->setMethods(['setStoreFilter', 'getSelectionsCollection']) + ->disableOriginalConstructor() + ->getMock(); + $this->product->expects($this->any()) + ->method('getTypeInstance') + ->will($this->returnValue($productType)); + $selectionsCollection = $this->getMockBuilder('Magento\Bundle\Model\Resource\Selection\Collection') + ->setMethods(['getIterator']) + ->disableOriginalConstructor() + ->getMock(); + $productType->expects($this->any()) + ->method('getSelectionsCollection') + ->will($this->returnValue($selectionsCollection)); + $iterator = $this->getMockBuilder('Iterator') + ->setMethods(['getNext']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $selectionsCollection->expects($this->any()) + ->method('getIterator') + ->will($this->returnValue($iterator)); + $this->model = $objectManager->getObject( 'Magento\Bundle\Service\V1\Product\Option\ReadService', [ diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php index 4c7620a2bb538a432b4fb9954d60eedf55f18a0e..4079abca16e32ad8998e92bd777e7e58a1080383 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php @@ -81,7 +81,7 @@ class HelperTest extends \PHPUnit_Framework_TestCase $this->jsHelperMock = $this->getMock('Magento\Backend\Helper\Js', array(), array(), '', false); $this->storeMock = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', array(), array(), '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->stockFilterMock = $this->getMock( 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Category/ViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Category/ViewTest.php index 73a8d6c998421f15a6af360a7e96b9ca4abcb1ac..362131c79657215b0e842c540ad1cf47ff48febf 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Category/ViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Category/ViewTest.php @@ -93,7 +93,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected $store; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; @@ -154,7 +154,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase $this->categoryFactory = $this->getMock('Magento\Catalog\Model\CategoryFactory', ['create'], [], '', false); $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $this->catalogDesign = $this->getMock('Magento\Catalog\Model\Design', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Helper/Product/Flat/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Helper/Product/Flat/IndexerTest.php index f8c70e06c0d39172cde6bffcd20227fdced85448..4b959c1ab33590b44721b5506f036fd867e95dd2 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Helper/Product/Flat/IndexerTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Helper/Product/Flat/IndexerTest.php @@ -36,7 +36,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_storeManagerMock; @@ -91,7 +91,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase $eavFactoryMock = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', array(), array(), '', false); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_connectionMock = $this->getMock( 'Magento\Framework\DB\Adapter\Pdo\Mysql', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ConfigTest.php index 69fab2654ee1bfcc8753f47ad6a177515f15619a..1e52ec3d6e5b910a788285632e7d746688c0dfae 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ConfigTest.php @@ -240,7 +240,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $attribute->expects($this->any())->method('getStoreLabel')->will($this->returnValue($storeLabel)); $attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode)); - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface'); $store = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue($storeId)); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/EraserTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/EraserTest.php index f21da8f4874c75110687d4493b89e7c0800457b3..55f333c5a798601d7ccb54bf2c154b76d00690ff 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/EraserTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/EraserTest.php @@ -64,7 +64,7 @@ class EraserTest extends \PHPUnit_Framework_TestCase array(2, 'store_2_flat'), ))); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->model = new \Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser( $resource, $this->indexerHelper, diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php index a85f6a2a6c59c7854a08f443bcf98c284303f1cb..bf9a82905cf502c80d47ced21907a8cb3798dd85 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php @@ -81,7 +81,7 @@ class RowTest extends \PHPUnit_Framework_TestCase $this->resource->expects($this->any())->method('getConnection') ->with('default') ->will($this->returnValue($this->connection)); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->store->expects($this->any())->method('getId')->will($this->returnValue('store_id_1')); $this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue(array($this->store))); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/ObserverTest.php index bec88d18600840ac066b58065522f6e1cb758513..e72ca34b3d6726c789db86848999c17add7e74d3 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/ObserverTest.php @@ -36,7 +36,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_storeManagerMock; @@ -70,7 +70,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php index ef9bb39d9772882934b203a02ebb85866d428c4e..e1e7dc870344747ee94512fc746406d900085fb1 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php @@ -55,7 +55,7 @@ class PriceScopeTest extends \PHPUnit_Framework_TestCase $contextMock = $this->getMock('Magento\Framework\Model\Context', array(), array(), '', false); $registryMock = $this->getMock('Magento\Framework\Registry', array(), array(), '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/FilterableAttributeListTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/FilterableAttributeListTest.php index 7cd6d53bb376ece6db69010f0939e3ecc57ecd3c..aa3305eff96d4500627059fb59d98aab96b043c5 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/FilterableAttributeListTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/FilterableAttributeListTest.php @@ -52,7 +52,7 @@ class FilterableAttributeListTest extends \PHPUnit_Framework_TestCase '\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory', array('create'), array(), '', false); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false + '\Magento\Framework\StoreManagerInterface', array(), array(), '', false ); $this->layerMock = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/StateKeyTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/StateKeyTest.php index 7552c2b6d8b79e090fda61c84563d0422895447c..274ef3f54e13958c7560001833c26c4c99e07d6e 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/StateKeyTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/StateKeyTest.php @@ -43,7 +43,7 @@ class StateKeyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', array(), array(), '', false); $this->model = new StateKey($this->storeManagerMock, $this->customerSessionMock); } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/CollectionFilterTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/CollectionFilterTest.php index 4e6697923485262dacde3c09a7183ab2671a7719..a2ba39af8f323fb50fcbfd64941d15eee5e7b47f 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/CollectionFilterTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/CollectionFilterTest.php @@ -56,7 +56,7 @@ class CollectionFilterTest extends \PHPUnit_Framework_TestCase $this->visibilityMock = $this->getMock('Magento\Catalog\Model\Product\Visibility', array(), array(), '', false); $this->catalogConfigMock = $this->getMock('\Magento\Catalog\Model\Config', array(), array(), '', false); $this->helperMock = $this->getMock('\Magento\CatalogSearch\Helper\Data', array(), array(), '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->model = new CollectionFilter( $this->catalogConfigMock, $this->helperMock, $this->storeManagerMock, $this->visibilityMock diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/FilterableAttributeListTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/FilterableAttributeListTest.php index 33c8811c8c5f6c8406c425ad4d2525201f9a653e..61fb9fca6ac6c9072f9938ac2a994f2c1acb5ae7 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/FilterableAttributeListTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/FilterableAttributeListTest.php @@ -52,7 +52,7 @@ class FilterableAttributeListTest extends \PHPUnit_Framework_TestCase '\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory', array('create'), array(), '', false); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false + '\Magento\Framework\StoreManagerInterface', array(), array(), '', false ); $this->layerMock = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/StateKeyTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/StateKeyTest.php index a799898a55d36c7f2943c993f693a72210557b0d..849614cd90346751cd7d463ab86ff3ab7386f924 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/StateKeyTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/StateKeyTest.php @@ -48,7 +48,7 @@ class StateKeyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', array(), array(), '', false); $this->helperMock = $this->getMock('\Magento\CatalogSearch\Helper\Data', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php index 5c75256055c929eff949c9d27483f9c1e4276983..2ef6965d466ab03ff0716b83bf07ce1fdb45bdff 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php @@ -51,7 +51,7 @@ class LayerTest extends \PHPUnit_Framework_TestCase private $registry; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $storeManager; @@ -131,7 +131,7 @@ class LayerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->setMethods(['getStore']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php index 6c4de178bc87f0cc0b0f72d9d9e8cce05d821d68..a11d85e686c2bd1f81d1ea55725c6482441dc702 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php @@ -44,7 +44,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $loggerMock = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); $currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', array(), array(), '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false); $configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Frontend/ImageTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Frontend/ImageTest.php index 5def7e22bc2b04bba6402f1f5c0f7f996a5a48ba..6015c8d121104c50fd8630d232a266323990c98d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Frontend/ImageTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Frontend/ImageTest.php @@ -68,13 +68,13 @@ class ImageTest extends \PHPUnit_Framework_TestCase } /** - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface */ private function getMockedStoreManager() { $mockedStore = $this->getMockedStore(); - $mockBuilder = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface'); + $mockBuilder = $this->getMockBuilder('\Magento\Framework\StoreManagerInterface'); $mock = $mockBuilder->setMethods(['getStore']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Source/CountryofmanufactureTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Source/CountryofmanufactureTest.php index 40bba460bfc916421042ae607729ecf6145e9eac..15d148650c1a79385c881b174b9d072602b51cc7 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Source/CountryofmanufactureTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Source/CountryofmanufactureTest.php @@ -26,7 +26,7 @@ namespace Magento\Catalog\Model\Product\Attribute\Source; class CountryofmanufactureTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -47,7 +47,7 @@ class CountryofmanufactureTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', array(), array(), '', false); $this->cacheConfig = $this->getMock('\Magento\Framework\App\Cache\Type\Config', array(), array(), '', false); $this->objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ImageTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ImageTest.php index 924d39fe4818050e0f34cfa47e04cc2d94829015..09819abf92b4640691db781b9c686cb1f6e582a5 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ImageTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ImageTest.php @@ -48,7 +48,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected $registry; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php index 3f440009fd954564a5949327472b7d59fcc127cc..0e4140e5b1ad30a8f5b7f2aa08f5d8a44e921619 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php @@ -92,7 +92,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase $store = $this->getMock('Magento\Store\Model\Store', ['getId', '__wakeup'], [], '', false); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php index 0ee7ff05b4156cd77902b32c73c0c8e6fe81d684..6803d90bc60e80a21dea29f52769b60878cc9f3e 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php @@ -184,7 +184,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMockForAbstractClass(); $storeManager->expects($this->any()) diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php index bd83e8080035f609e598c2372b2e279449bf5651..80c2c68ba0d7bc70b4212d8b05108a9c0a7025c6 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php @@ -106,7 +106,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Framework\Locale\FormatInterface'), $this->getMock('Magento\Eav\Model\Resource\Helper', array(), array(), '', false, false), $this->getMock('Magento\Framework\Validator\UniversalFactory', array(), array(), '', false, false), - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), + $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false), $this->getMock('Magento\Catalog\Model\Factory', array(), array(), '', false), array() ) diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php index 9be7df61744a839582fb3bd3f9a75aa43a9d3874..76c0505d3c830e278f38aa205bcfda08baec4c0c 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php @@ -96,7 +96,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Entity\TypeFactory', array(), array(), '', false), - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), + $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Resource\Helper', array(), array(), '', false), $this->getMock('Magento\Framework\Validator\UniversalFactory', array(), array(), '', false), $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php index b7ef3e30b3ee0562894e19b8c417ec1378a11b17..444e06eb0daba59c1d9ceecfe7e5a3ee4eee7659 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php @@ -36,7 +36,7 @@ class FlatTest extends \PHPUnit_Framework_TestCase protected $_store; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManagerInterface; @@ -44,7 +44,7 @@ class FlatTest extends \PHPUnit_Framework_TestCase { $this->_store = $this->getMock('\Magento\Store\Model\Store', array(), array(), '', false); - $this->_storeManagerInterface = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerInterface = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->_storeManagerInterface->expects( $this->any() diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php index 05b4c4a99e8d0aa930251d7f4e9b1e4cc9992a04..7589571542139012f43f40f27f72ece5834ace4f 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php @@ -65,7 +65,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Validator\UniversalFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $universalFactoryMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; /** @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ @@ -108,7 +108,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase $entity->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([])); $this->universalFactoryMock = $this->getMock('Magento\Framework\Validator\UniversalFactory', [], [], '', false); $this->universalFactoryMock->expects($this->any())->method('create')->will($this->returnValue($entity)); - $this->storeManagerMock = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $this->storeManagerMock ->expects($this->any()) ->method('getStore') diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php index 3a0a0bdfe1e1541f570f8aea7fa0b27368876819..4dc6aaa0f192e97f9aebe510d05ee3d1a1eab6cb 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php @@ -56,7 +56,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected $optionsFactoryMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/TreeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/TreeTest.php index 469d333c07f67e30c53a5bc8f3a7c07eb8f19974..9c2faa09e2deb065cc2b4664e5c40414e1602aab 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/TreeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/TreeTest.php @@ -35,7 +35,7 @@ class TreeTest extends \PHPUnit_Framework_TestCase protected $categoryTreeMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -74,7 +74,7 @@ class TreeTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadServiceTest.php index 48506b08ed76eb069349deeac681b4f2ae04c511..013f4a664192cb4cb316cc37fd1de4d54e11f404 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadServiceTest.php @@ -124,7 +124,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->storeMock = $this->getMock('\Magento\Store\Model\Store', array(), array(), '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock)); $this->setFactoryMock = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php index f65de7c82496cbcf2db5c8dcdec6d64fc519c789..eaebb5347943cda4370205678857f6c90e235e36 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php @@ -88,7 +88,7 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeManagerMock = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder('\Magento\Framework\StoreManagerInterface') ->setMethods(['getWebsite']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductLoadProcessorCompositeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductLoadProcessorCompositeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d08fe87792a2622cf41700b885bf71f656f67bb7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductLoadProcessorCompositeTest.php @@ -0,0 +1,140 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; +use Magento\TestFramework\Helper\ObjectManager; + +class ProductLoadProcessorCompositeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CompositeHelper + */ + protected $compositeHelperMock; + + /** + * @var ObjectManager + */ + protected $objectManager; + + /** @var \Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite $loadProcessor */ + protected $loadProcessor; + + /** @var \Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite $loadProcessorMock */ + protected $loadProcessorMock; + + protected $processors; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + $this->compositeHelperMock = $this->getMockBuilder('Magento\Framework\ObjectManager\Helper\Composite') + ->disableOriginalConstructor() + ->setMethods(['filterAndSortDeclaredComponents']) + ->getMock(); + $this->compositeHelperMock + ->expects($this->any()) + ->method('filterAndSortDeclaredComponents') + ->will($this->returnArgument(0)); + $this->loadProcessorMock = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite') + ->disableOriginalConstructor() + ->setMethods(['load']) + ->getMock(); + $this->processors = [ + [ + 'sortOrder' => 10, + 'type' => $this->loadProcessorMock + ] + ]; + $this->loadProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'loadProcessors' => $this->processors] + ); + } + + public function testConstructor() + { + $loadProcessorMock = $this->createProductLoadProcessorCompositeMock(); + $processors = [ + [ + 'sortOrder' => 10, + 'type' => $loadProcessorMock + ] + ]; + $compositeProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'loadProcessors' => $processors] + ); + $this->verifyLoadProcessorIsAdded($compositeProcessor, $loadProcessorMock); + } + + public function testLoad() + { + $productSku = '5'; + $productDataBuilder = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductBuilder') + ->disableOriginalConstructor() + ->getMock(); + $this->loadProcessorMock + ->expects($this->once()) + ->method('load') + ->with($productSku, $productDataBuilder); + $loadProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'loadProcessors' => $this->processors] + ); + $loadProcessor->load($productSku, $productDataBuilder); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function createProductLoadProcessorCompositeMock() + { + $productLoadProcessorCompositeMock = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite') + ->disableOriginalConstructor() + ->setMethods(['load']) + ->getMock(); + $productLoadProcessorCompositeMock->expects($this->any())->method('load'); + return $productLoadProcessorCompositeMock; + } + + /** + * @param ProductLoadProcessorInterface $compositeProcessor + * @param ProductLoadProcessorInterface $loadProcessorMock + */ + protected function verifyLoadProcessorIsAdded($compositeProcessor, $loadProcessorMock) + { + $loadProcessor = new \ReflectionProperty( + 'Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite', + 'productLoadProcessors' + ); + $loadProcessor->setAccessible(true); + $values = $loadProcessor->getValue($compositeProcessor); + $this->assertCount(1, $values, 'Load Processor is not registered.'); + $this->assertEquals($loadProcessorMock, $values[0], 'Load Processor is registered incorrectly.'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductSaveProcessorCompositeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductSaveProcessorCompositeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c109c97e5eae50e8287b9ad06ea62d259842daa0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductSaveProcessorCompositeTest.php @@ -0,0 +1,200 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; +use Magento\TestFramework\Helper\ObjectManager; + +class ProductSaveProcessorCompositeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CompositeHelper + */ + protected $compositeHelperMock; + + /** + * @var ObjectManager + */ + protected $objectManager; + + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessor */ + protected $saveProcessor; + + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessorMock */ + protected $saveProcessorMock; + + protected $processors; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + $this->compositeHelperMock = $this->getMockBuilder('Magento\Framework\ObjectManager\Helper\Composite') + ->disableOriginalConstructor() + ->setMethods(['filterAndSortDeclaredComponents']) + ->getMock(); + $this->compositeHelperMock + ->expects($this->any()) + ->method('filterAndSortDeclaredComponents') + ->will($this->returnArgument(0)); + $this->saveProcessorMock = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite') + ->disableOriginalConstructor() + ->setMethods(['create', 'update', 'delete']) + ->getMock(); + $this->processors = [ + [ + 'sortOrder' => 10, + 'type' => $this->saveProcessorMock + ] + ]; + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessor */ + $this->saveProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'saveProcessors' => $this->processors] + ); + } + + public function testConstructor() + { + $saveProcessorMock = $this->createProductSaveProcessorCompositeMock(); + $processors = [ + [ + 'sortOrder' => 10, + 'type' => $saveProcessorMock + ] + ]; + $model = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'saveProcessors' => $processors] + ); + $this->verifySaveProcessorIsAdded($model, $saveProcessorMock); + } + + + public function testCreate() + { + $expectedSku = 'test'; + $product = $this + ->getMockBuilder('\Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + $productData = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $productData->expects($this->once())->method('getSku')->will($this->returnValue($expectedSku)); + + $this->saveProcessorMock + ->expects($this->once()) + ->method('create') + ->with($product, $productData) + ->will($this->returnValue($expectedSku)); + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessor */ + $saveProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'saveProcessors' => $this->processors] + ); + + $actualSku = $saveProcessor->create($product, $productData); + $this->assertEquals($expectedSku, $actualSku, 'Save processor is not created'); + } + + public function testDelete() + { + $expectedSku = 'test'; + $productData = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $this->saveProcessorMock + ->expects($this->once()) + ->method('delete') + ->with($productData) + ->will($this->returnValue($expectedSku)); + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessor */ + $saveProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'saveProcessors' => $this->processors] + ); + $saveProcessor->delete($productData); + } + + public function testUpdate() + { + $expectedSku = 'test'; + $actualSku = '5'; + $productData = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $productData->expects($this->once())->method('getSku')->will($this->returnValue($expectedSku)); + + $this->saveProcessorMock + ->expects($this->once()) + ->method('update') + ->with($actualSku, $productData) + ->will($this->returnValue($expectedSku)); + + $this->assertEquals( + $expectedSku, + $this->saveProcessor->update(5, $productData), + 'Save processor is updated incorrectly' + ); + } + + /** + * @param string|null $sku + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function createProductSaveProcessorCompositeMock($sku = null) + { + $productSaveProcessorCompositeMock = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite') + ->disableOriginalConstructor() + ->setMethods(['create', 'update']) + ->getMock(); + if (!is_null($sku)) { + $productSaveProcessorCompositeMock->expects($this->any())->method('create')->will($this->returnValue($sku)); + $productSaveProcessorCompositeMock->expects($this->any())->method('update')->will($this->returnValue($sku)); + } + return $productSaveProcessorCompositeMock; + } + + /** + * @param ProductSaveProcessorInterface $model + * @param ProductSaveProcessorInterface $saveProcessorMock + */ + protected function verifySaveProcessorIsAdded($model, $saveProcessorMock) + { + $saveProcessor = new \ReflectionProperty( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + 'productSaveProcessors' + ); + $saveProcessor->setAccessible(true); + $values = $saveProcessor->getValue($model); + $this->assertCount(1, $values, 'Save Processor is not registered.'); + $this->assertEquals($saveProcessorMock, $values[0], 'Save Processor is registered incorrectly.'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php index b8e46e7697194d5927a3801d8f8d2bcbea22c97e..8fd0c94936d4a5c04983229f2d2053e4bfbd8b30 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php @@ -88,7 +88,7 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->groupServiceMock = $this->getMock('\Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', array('getId', '__wakeup'), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php index 5630dc19d696b144978c16d2ab4af4ae529114e7..f7a41371eb7c0a9aab6b52e280e1e16fae9a83b3 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php @@ -130,7 +130,22 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $this->_productMock->expects($this->at(0))->method('getIdBySku')->will($this->returnValue($productId)); $this->_productMock->expects($this->at(1))->method('load')->with($productId); - $productService = $this->_createService(); + + $productData = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $this->converterMock->expects($this->once()) + ->method('createProductDataFromModel') + ->with($this->_productMock) + ->will($this->returnValue($productData)); + + $productService = $this->_objectManager->getObject( + 'Magento\Catalog\Service\V1\ProductService', + [ + 'productLoader' => $this->_productLoaderMock, + 'converter' => $this->converterMock, + ] + ); $this->assertTrue($productService->delete($productSku)); } @@ -200,8 +215,8 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $productDataBuilder->setSku('test'); $productDataBuilder->setStoreId(10); $this->converterMock->expects($this->once()) - ->method('createProductDataFromModel') - ->will($this->returnValue($productDataBuilder->create())); + ->method('createProductBuilderFromModel') + ->will($this->returnValue($productDataBuilder)); $this->searchResultsBuilderMock->expects($this->once()) ->method('setItems') @@ -243,7 +258,13 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $this->_productMock->expects($this->at(0))->method('getIdBySku')->will($this->returnValue($productId)); $this->_productMock->expects($this->at(1))->method('load')->with($productId); - $this->converterMock->expects($this->once())->method('createProductDataFromModel')->with($this->_productMock); + $productDataBuilder = $this->getMockBuilder('\Magento\Catalog\Service\V1\Data\ProductBuilder') + ->disableOriginalConstructor() + ->getMock(); + $this->converterMock->expects($this->once()) + ->method('createProductBuilderFromModel') + ->with($this->_productMock) + ->will($this->returnValue($productDataBuilder)); $productService = $this->_objectManager->getObject( 'Magento\Catalog\Service\V1\ProductService', @@ -312,8 +333,8 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $initializationHelper->expects($this->once())->method('initialize')->with($productModel); - $productModel->expects($this->once())->method('validate'); - $productModel->expects($this->once())->method('save'); + $productModel->expects($this->any())->method('validate'); + $productModel->expects($this->any())->method('save'); $productSku = 'sku-001'; $productModel->expects($this->once())->method('getId')->will($this->returnValue(100)); @@ -481,8 +502,8 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $initializationHelper->expects($this->once())->method('initialize')->with($productModel); $productTypeManager->expects($this->once())->method('processProduct')->with($productModel); - $productModel->expects($this->once())->method('validate'); - $productModel->expects($this->once())->method('save'); + $productModel->expects($this->any())->method('validate'); + $productModel->expects($this->any())->method('save'); $productSku = 'sku-001'; $productModel->expects($this->any())->method('getSku')->will($this->returnValue($productSku)); diff --git a/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Import/Product/Type/OptionTest.php b/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Import/Product/Type/OptionTest.php index 4a9fc61ffaf771d2e7ad844752838ea1b18cdf3b..fadb811e3443fb1229a20fe7698fca6ccbc915dd 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Import/Product/Type/OptionTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Import/Product/Type/OptionTest.php @@ -242,7 +242,7 @@ class OptionTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\ImportExport\Model\Resource\Import\Data', array(), array(), '', false), $this->getMock('Magento\Framework\App\Resource', array(), array(), '', false), $this->getMock('Magento\ImportExport\Model\Resource\Helper', array(), array(), '', false), - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), + $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false), $this->getMock('Magento\Catalog\Model\ProductFactory', array(), array(), '', false), $this->getMock( 'Magento\Catalog\Model\Resource\Product\Option\CollectionFactory', diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php index 6bb83f07178cb312193f7073d3433211398b3757..884e9acce54a8b0ab56b561339484de8e6897896 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php @@ -62,7 +62,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase /** @var \Magento\CatalogInventory\Helper\Minsaleqty|\PHPUnit_Framework_MockObject_MockObject */ protected $catalogInventoryMinsaleqty; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; /** @var \Magento\CatalogInventory\Model\Stock\ItemRegistry|\PHPUnit_Framework_MockObject_MockObject */ @@ -113,7 +113,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase false ); $this->scopeConfig = $this->getMock('Magento\Framework\App\Config', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); $this->stockItemRegistry = $this->getMock( '\Magento\CatalogInventory\Model\Stock\ItemRegistry', diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/RuleTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/RuleTest.php index a8420516f5d3fa18c9be8a41ba9a493d94750d5a..fdc6ff3dedd95a12202ab4ddfa86c4f942dd22ab 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/RuleTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/RuleTest.php @@ -34,7 +34,7 @@ class RuleTest extends \PHPUnit_Framework_TestCase /** @var ObjectManagerHelper */ protected $objectManagerHelper; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; /** @var \PHPUnit_Framework_MockObject_MockObject */ @@ -51,7 +51,7 @@ class RuleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->storeModel = $this->getMock('Magento\Store\Model\Store', array('__wakeup', 'getId'), array(), '', false); $this->combineFactory = $this->getMock( 'Magento\CatalogRule\Model\Rule\Condition\CombineFactory', diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Helper/DataTest.php index a262d04375402597b946f441fc88de53a15b2281..92993c9df6b8684c340ed3bd6bb51d009d37e81c 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogSearch/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Helper/DataTest.php @@ -64,7 +64,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected $_filterManagerMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_storeManagerMock; @@ -76,7 +76,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->_escaperMock = $this->getMock('Magento\Framework\Escaper'); $this->_filterManagerMock = $this->getMock('Magento\Framework\Filter\FilterManager', [], [], '', false); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_model = new \Magento\CatalogSearch\Helper\Data( $this->_contextMock, diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Controller/CartTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Controller/CartTest.php index 1d41272b6b9a2b4d1ab7c32bd3b45de2bb962b2d..d8eba0c3fffdf466fd3a440a4ee082f55a07ca84 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Controller/CartTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Controller/CartTest.php @@ -36,7 +36,7 @@ class CartTest extends \PHPUnit_Framework_TestCase public function testGoBack() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $responseMock = $this->getMock('Magento\Framework\App\Response\Http', array(), array(), '', false); $responseMock->headersSentThrowsException = false; diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Controller/Onepage/IndexTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Controller/Onepage/IndexTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c1bcb590b012cf5ce81d216f603966f3428f418e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Controller/Onepage/IndexTest.php @@ -0,0 +1,217 @@ +<?php +/** + * Test for \Magento\Checkout\Controller\Onepage\Index + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Controller\Onepage; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManager; + +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + private $objectManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $dataMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $onepageMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $layoutMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $redirectMock; + + /** + * @var \Magento\Checkout\Controller\Onepage\Index + */ + private $model; + + public function setUp() + { + // mock objects + $this->objectManager = new ObjectManager($this); + $this->objectManagerMock = $this->basicMock('\Magento\Framework\ObjectManager'); + $this->dataMock = $this->basicMock('Magento\Checkout\Helper\Data'); + $this->quoteMock = $this->basicMock('\Magento\Sales\Model\Quote'); + $this->contextMock = $this->basicMock('\Magento\Framework\App\Action\Context'); + $this->sessionMock = $this->basicMock('\Magento\Customer\Model\Session'); + $this->onepageMock = $this->basicMock('\Magento\Checkout\Model\Type\Onepage'); + $this->viewMock = $this->basicMock('\Magento\Framework\App\ViewInterface'); + $this->layoutMock = $this->basicMock('\Magento\Framework\View\Layout'); + $this->requestMock = $this->basicMock('\Magento\Framework\App\RequestInterface'); + $this->responseMock = $this->basicMock('\Magento\Framework\App\ResponseInterface'); + $this->redirectMock = $this->basicMock('\Magento\Framework\App\Response\RedirectInterface'); + + // stubs + $this->basicStub($this->onepageMock, 'getQuote')->willReturn($this->quoteMock); + $this->basicStub($this->viewMock, 'getLayout')->willReturn($this->layoutMock); + $this->basicStub($this->layoutMock, 'getBlock') + ->willReturn($this->basicMock('Magento\Theme\Block\Html\Head')); + + // objectManagerMock + $objectManagerReturns = [ + ['Magento\Checkout\Helper\Data', $this->dataMock], + ['Magento\Checkout\Model\Type\Onepage', $this->onepageMock], + ['Magento\Checkout\Model\Session', $this->basicMock('Magento\Checkout\Model\Session')], + ['Magento\Customer\Model\Session', $this->basicMock('Magento\Customer\Model\Session')], + + ]; + $this->objectManagerMock->expects($this->any()) + ->method('get') + ->will($this->returnValueMap($objectManagerReturns)); + $this->basicStub($this->objectManagerMock, 'create') + ->willReturn($this->basicMock('Magento\Framework\UrlInterface')); + // context stubs + $this->basicStub($this->contextMock, 'getObjectManager')->willReturn($this->objectManagerMock); + $this->basicStub($this->contextMock, 'getView')->willReturn($this->viewMock); + $this->basicStub($this->contextMock, 'getRequest')->willReturn($this->requestMock); + $this->basicStub($this->contextMock, 'getResponse')->willReturn($this->responseMock); + $this->basicStub($this->contextMock, 'getMessageManager') + ->willReturn($this->basicMock('\Magento\Framework\Message\ManagerInterface')); + $this->basicStub($this->contextMock, 'getRedirect')->willReturn($this->redirectMock); + + + // SUT + $this->model = $this->objectManager->getObject('\Magento\Checkout\Controller\Onepage\Index', + [ + 'context' => $this->contextMock, + 'customerSession' => $this->sessionMock, + ] + ); + } + + public function testRegenerateSessionIdOnExecute() + { + //Stubs to control execution flow + $this->basicStub($this->dataMock, 'canOnepageCheckout')->willReturn(true); + $this->basicStub($this->quoteMock, 'hasItems')->willReturn(true); + $this->basicStub($this->quoteMock, 'getHasError')->willReturn(false); + $this->basicStub($this->quoteMock, 'validateMinimumAmount')->willReturn(true); + + //Expected outcomes + $this->sessionMock->expects($this->once()) + ->method('regenerateId'); + $this->viewMock->expects($this->once()) + ->method('renderLayout'); + + $this->model->execute(); + } + + public function testOnepageCheckoutNotAvailable() + { + + $this->basicStub($this->dataMock, 'canOnepageCheckout')->willReturn(false); + + $expectedPath = 'checkout/cart'; + $this->redirectMock->expects($this->once()) + ->method('redirect') + ->with($this->responseMock, $expectedPath, []); + + $this->model->execute(); + } + + public function testInvalidQuote() + { + $this->basicStub($this->quoteMock, 'hasError')->willReturn(true); + + $expectedPath = 'checkout/cart'; + $this->redirectMock->expects($this->once()) + ->method('redirect') + ->with($this->responseMock, $expectedPath, []); + + $this->model->execute(); + } + + /** + * @param \PHPUnit_Framework_MockObject_MockObject $mock + * @param string $method + * + * @return \PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + private function basicStub($mock, $method) + { + return $mock->expects($this->any()) + ->method($method) + ->withAnyParameters(); + } + + /** + * @param string $className + * @return \PHPUnit_Framework_MockObject_MockObject + */ + private function basicMock($className) + { + return $this->getMockBuilder($className) + ->disableOriginalConstructor() + ->getMock(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php index b3c40a76ad5a8f112d1219b6c10bffb437718a7d..d3e1ff07b1546cabba3e163ea40d338356a3b1dc 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php @@ -88,7 +88,7 @@ class CartTest extends \PHPUnit_Framework_TestCase $contextMock = $this->getMock('\Magento\Framework\App\Helper\Context', [], [], '', false); $contextMock->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($this->urlBuilderMock)); $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->coreHelperMock = $this->getMock('\Magento\Core\Helper\Data', [], [], '', false); $this->scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); $this->cartMock = $this->getMock('\Magento\Checkout\Model\Cart', [], [], '', false); @@ -219,7 +219,7 @@ class CartTest extends \PHPUnit_Framework_TestCase */ public function testGetDeletePostJson($id, $url, $isAjax, $expectedPostData) { - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $coreData = $this->getMock('\Magento\Core\Helper\Data', [], [], '', false); $scopeConfig = $this->getMockForAbstractClass('\Magento\Framework\App\Config\ScopeConfigInterface'); $checkoutCart = $this->getMock('\Magento\Checkout\Model\Cart', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php index d1adc7cb5b258625d017e444bbf35d560e064a6c..47c9115bf6399bc53b72f03e7b1db8f866c8c0b2 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php @@ -141,7 +141,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ) ); - $this->_storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $this->_checkoutSession = $this->getMock('\Magento\Checkout\Model\Session', array(), array(), '', false); @@ -379,7 +379,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $rowTotal = 15; $roundPrice = 17; $expected = 17; - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface', array(), array(), '', false); $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', @@ -444,7 +444,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testGetBasePriceInclTaxWithoutQty() { - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface', array(), array(), '', false); $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', @@ -466,7 +466,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testGetBasePriceInclTax() { - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface', array(), array(), '', false); $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php index ea5e864eba9b16fdbaa5ba0339165ca55382a870..147c7fe1436c1b41ffafd8ad261b1d6354eaa2c5 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php @@ -177,7 +177,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase $quoteFactory = $this->getMock('Magento\Sales\Model\QuoteFactory', array('create'), array(), '', false); $storage = $this->getMock('Magento\Framework\Session\Storage', null); $store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $eventManager = $this->getMockForAbstractClass('Magento\Framework\Event\ManagerInterface'); @@ -299,7 +299,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase ->method('getWebsiteId') ->will($this->returnValue($websiteId)); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any()) ->method('getStore') ->will($this->returnValue($store)); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php index 93c4e8b2c07c191a4fe489f3974d2227846d6f59..17d9a4bdd583ae67530febf5901a2627e9f86530 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -56,7 +56,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ protected $customerSessionMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; /** @var \Magento\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -113,7 +113,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', ['getLastOrderId', 'getQuote', 'setStepData', 'getStepData'], [], '', false); $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->requestMock = $this->getMock( 'Magento\Framework\App\RequestInterface', ['isAjax', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'] diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php index 8dc87b47f2f631010ef45886372147abf6d70661..58b0718f83b6b864deb7fef157edd8b7ff2e118f 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php @@ -50,7 +50,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); $this->service = new ReadService($this->quoteLoaderMock, $this->converterMock, $this->storeManagerMock); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php index 64bb4c6ffaba991b760f93abb80554b9ce6ad257..93bf3f8e14df0ad18cb31b8e6d52b740cd1ae786 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php @@ -70,7 +70,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->addressFactoryMock = $this->getMock( '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php index 9c9f4f83871e4bbd503e9d7a1162181dedc80e7d..180ebe591443ee0d55c045c3e4211f49b956aa2f 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php @@ -50,7 +50,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php index f51418ace4340005309e5e039f769fbba8d5bae7..c25c0e7b708eac23de7af21cef9e0b2b238dbe9a 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php @@ -70,7 +70,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->addressFactoryMock = $this->getMock( '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php index cdfe50596c66e5d56caa49317792e216e4e1f0b3..5b5a3fa5a5126bedddbb2653ddc1c74ce8c59b6c 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php @@ -71,7 +71,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock = $this->getMock( '\Magento\Sales\Model\QuoteFactory', ['create', '__wakeup'], [], '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface', [], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $this->quoteMock = diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php index b6a5e41231e2e6b6bc64354ff0264bdb160f9598..c88416c1b27a85e3df642c8e1e1ddaf0cb2ed978 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php @@ -53,7 +53,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->couponBuilderMock = $this->getMock( '\Magento\Checkout\Service\V1\Data\Cart\CouponBuilder', [], [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php index 30585e2f9b659088ac80b59d538119bca1c32400..584de65681b697f808347c125c67adcd0537710f 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php @@ -71,7 +71,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase { $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->couponBuilderMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CouponBuilder', [], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php index 746adf0ee7fc1367d29306353b6db286c72e6821..09d3eb7aa2131610fd388ce424dc36f5ea0b621e 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php @@ -67,7 +67,7 @@ class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->builderMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->currencyMock = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $this->shippingMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethod', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php index 15278615af603fb6a62a735e964eb369ae251310..fe9d54fe9bf1ab503c783b197fe0718d2a701eb9 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php @@ -66,7 +66,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->quoteMethodConverterMock = $this->getMock( '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter', [], [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php index 86888e9abc7c5f91e2287d025dd975d1e7ce922c..28767afa9877436d5e5cc030c4a3444efe29bf7a 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php @@ -66,7 +66,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->paymentMethodBuilderMock = $this->getMock( '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder', [], [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php index ebcf79294b9cba95016034493f9c5ab643eeb87a..8d805647cca9295fc06c5e057c73dbfc96d0dd00 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php @@ -79,7 +79,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->methodBuilderMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', [], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php index 26e8390fd82d88db75a642be21f516fc5b4b2d6f..cdea76c91af328fadd205eb4a2e77793d201e1a3 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php @@ -67,7 +67,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->addressFactoryMock = $this->getMock('\Magento\Sales\Model\Quote\AddressFactory', [], [], '', false); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->quoteMock = $this->getMock( '\Magento\Sales\Model\Quote', [ diff --git a/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php index acea4656774e9254ac5984b0210a3fc3fb9abc3b..c6711a9e705880e8c6781b2fbb1e8c94b5a8ae02 100644 --- a/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php @@ -76,7 +76,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->service = new ReadService( $this->factoryMock, diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php index ffc5ba421f75a8bf17c068d6777b3ae8267acc9e..189639f8ab2ca5f361bd97710c03e36fa7725a5d 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php @@ -239,7 +239,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->_model->canUseAttribute($attribute)); } - public function testgetUsedProducts() + public function testGetUsedProducts() { $attributeCollection = $this->getMockBuilder( '\Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection' @@ -290,4 +290,81 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($productCollection)); $this->_model->getUsedProducts($product); } -} \ No newline at end of file + + /** + * @param int $productStore + * @param int $attributeStore + * + * @dataProvider getConfigurableAttributesAsArrayDataProvider + */ + public function testGetConfigurableAttributesAsArray($productStore, $attributeStore) + { + $attributeSource = $this->getMockForAbstractClass( + 'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource', + array(), + '', + false, + true, + true, + array('getAllOptions') + ); + $attributeSource->expects($this->any())->method('getAllOptions')->will($this->returnValue([])); + + $attributeFrontend = $this->getMockForAbstractClass( + 'Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend', + array(), + '', + false, + true, + true, + array('getLabel') + ); + $attributeFrontend->expects($this->any())->method('getLabel')->will($this->returnValue('Label')); + + $eavAttribute = $this->getMock( + 'Magento\Catalog\Model\Resource\Eav\Attribute', + array('getFrontend', 'getSource', 'getStoreLabel', '__wakeup', 'setStoreId', '__sleep'), + array(), + '', + false + ); + $eavAttribute->expects($this->any())->method('getFrontend')->will($this->returnValue($attributeFrontend)); + $eavAttribute->expects($this->any())->method('getSource')->will($this->returnValue($attributeSource)); + $eavAttribute->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Store Label')); + $eavAttribute->expects($this->any())->method('setStoreId')->with($attributeStore); + + $attribute = $this->getMockBuilder('\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute') + ->disableOriginalConstructor() + ->setMethods(['getProductAttribute', '__wakeup', '__sleep']) + ->getMock(); + $attribute->expects($this->any())->method('getProductAttribute')->will($this->returnValue($eavAttribute)); + + $product = $this->getMockBuilder('\Magento\Catalog\Model\Product') + ->setMethods(['getStoreId', 'getData', 'hasData', '__wakeup', '__sleep']) + ->disableOriginalConstructor() + ->getMock(); + $product->expects($this->any())->method('getStoreId')->will($this->returnValue($productStore)); + $product->expects($this->any())->method('hasData') + ->will($this->returnValueMap([ + ['_cache_instance_configurable_attributes', 1], + ])); + $product->expects($this->any())->method('getData') + ->will($this->returnValueMap([ + ['_cache_instance_configurable_attributes', null, [$attribute]], + ])); + + $result = $this->_model->getConfigurableAttributesAsArray($product); + $this->assertCount(1, $result); + } + + /** + * @return array + */ + public function getConfigurableAttributesAsArrayDataProvider() + { + return array( + array(5, 5), + array(null, 0), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php index 53e459fceebed62c1594a18b5157fdb0b929c907..02a376721264830fb6db5db3d31f4e11f632fb3b 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php @@ -65,7 +65,7 @@ class AttributePriceTest extends \PHPUnit_Framework_TestCase protected $regularPriceMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php index 9c311e2a7b5521c693ae693d1931fdc0cd8656f1..feaaac019cd48db9b9315f2c139ebe3ad7e8488d 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php @@ -147,7 +147,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); $storeManagerMock->expects($this->any()) ->method('getStore') ->will($this->returnValue(new \Magento\Framework\Object())); diff --git a/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/IndexTest.php b/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/IndexTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9d67a7f81ffdac279aea6172a19b4c21326c85c3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/IndexTest.php @@ -0,0 +1,136 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Contact\Controller\Index; + +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Controller\Index\Index|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_controller; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_scopeConfig; + + /** + * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_view; + + /** + * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_url; + + public function setUp() + { + $this->_scopeConfig = $this->getMockForAbstractClass( + '\Magento\Framework\App\Config\ScopeConfigInterface', ['isSetFlag'], '', false + ); + $context = $this->getMock( + '\Magento\Framework\App\Action\Context', + ['getRequest', 'getResponse', 'getView', 'getUrl'], + [], + '', + false + ); + + $this->_url = $this->getMockForAbstractClass('\Magento\Framework\UrlInterface', [], '', false); + + $context->expects($this->any()) + ->method('getUrl') + ->will($this->returnValue($this->_url)); + + $context->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false) + )); + + $context->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface', [], '', false) + )); + + $this->_view = $this->getMock( + '\Magento\Framework\App\ViewInterface', + [], + [], + '', + false + ); + + $context->expects($this->once()) + ->method('getView') + ->will($this->returnValue($this->_view)); + + $this->_controller = new \Magento\Contact\Controller\Index\Index( + $context, + $this->getMock('\Magento\Framework\Mail\Template\TransportBuilder', [], [], '', false), + $this->getMockForAbstractClass('\Magento\Framework\Translate\Inline\StateInterface', [], '', false), + $this->_scopeConfig, + $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface', [], '', false) + ); + } + + public function testExecute() + { + $layout = $this->getMock( + '\Magento\Framework\View\Layout', + ['getBlock', 'initMessages'], + [], + '', + false + ); + $block = $this->getMockForAbstractClass( + '\Magento\Framework\View\Element\AbstractBlock', + ['setFormAction'], + '', + false + ); + $layout->expects($this->once()) + ->method('getBlock') + ->with('contactForm') + ->will($this->returnValue($block)); + + $this->_view->expects($this->once()) + ->method('loadLayout'); + + $this->_view->expects($this->exactly(2)) + ->method('getLayout') + ->will($this->returnValue($layout)); + + $layout->expects($this->once()) + ->method('initMessages'); + + $this->_view->expects($this->once()) + ->method('renderLayout'); + + $this->_controller->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/PostTest.php b/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/PostTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3e40b619580f23453cf620375c28bf2002ed4b0c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/PostTest.php @@ -0,0 +1,254 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Contact\Controller\Index; + +class PostTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Controller\Index\Index|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_controller; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_scopeConfig; + + /** + * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_view; + + /** + * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_url; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_request; + + /** + * @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_redirect; + + /** + * @var \Magento\Framework\Mail\Template\TransportBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_transportBuilder; + + /** + * @var \Magento\Framework\Translate\Inline\StateInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_inlineTranslation; + + /** + * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_messageManager; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_storeManager; + + public function setUp() + { + $this->_scopeConfig = $this->getMockForAbstractClass( + '\Magento\Framework\App\Config\ScopeConfigInterface', + ['isSetFlag'], + '', + false + ); + $context = $this->getMock( + '\Magento\Framework\App\Action\Context', + ['getRequest', 'getResponse', 'getView', 'getUrl', 'getRedirect', 'getMessageManager'], + [], + '', + false + ); + $this->_url = $this->getMock('\Magento\Framework\UrlInterface', [], [], '', false); + $this->_messageManager = $this->getMock('\Magento\Framework\Message\ManagerInterface', [], [], '', false); + $this->_request = $this->getMock('\Magento\Framework\App\Request\Http', ['getPost'], [], '', false); + $this->_redirect = $this->getMock('\Magento\Framework\App\Response\RedirectInterface', [], [], '', false); + $this->_view = $this->getMock('\Magento\Framework\App\ViewInterface', [], [], '', false); + $this->_storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface', [], [], '', false); + $this->_transportBuilder = $this->getMock( + '\Magento\Framework\Mail\Template\TransportBuilder', + [], + [], + '', + false + ); + $this->_inlineTranslation = $this->getMock( + '\Magento\Framework\Translate\Inline\StateInterface', + [], + [], + '', + false + ); + $context->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->_request)); + + $context->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue( + $this->getMock('\Magento\Framework\App\ResponseInterface', [], [], '', false) + )); + + $context->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->_messageManager)); + + $context->expects($this->any()) + ->method('getUrl') + ->will($this->returnValue($this->_url)); + + $context->expects($this->any()) + ->method('getRedirect') + ->will($this->returnValue($this->_redirect)); + + $context->expects($this->once()) + ->method('getView') + ->will($this->returnValue($this->_view)); + + $this->_controller = new \Magento\Contact\Controller\Index\Post( + $context, + $this->_transportBuilder, + $this->_inlineTranslation, + $this->_scopeConfig, + $this->_storeManager + ); + } + + public function testExecuteEmptyPost() + { + $this->_request->expects($this->once())->method('getPost')->will($this->returnValue([])); + $this->_redirect->expects($this->once())->method('redirect'); + $this->_controller->execute(); + } + + /** + * @dataProvider testPostDataProvider + */ + public function testExecutePostValidation($postData, $exceptionExpected) + { + $this->_request->expects($this->any()) + ->method('getPost') + ->will($this->returnValue($postData)); + + if ($exceptionExpected) { + $this->_messageManager->expects($this->once()) + ->method('addError'); + } + $this->_inlineTranslation->expects($this->once()) + ->method('resume'); + + $this->_inlineTranslation->expects($this->once()) + ->method('suspend'); + + $this->_controller->execute(); + } + + public function testPostDataProvider() + { + return [ + [['name' => null, 'comment' => null, 'email' => '', 'hideit' => 'no'], true], + [['name' => 'test', 'comment' => '', 'email' => '', 'hideit' => 'no'], true], + [['name' => '', 'comment' => 'test', 'email' => '', 'hideit' => 'no'], true], + [['name' => '', 'comment' => '', 'email' => 'test', 'hideit' => 'no'], true], + [['name' => '', 'comment' => '', 'email' => '', 'hideit' => 'no'], true], + [['name' => 'Name', 'comment' => 'Name', 'email' => 'invalidmail', 'hideit' => 'no'], true], + ]; + } + + public function testExecuteValidPost() + { + $post = ['name' => 'Name', 'comment' => 'Comment', 'email' => 'valid@mail.com', 'hideit' => null]; + + $this->_request->expects($this->any()) + ->method('getPost') + ->will($this->returnValue($post)); + + $store = $this->getMock('\Magento\Store\Model\Store', ['getId', '__sleep', '__wakeup'], [], '', false); + + $store->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + + $this->_storeManager->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($store)); + + $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface', [], [], '', false); + + $this->_transportBuilder->expects($this->once()) + ->method('setTemplateIdentifier') + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('setTemplateOptions') + ->with([ + 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, + 'store' => 1 + ]) + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('setTemplateVars') + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('setFrom') + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('addTo') + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('setReplyTo') + ->with($post['email']) + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('getTransport') + ->will($this->returnValue($transport)); + + $transport->expects($this->once()) + ->method('sendMessage'); + + $this->_inlineTranslation->expects($this->once()) + ->method('resume'); + + $this->_inlineTranslation->expects($this->once()) + ->method('suspend'); + + $this->_controller->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Controller/IndexTest.php b/dev/tests/unit/testsuite/Magento/Contact/Controller/IndexTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0617d59b394b2ee123039ce36dcb0972b66aa42f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Controller/IndexTest.php @@ -0,0 +1,98 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Contact\Controller; + +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Controller\Index|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_controller; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_scopeConfig; + + public function setUp() + { + $this->_scopeConfig = $this->getMockForAbstractClass( + '\Magento\Framework\App\Config\ScopeConfigInterface', ['isSetFlag'], '', false + ); + $context = $this->getMock( + '\Magento\Framework\App\Action\Context', + ['getRequest', 'getResponse'], + [], + '', + false + ); + + $context->expects( + $this->any() + )->method( + 'getRequest' + )->will( + $this->returnValue($this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false)) + ); + + $context->expects( + $this->any() + )->method( + 'getResponse' + )->will( + $this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface', [], '', false) + ) + ); + + $this->_controller = new \Magento\Contact\Controller\Index( + $context, + $this->getMock('\Magento\Framework\Mail\Template\TransportBuilder', [], [], '', false), + $this->getMockForAbstractClass('\Magento\Framework\Translate\Inline\StateInterface', [], '', false), + $this->_scopeConfig, + $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface', [], '', false) + ); + } + + /** + * @expectedException \Magento\Framework\App\Action\NotFoundException + */ + public function testDispatch() + { + $this->_scopeConfig->expects( + $this->once() + )->method( + 'isSetFlag' + )->with( + \Magento\Contact\Controller\Index::XML_PATH_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->will( + $this->returnValue(false) + ); + $this->_controller->dispatch( + $this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b4c0a4cbc3563bb5ab7427c8da0efd562af9111c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php @@ -0,0 +1,138 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Contact\Helper; + +class DataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_helper; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_scopeConfig; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_customerSession; + + /** + * @var \Magento\Customer\Helper\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_customerViewHelper; + + public function setUp() + { + $this->_scopeConfig = $this->getMockForAbstractClass( + '\Magento\Framework\App\Config\ScopeConfigInterface', ['getValue'], '', false + ); + $this->_customerSession = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $this->_customerViewHelper = $this->getMock('\Magento\Customer\Helper\View', [], [], '', false); + + $this->_helper = new Data( + $this->getMock('Magento\Framework\App\Helper\Context', [], [], '', false), + $this->_scopeConfig, + $this->_customerSession, + $this->_customerViewHelper + ); + } + + public function testIsEnabled() + { + $this->_scopeConfig->expects($this->once()) + ->method('getValue') + ->will($this->returnValue('1')); + + $this->assertTrue(is_string($this->_helper->isEnabled())); + } + + public function testIsNotEnabled() + { + $this->_scopeConfig->expects($this->once()) + ->method('getValue') + ->will($this->returnValue(null)); + + $this->assertTrue(is_null($this->_helper->isEnabled())); + } + + public function testGetUserNameNotLoggedIn() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(false)); + + $this->assertEmpty($this->_helper->getUserName()); + } + + public function testGetUserName() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(true)); + + $objectBuilder = $this->getMockForAbstractClass( + '\Magento\Framework\Service\Data\AbstractSimpleObjectBuilder', + ['getData'], + '', + false + ); + $customerDataObject = new \Magento\Customer\Service\V1\Data\Customer($objectBuilder); + $this->_customerSession->expects($this->once()) + ->method('getCustomerDataObject') + ->will($this->returnValue($customerDataObject)); + + $this->_customerViewHelper->expects($this->once()) + ->method('getCustomerName') + ->will($this->returnValue(' customer name ')); + + $this->assertEquals('customer name', $this->_helper->getUserName()); + } + + public function testGetUserEmailNotLoggedIn() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(false)); + + $this->assertEmpty($this->_helper->getUserEmail()); + } + + public function testGetUserEmail() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(true)); + $customerDataObject = $this->getMock('\Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $customerDataObject->expects($this->once())->method('getEmail')->will($this->returnValue('customer@email.com')); + $this->_customerSession->expects($this->once()) + ->method('getCustomerDataObject') + ->will($this->returnValue($customerDataObject)); + + $this->assertEquals('customer@email.com', $this->_helper->getUserEmail()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Model/System/Config/Backend/LinksTest.php b/dev/tests/unit/testsuite/Magento/Contact/Model/System/Config/Backend/LinksTest.php new file mode 100644 index 0000000000000000000000000000000000000000..647638579270950eab153bd6e47ef3688e96fc45 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Model/System/Config/Backend/LinksTest.php @@ -0,0 +1,48 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Contact\Model\System\Config\Backend; + +class LinksTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Model\System\Config\Backend\Links|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_model; + + public function setUp() + { + $this->_model = new Links( + $this->getMock('\Magento\Framework\Model\Context', [], [], '', false), + $this->getMock('\Magento\Framework\Registry', [], [], '', false), + $this->getMockForAbstractClass('\Magento\Framework\App\Config\ScopeConfigInterface', [], '', false), + $this->getMockForAbstractClass('\Magento\Framework\Model\Resource\AbstractResource', [], '', false), + $this->getMock('\Magento\Framework\Data\Collection\Db', [], [], '', false) + ); + } + + public function testGetIdentities() + { + $this->assertTrue(is_array($this->_model->getIdentities())); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php deleted file mode 100644 index 03ef891c9ea1583dd77790bed7b3aff6b6d15836..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\App\FrontController\Plugin; - -class InstallTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\Module\FrontController\Plugin\Install - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_cacheMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_dbUpdaterMock; - - /** - * @var \Closure - */ - protected $closureMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $requestMock; - - protected function setUp() - { - $this->_appStateMock = $this->getMock('\Magento\Framework\App\State', array(), array(), '', false); - $this->_cacheMock = $this->getMock('\Magento\Framework\Cache\FrontendInterface'); - $this->_dbUpdaterMock = $this->getMock('\Magento\Framework\Module\UpdaterInterface'); - $this->closureMock = function () { - return 'Expected'; - }; - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); - $this->_model = new \Magento\Framework\Module\FrontController\Plugin\Install( - $this->_appStateMock, - $this->_cacheMock, - $this->_dbUpdaterMock - ); - } - - public function testAroundDispatch() - { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->_cacheMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'data_upgrade' - )->will( - $this->returnValue(false) - ); - $this->_dbUpdaterMock->expects($this->once())->method('updateScheme'); - $this->_dbUpdaterMock->expects($this->once())->method('updateData'); - $this->_cacheMock->expects($this->once())->method('save')->with('true', 'data_upgrade'); - $this->assertEquals( - 'Expected', - $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php b/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php index d2e8053308ba5adfe8615d5bf5be4fa403ff64da..b9cee5eb4bc7fb636a3832ab13a3feea9fc20112 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php @@ -40,11 +40,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase */ protected $_requestMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appState; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -92,7 +87,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase return true; }; $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); - $this->_appState = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); $this->_configMock = $this->getMock('Magento\Core\Model\File\Storage\Config', array(), array(), '', false); $this->_sync = $this->getMock('Magento\Core\Model\File\Storage\Synchronization', array(), array(), '', false); $this->_dirVerificationMock = $this->getMock( @@ -126,12 +120,10 @@ class MediaTest extends \PHPUnit_Framework_TestCase $map = array( array('Magento\Framework\App\Filesystem\DirectoryList\Verification', $this->_dirVerificationMock), - array('Magento\Framework\App\State', $this->_appState), array('Magento\Core\Model\File\Storage\Request', $this->_requestMock), array('Magento\Core\Model\File\Storage\Synchronization', $this->_sync) ); $this->_model = new \Magento\Core\App\Media( - $this->_appState, $this->_objectManagerMock, $this->_requestMock, $this->_responseMock, @@ -150,18 +142,13 @@ class MediaTest extends \PHPUnit_Framework_TestCase unset($this->_model); } - public function testProcessRequestDoesNothingIfApplicationIsNotInstalled() - { - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); - $this->_requestMock->expects($this->never())->method('getPathInfo'); - $this->assertEquals($this->_responseMock, $this->_model->launch()); - } - + /** + * @expectedException \LogicException + * @expectedExceptionMessage The specified path is not within media directory. + */ public function testProcessRequestCreatesConfigFileMediaDirectoryIsNotProvided() { $this->_model = new \Magento\Core\App\Media( - $this->_appState, $this->_objectManagerMock, $this->_requestMock, $this->_responseMock, @@ -172,7 +159,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase 'params', $this->filesystemMock ); - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_objectManagerMock->expects( $this->once() )->method( @@ -183,16 +169,19 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->_configMock) ); $this->_configMock->expects($this->once())->method('save'); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->_model->launch(); } + /** + * @expectedException \LogicException + * @expectedExceptionMessage The specified path is not allowed. + */ public function testProcessRequestReturnsNotFoundResponseIfResourceIsNotAllowed() { $this->_closure = function () { return false; }; $this->_model = new \Magento\Core\App\Media( - $this->_appState, $this->_objectManagerMock, $this->_requestMock, $this->_responseMock, @@ -203,8 +192,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase 'params', $this->filesystemMock ); - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); $this->_requestMock->expects($this->once())->method('getPathInfo'); $this->_objectManagerMock->expects( $this->once() @@ -216,24 +203,25 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->_configMock) ); $this->_configMock->expects($this->once())->method('getAllowedResources')->will($this->returnValue(false)); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->_model->launch(); } + /** + * @expectedException \LogicException + * @expectedExceptionMessage The specified path is not within media directory. + */ public function testProcessRequestReturnsNotFoundIfFileIsNotAllowed() { - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_configMock->expects($this->never())->method('save'); $this->_requestMock->expects($this->once())->method('getPathInfo'); - $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); $this->_requestMock->expects($this->never())->method('getFilePath'); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->_model->launch(); } public function testProcessRequestReturnsFileIfItsProperlySynchronized() { $relativeFilePath = '_files'; $filePath = str_replace('\\', '/', __DIR__ . '/' . $relativeFilePath); - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects( $this->any() )->method( @@ -264,12 +252,11 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->returnValue(true) ); $this->_responseMock->expects($this->once())->method('setFilePath')->with($filePath); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->assertSame($this->_responseMock, $this->_model->launch()); } public function testProcessRequestReturnsNotFoundIfFileIsNotSynchronized() { - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects( $this->any() )->method( @@ -286,6 +273,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->returnValue('non_existing_file_name') ); $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->assertSame($this->_responseMock, $this->_model->launch()); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php index 29dcfbf615d3fcd9666c85d11a48b5bdb74f5b72..6be6a06216aaa265849644542c569b85721624a9 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php @@ -88,7 +88,7 @@ class MergeTest extends \PHPUnit_Framework_TestCase $this->_store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->_store->expects($this->any())->method('getId')->will($this->returnValue(20)); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->once())->method('getStore')->with(null)->will($this->returnValue($this->_store)); $this->_resource = $this->getMock('Magento\Core\Model\Resource\Layout\Update', array(), array(), '', false); @@ -292,13 +292,19 @@ class MergeTest extends \PHPUnit_Framework_TestCase $this->assertEquals(self::FIXTURE_LAYOUT_XML, $this->_model->asString()); } - public function testLoadDbAppInstalled() + public function testLoadDbApp() { - $this->_appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - $this->_resource->expects($this->once())->method('fetchUpdatesByHandle') - ->with('fixture_handle', $this->_theme, $this->_store) - ->will($this->returnValue(self::FIXTURE_LAYOUT_XML)); - + $this->_resource->expects( + $this->once() + )->method( + 'fetchUpdatesByHandle' + )->with( + 'fixture_handle', + $this->_theme, + $this->_store + )->will( + $this->returnValue(self::FIXTURE_LAYOUT_XML) + ); $this->assertEmpty($this->_model->getHandles()); $this->assertEmpty($this->_model->asString()); $handles = array('fixture_handle'); @@ -307,18 +313,6 @@ class MergeTest extends \PHPUnit_Framework_TestCase $this->assertXmlStringEqualsXmlString(self::FIXTURE_LAYOUT_XML, $this->_model->asString()); } - public function testLoadDbAppNotInstalled() - { - $this->_appState->expects($this->any())->method('isInstalled')->will($this->returnValue(false)); - $this->_resource->expects($this->never())->method('fetchUpdatesByHandle'); - $this->assertEmpty($this->_model->getHandles()); - $this->assertEmpty($this->_model->asString()); - $handles = array('fixture_handle'); - $this->_model->load($handles); - $this->assertEquals($handles, $this->_model->getHandles()); - $this->assertEmpty($this->_model->asString()); - } - public function testGetFileLayoutUpdatesXml() { $errorString = "Theme layout update file '" . __DIR__ . "/_files/layout/file_wrong.xml' is not valid."; diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php index 2fdb5b607e4dacf46389cd3eac830e2903ee3db3..12163c3f448cae5ad09a88882ee20b8ff1bd2109 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php @@ -38,7 +38,7 @@ class ScopeResolverTest extends \PHPUnit_Framework_TestCase public function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')->getMock(); + $this->_storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface')->getMock(); $this->_object = $objectManager->getObject( 'Magento\Core\Model\Url\ScopeResolver', array('storeManager' => $this->_storeManagerMock) diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/View/DesignTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/View/DesignTest.php index df8df8bf3cb458e82781168295e3e8fb3018245b..12c28eeb16171effbb0ccd102cb883eba1f1dd88 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/View/DesignTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/View/DesignTest.php @@ -37,7 +37,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $flyweightThemeFactory = $this->getMock( '\Magento\Framework\View\Design\Theme\FlyweightFactory', array(), array(), '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php b/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php deleted file mode 100644 index d28693237c046256354beba75fe18594b16afd37..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Cron\App\Cron\Plugin; - -class ApplicationInitializerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Cron\App\Cron\Plugin\ApplicationInitializer - */ - protected $model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $sidResolverMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - protected function setUp() - { - $this->appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->sidResolverMock = $this->getMock( - '\Magento\Framework\Session\SidResolverInterface', - array(), - array(), - '', - false - ); - $this->subjectMock = $this->getMock('Magento\Framework\App\Cron', array(), array(), '', false); - $this->model = new ApplicationInitializer( - $this->appStateMock, - $this->sidResolverMock - ); - } - - public function testBeforeExecutePerformsRequiredChecks() - { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->sidResolverMock->expects($this->once())->method('setUseSessionInUrl')->with(false); - $this->model->beforeLaunch($this->subjectMock); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e16e1861eeee46caf353a6d4fca7dfd14431a8ef --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class ViewTest + * @package Magento\Customer\Block\Adminhtml\Edit\Tab + */ +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Block\Adminhtml\Edit\Tab\View + */ + protected $view; + + protected function setUp() + { + $customerAccountService = $this->getMock('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $customerAddressService = $this->getMock('Magento\Customer\Service\V1\CustomerAddressServiceInterface'); + $customerGroupService = $this->getMock('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); + $customerBuilder = $this->getMock('Magento\Customer\Service\V1\Data\CustomerBuilder', [], [], '', false); + $customerAddressHelper = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); + $registry = $this->getMock('Magento\Framework\Registry'); + + $objectManagerHelper = new ObjectManagerHelper($this); + $this->view = $objectManagerHelper->getObject( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\View', + [ + 'accountService' => $customerAccountService, + 'addressService' => $customerAddressService, + 'groupService' => $customerGroupService, + 'customerBuilder' => $customerBuilder, + 'addressHelper' => $customerAddressHelper, + 'registry' => $registry + ] + ); + } + + public function testGetTabLabel() + { + $this->assertEquals('Customer View', $this->view->getTabLabel()); + } + + public function testGetTabTitle() + { + $this->assertEquals('Customer View', $this->view->getTabTitle()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php index a27dad2bfbca585009b4b3b6250d02c42034da5f..71ecdf4a58e8c65827860dc6dd9cb3391e74436b 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php @@ -24,6 +24,8 @@ namespace Magento\Customer\Block\Widget; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Customer\Service\V1\Data\Eav\ValidationRule; +use Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder; class DobTest extends \PHPUnit_Framework_TestCase { @@ -340,12 +342,30 @@ class DobTest extends \PHPUnit_Framework_TestCase */ public function getMinDateRangeDataProvider() { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); return array( array( - array(Dob::MIN_DATE_RANGE_KEY => strtotime(self::MIN_DATE)), + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ->populateWithArray( + array( + 'name' => Dob::MIN_DATE_RANGE_KEY, + 'value' => strtotime(self::MIN_DATE) + ) + ) + ) + ), date('Y/m/d', strtotime(self::MIN_DATE)) ), - array(array(), null) + array( + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ) + ), + null + ) ); } @@ -388,12 +408,30 @@ class DobTest extends \PHPUnit_Framework_TestCase */ public function getMaxDateRangeDataProvider() { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); return array( array( - array(Dob::MAX_DATE_RANGE_KEY => strtotime(self::MAX_DATE)), + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ->populateWithArray( + array( + 'name' => Dob::MAX_DATE_RANGE_KEY, + 'value' => strtotime(self::MAX_DATE) + ) + ) + ) + ), date('Y/m/d', strtotime(self::MAX_DATE)) ), - array(array(), null) + array( + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ) + ), + null + ) ); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php index 02e30e8900ca09c77e5c56822ed41f935fa38c75..c4e1925ed7e68e5bf145595e5ef435b2c2bf177e 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php @@ -56,6 +56,21 @@ class CreatePostTest extends \PHPUnit_Framework_TestCase */ protected $response; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $urlFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $urlMock; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -63,7 +78,16 @@ class CreatePostTest extends \PHPUnit_Framework_TestCase $this->customerHelperMock = $this->getMock('\Magento\Customer\Helper\Data', [], [], '', false); $this->redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); $this->accountServiceMock = $this->getMock('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); - $this->response = $this->getMock('Magento\Framework\App\ResponseInterface'); + $this->response = $this->getMock('Magento\Webapi\Controller\Response'); + $this->request = $this->getMockBuilder('Magento\Webapi\Controller\Request') + ->disableOriginalConstructor() + ->getMock(); + $this->urlFactoryMock = $this->getMockBuilder('\Magento\Framework\UrlFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->urlMock = $this->getMockBuilder('\Magento\Backend\Model\Url') + ->disableOriginalConstructor() + ->getMock(); $this->object = $objectManager->getObject('Magento\Customer\Controller\Account\CreatePost', [ 'response' => $this->response, @@ -71,6 +95,8 @@ class CreatePostTest extends \PHPUnit_Framework_TestCase 'customerHelperData' => $this->customerHelperMock, 'redirect' => $this->redirectMock, 'customerAccountService' => $this->accountServiceMock, + 'request' => $this->request, + 'urlFactory' => $this->urlFactoryMock, ] ); } @@ -98,4 +124,24 @@ class CreatePostTest extends \PHPUnit_Framework_TestCase $this->object->execute(); } + + public function testRegenerateIdOnExecution() + { + $this->customerSession->expects($this->once()) + ->method('regenerateId'); + $this->customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(false)); + + $this->customerHelperMock->expects($this->once()) + ->method('isRegistrationAllowed') + ->will($this->returnValue(true)); + $this->request->expects($this->once()) + ->method('isPost') + ->will($this->returnValue(true)); + $this->urlFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->urlMock)); + $this->object->execute(); + } } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e43e35c3a7c737d98e610f40cb763cc6796a3504 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php @@ -0,0 +1,197 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Controller\Adminhtml\Index; + +/** + * Class IndexTest + */ +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $titleMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $breadcrumbsBlockMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $menuBlockMock; + + /** + * @var \Magento\Customer\Controller\Adminhtml\Index\Index + */ + protected $controller; + + protected function setUp() + { + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods(['setRedirect', 'getHeader', '__wakeup']) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['unsCustomerData', '__wakeup', 'setIsUrlNotice']) + ->getMock(); + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->getMock(); + $this->titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->getMock(); + + $this->breadcrumbsBlockMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Breadcrumbs') + ->disableOriginalConstructor() + ->getMock(); + + $this->menuBlockMock = $this->getMockBuilder('Magento\Backend\Block\Menu') + ->disableOriginalConstructor() + ->setMethods(['getMenuModel', 'getParentItems']) + ->getMock(); + $this->menuBlockMock->expects($this->any()) + ->method('getMenuModel') + ->willReturnSelf(); + $this->menuBlockMock->expects($this->any()) + ->method('getParentItems') + ->willReturn([]); + + $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods(['getBlock']) + ->getMock(); + + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->getMock(); + $this->viewMock->expects($this->any()) + ->method('getLayout') + ->willReturn($this->layoutMock); + + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->willReturn($this->requestMock); + $this->contextMock->expects($this->any()) + ->method('getResponse') + ->willReturn($this->responseMock); + $this->contextMock->expects($this->any()) + ->method('getSession') + ->willReturn($this->sessionMock); + $this->contextMock->expects($this->any()) + ->method('getActionFlag') + ->willReturn($this->actionFlagMock); + $this->contextMock->expects($this->any()) + ->method('getTitle') + ->willReturn($this->titleMock); + $this->contextMock->expects($this->any()) + ->method('getView') + ->willReturn($this->viewMock); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->controller = $objectManager->getObject( + 'Magento\Customer\Controller\Adminhtml\Index\Index', + [ + 'context' => $this->contextMock, + ] + ); + } + + public function testExecuteAjax() + { + $this->requestMock->expects($this->once()) + ->method('getQuery') + ->with('ajax') + ->willReturn(true); + $this->assertNull($this->controller->execute()); + } + + public function testExecute() + { + $this->layoutMock->expects($this->at(0)) + ->method('getBlock') + ->with('menu') + ->willReturn($this->menuBlockMock); + + $this->layoutMock->expects($this->at(1)) + ->method('getBlock') + ->with('breadcrumbs') + ->willReturn($this->breadcrumbsBlockMock); + $this->layoutMock->expects($this->at(2)) + ->method('getBlock') + ->with('breadcrumbs') + ->willReturn($this->breadcrumbsBlockMock); + + $this->requestMock->expects($this->once()) + ->method('getQuery') + ->with('ajax') + ->willReturn(false); + $this->sessionMock->expects($this->once()) + ->method('unsCustomerData'); + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Helper/AddressTest.php b/dev/tests/unit/testsuite/Magento/Customer/Helper/AddressTest.php index ba2dea2226659938cb1b59f56cf085bcd108b219..b876104a7fd4252b9898e319c8bf22f1cfc175f4 100755 --- a/dev/tests/unit/testsuite/Magento/Customer/Helper/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Helper/AddressTest.php @@ -37,7 +37,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\View\Element\BlockFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $blockFactory; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -61,7 +61,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\View\Element\BlockFactory' )->disableOriginalConstructor()->getMock(); $this->storeManager = $this->getMockBuilder( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->getMock(); $this->scopeConfig = $this->getMockBuilder( 'Magento\Framework\App\Config\ScopeConfigInterface' diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php index 0fa79ebedf3734795e39d16466630957cc81a3c7..c61edf9803419f21be5be09515f7d57f2bbc9c8e 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php @@ -44,7 +44,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected $_objectManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -108,7 +108,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase false ); $this->storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/StoreTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/StoreTest.php index e640635f3d031bc300d65adec21977e80eef11a4..11cfa14ff0708070a420a587749dcb43326757db 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/StoreTest.php @@ -32,7 +32,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected $testable; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; @@ -40,9 +40,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase { $logger = $this->getMockBuilder('Magento\Framework\Logger')->disableOriginalConstructor()->getMock(); /** @var \Magento\Framework\Logger $logger */ - $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->getMock(); - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ $this->testable = new Store($logger, $storeManager); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/WebsiteTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/WebsiteTest.php index ac31a29e4e268bfbbdeadd0c66345040126cd899..7247b735f504744c6314de3a78cb6a880ddb4e03 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/WebsiteTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/WebsiteTest.php @@ -32,7 +32,7 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected $testable; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; @@ -40,9 +40,9 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase { $logger = $this->getMockBuilder('Magento\Framework\Logger')->disableOriginalConstructor()->getMock(); /** @var \Magento\Framework\Logger $logger */ - $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->getMock(); - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ $this->testable = new Website($logger, $storeManager); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php index 9866b13038b251cd9b57f48596a1039e14a83361..826708a45bf7f61a160119e6d7c76e24f8582fdc 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php @@ -115,7 +115,7 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase false ); $this->moduleManagerMock = $this->getMock('Magento\Framework\Module\Manager', array(), array(), '', false); - $this->visitorMock = $this->getMock('Magento\Log\Model\Visitor', array(), array(), '', false); + $this->visitorMock = $this->getMock('Magento\Customer\Model\Visitor', array(), array(), '', false); $this->customerFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->customerMock)); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php index 242bf8ce56a5a5184eabbc598a8bf4c6f034bacc..f63294001f5d0eb61e169e82b7a826b951ab7bab 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php @@ -25,6 +25,9 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Customer\Service\V1\Data\Eav\ValidationRule; +use Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder; + class AbstractDataTest extends \PHPUnit_Framework_TestCase { const MODEL = 'MODEL'; @@ -221,13 +224,26 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase */ public function testValidateInputRule($value, $label, $inputValidation, $expectedOutput) { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue($label)); $this->_attributeMock->expects( $this->any() )->method( 'getValidationRules' )->will( - $this->returnValue(array('input_validation' => $inputValidation)) + $this->returnValue( + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ->populateWithArray( + array( + 'name' => 'input_validation', + 'value' => $inputValidation + ) + ) + ) + ) + ) ); $this->assertEquals($expectedOutput, $this->_model->validateInputRule($value)); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php index 09cbf32f610e7389c0cf8d668b4deb576e315920..62ed6d4631741c69d7aba21e52e2f6055c01066b 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php @@ -25,6 +25,9 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Customer\Service\V1\Data\Eav\ValidationRule; +use Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder; + class DateTest extends AbstractFormTestCase { /** @var \Magento\Customer\Model\Metadata\Form\Date */ @@ -86,12 +89,24 @@ class DateTest extends AbstractFormTestCase */ public function testValidateValue($value, $validation, $required, $expected) { + $validationRules = array(); + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $ruleBuilder = $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder'); + $ruleBuilder->populateWithArray(array('name' => 'input_validation', 'value' => 'date')); + $validationRules[] = new ValidationRule($ruleBuilder); + if (is_array($validation)) { + foreach ($validation as $ruleName => $ruleValue) { + $ruleBuilder->populateWithArray(array('name' => $ruleName, 'value' => $ruleValue)); + $validationRules[] = new ValidationRule($ruleBuilder); + } + } + $this->attributeMetadataMock->expects( $this->any() )->method( 'getValidationRules' )->will( - $this->returnValue(array_merge(array('input_validation' => 'date'), $validation)) + $this->returnValue($validationRules) ); $this->attributeMetadataMock->expects($this->any())->method('isRequired')->will($this->returnValue($required)); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/SessionTest.php index e7306a6aadb31d62cd7e2a3418639c09b64af885..2326f369cb7107c323d6fa59157d64b942129a91 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/SessionTest.php @@ -177,22 +177,6 @@ class SessionTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->_model->loginById($customerId)); } - public function testLogin() - { - $customerId = 1; - $username = 'TestName'; - $password = 'TestPassword'; - - $customerDataMock = $this->prepareLoginDataMock($customerId); - - $this->customerAccountServiceMock->expects($this->once()) - ->method('authenticate') - ->with($this->equalTo($username), $this->equalTo($password)) - ->will($this->returnValue($customerDataMock)); - - $this->assertTrue($this->_model->login($username, $password)); - } - /** * @param $customerId * @return \PHPUnit_Framework_MockObject_MockObject diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/VisitorTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/VisitorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2a29852f17be5cbfb16e365b0d23b163d3d17ad3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/VisitorTest.php @@ -0,0 +1,182 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class VisitorTest + * @package Magento\Customer\Model + */ +class VisitorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Model\Visitor + */ + protected $visitor; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Customer\Model\Resource\Visitor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * @var \Magento\Framework\Session\SessionManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $session; + + protected function setUp() + { + $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->session = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['getSessionId', 'getVisitorData', 'setVisitorData']) + ->getMock(); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + + $this->resource = $this->getMockBuilder('Magento\Customer\Model\Resource\Visitor') + ->setMethods([ + 'beginTransaction', + '__sleep', + '__wakeup', + 'getIdFieldName', + 'save', + 'addCommitCallback', + 'commit' + ])->disableOriginalConstructor()->getMock(); + $this->resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id')); + $this->resource->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); + + $arguments = $this->objectManagerHelper->getConstructArguments( + 'Magento\Customer\Model\Visitor', + [ + 'registry' => $this->registry, + 'session' => $this->session, + 'resource' => $this->resource + ] + ); + + $this->visitor = $this->objectManagerHelper->getObject('Magento\Customer\Model\Visitor', $arguments); + } + + public function testInitByRequest() + { + $this->session->expects($this->once())->method('getSessionId') + ->will($this->returnValue('asdfhasdfjhkj2198sadf8sdf897')); + $this->visitor->initByRequest(null); + $this->assertEquals('asdfhasdfjhkj2198sadf8sdf897', $this->visitor->getSessionId()); + + $this->visitor->setData(['visitor_id' => 1]); + $this->visitor->initByRequest(null); + $this->assertNull($this->visitor->getSessionId()); + } + + public function testSaveByRequest() + { + $this->session->expects($this->once())->method('setVisitorData')->will($this->returnSelf()); + $this->assertSame($this->visitor, $this->visitor->saveByRequest(null)); + } + + public function testIsModuleIgnored() + { + $this->visitor = $this->objectManagerHelper->getObject( + 'Magento\Customer\Model\Visitor', + [ + 'registry' => $this->registry, + 'session' => $this->session, + 'resource' => $this->resource, + 'ignores' => array('test_route_name' => true) + ] + ); + $request = new \Magento\Framework\Object(['route_name' => 'test_route_name']); + $action = new \Magento\Framework\Object(['request' => $request]); + $event = new \Magento\Framework\Object(['controller_action' => $action]); + $observer = new \Magento\Framework\Object(['event' => $event]); + $this->assertTrue($this->visitor->isModuleIgnored($observer)); + } + + + public function testBindCustomerLogin() + { + $customer = new \Magento\Framework\Object(['id' => '1']); + $observer = new \Magento\Framework\Object([ + 'event' => new \Magento\Framework\Object(['customer' => $customer]) + ]); + + $this->visitor->bindCustomerLogin($observer); + $this->assertTrue($this->visitor->getDoCustomerLogin()); + $this->assertEquals($customer->getId(), $this->visitor->getCustomerId()); + + $this->visitor->unsetData(); + $this->visitor->setCustomerId('2'); + $this->visitor->bindCustomerLogin($observer); + $this->assertNull($this->visitor->getDoCustomerLogin()); + $this->assertEquals('2', $this->visitor->getCustomerId()); + } + + public function testBindCustomerLogout() + { + $observer = new \Magento\Framework\Object(); + + $this->visitor->setCustomerId('1'); + $this->visitor->bindCustomerLogout($observer); + $this->assertTrue($this->visitor->getDoCustomerLogout()); + + $this->visitor->unsetData(); + $this->visitor->bindCustomerLogout($observer); + $this->assertNull($this->visitor->getDoCustomerLogout()); + } + + public function testBindQuoteCreate() + { + $quote = new \Magento\Framework\Object(['id' => '1', 'is_checkout_cart' => true]); + $observer = new \Magento\Framework\Object([ + 'event' => new \Magento\Framework\Object(['quote' => $quote]) + ]); + $this->visitor->bindQuoteCreate($observer); + $this->assertTrue($this->visitor->getDoQuoteCreate()); + } + + public function testBindQuoteDestroy() + { + $quote = new \Magento\Framework\Object(['id' => '1']); + $observer = new \Magento\Framework\Object([ + 'event' => new \Magento\Framework\Object(['quote' => $quote]) + ]); + $this->visitor->bindQuoteDestroy($observer); + $this->assertTrue($this->visitor->getDoQuoteDestroy()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php index 976ff4fe3e04c7030a7a843511085e4cdae250c1..3455908ed9de5759385c36a0cd9ab1699940a63d 100755 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -72,7 +72,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase private $_eventManagerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ private $_storeManagerMock; @@ -2125,7 +2125,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase private function _setupStoreMock() { $this->_storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->getMock(); $this->_storeMock = $this->getMockBuilder( diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php index 4f2087e54b04f15b170e24541164d67fbe522178..a6c0127f9877f8aee4c5d99f209e7ef72dfbcc54 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php @@ -95,7 +95,7 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase private $_customerModelMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ private $_storeManagerMock; @@ -849,7 +849,7 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase private function _setupStoreMock() { $this->_storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->getMock(); $this->_storeMock = $this->getMockBuilder( diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverterTest.php index 062464a2d1f359070a2c82c9dd3295ffd83e3764..0c7494afa2ad0441e513195d750bd5027f0d0ea5 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverterTest.php @@ -101,16 +101,16 @@ class AttributeMetadataConverterTest extends \PHPUnit_Framework_TestCase $frontendInput = 'frontendInput'; $inputFilter = 'inputFilter'; $storeLabel = 'storeLabel'; - $isVisible = 'isVisible'; - $isRequired = 'isRequired'; - $multilineCount = 'multilineCount'; + $isVisible = true; + $isRequired = true; + $multilineCount = 0; $dataModel = 'dataModel'; $frontendLabel = 'frontendLabel'; $backendType = 'backendType'; $note = 'note'; - $isSystem = 'isSystem'; - $isUserDefined = 'isUserDefined'; - $sortOrder = 'sortOrder'; + $isSystem = true; + $isUserDefined = true; + $sortOrder = 0; $attribute->expects($this->once())->method('getAttributeCode')->will($this->returnValue($attributeCode)); $attribute->expects($this->once())->method('getFrontendInput')->will($this->returnValue($frontendInput)); diff --git a/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php index ed75a2751b19c923925abe88cf9976d57157999f..6b6cd3fd380974b45beddcca2fabfe8aaf640421 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php @@ -95,7 +95,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_coreHelper = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); $this->_store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->_store)); $currencyFactory = $this->getMock('Magento\Directory\Model\CurrencyFactory', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Directory/Model/PriceCurrencyTest.php b/dev/tests/unit/testsuite/Magento/Directory/Model/PriceCurrencyTest.php index 9752806fb31d2185fcefe6e61b6c4d4b2f849bf8..e9e77e8a278cd90e224746f0b2a9ccbfe61f6c81 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Model/PriceCurrencyTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Model/PriceCurrencyTest.php @@ -32,7 +32,7 @@ class PriceCurrencyTest extends \PHPUnit_Framework_TestCase protected $priceCurrency; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php index 6513fe96cb42e3bcdb648d95ecfb9a81575512e1..21df0fce0847949775c16fabba251c48c8f0b02a 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php @@ -26,23 +26,127 @@ namespace Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Download class LinksTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable_Links + * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links */ - protected $_block; + protected $block; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $productModel; + + /** + * @var \Magento\Downloadable\Model\Product\Type + */ + protected $downloadableProductModel; + + /** + * @var \Magento\Downloadable\Model\Link + */ + protected $downloadableLinkModel; + + /** + * @var \Magento\Framework\Escaper + */ + protected $escaper; + + /** + * @var \Magento\Downloadable\Helper\File + */ + protected $fileHelper; + + /** + * @var \Magento\Framework\Registry + */ + protected $coreRegistry; + + /** + * @var \Magento\Backend\Model\Url + */ + protected $urlBuilder; protected function setUp() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $urlBuilder = $this->getMock('Magento\Backend\Model\Url', array(), array(), '', false); + $this->urlBuilder = $this->getMock('Magento\Backend\Model\Url', array('getUrl'), array(), '', false); $attributeFactory = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', array(), array(), '', false); $urlFactory = $this->getMock('Magento\Backend\Model\UrlFactory', array(), array(), '', false); + $this->fileHelper = $this->getMock( + '\Magento\Downloadable\Helper\File', + array( + 'getFilePath', + 'ensureFileInFilesystem', + 'getFileSize' + ), + array(), + '', + false + ); + $this->productModel = $this->getMock( + 'Magento\Catalog\Model\Product', + array( + '__wakeup', + 'getTypeId', + 'getTypeInstance', + 'getStoreId' + ), + array(), + '', + false + ); + $this->downloadableProductModel = $this->getMock( + '\Magento\Downloadable\Model\Product\Type', + array( + '__wakeup', + 'getLinks' + ), + array(), + '', + false + ); + $this->downloadableLinkModel = $this->getMock( + '\Magento\Downloadable\Model\Link', + array( + '__wakeup', + 'getId', + 'getTitle', + 'getPrice', + 'getNumberOfDownloads', + 'getLinkUrl', + 'getLinkType', + 'getSampleFile', + 'getSampleType', + 'getSortOrder', + 'getLinkFile', + 'getStoreTitle' + ), + array(), + '', + false + ); + + $this->coreRegistry = $this->getMock( + '\Magento\Framework\Registry', + array( + '__wakeup', + 'registry' + ), + array(), + '', + false + ); + + $this->escaper = $this->getMock('\Magento\Framework\Escaper', array('escapeHtml'), array(), '', false); - $this->_block = $objectManagerHelper->getObject( + $this->block = $objectManagerHelper->getObject( 'Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links', array( - 'urlBuilder' => $urlBuilder, - 'Magento\Eav\Model\Entity\AttributeFactory' => $attributeFactory, - 'Magento\Backend\Model\UrlFactory' => $urlFactory + 'urlBuilder' => $this->urlBuilder, + 'attributeFactory' => $attributeFactory, + 'urlFactory' => $urlFactory, + 'coreRegistry' => $this->coreRegistry, + 'escaper' => $this->escaper, + 'downloadableFile' => $this->fileHelper ) ); } @@ -52,6 +156,75 @@ class LinksTest extends \PHPUnit_Framework_TestCase */ public function testGetConfig() { - $this->assertInstanceOf('Magento\Framework\Object', $this->_block->getConfig()); + $this->assertInstanceOf('Magento\Framework\Object', $this->block->getConfig()); + } + + public function testGetLinkData() + { + $expectingFileData = array( + 'file' => array( + 'file' => 'file/link.gif', + 'name' => '<a href="final_url">link.gif</a>', + 'size' => '1.1', + 'status' => 'old' + ), + 'sample_file' => array( + 'file' => 'file/sample.gif', + 'name' => '<a href="final_url">sample.gif</a>', + 'size' => '1.1', + 'status' => 'old' + ) + ); + + $this->productModel->expects($this->any())->method('getTypeId') + ->will($this->returnValue('downloadable')); + $this->productModel->expects($this->any())->method('getTypeInstance') + ->will($this->returnValue($this->downloadableProductModel)); + $this->productModel->expects($this->any())->method('getStoreId') + ->will($this->returnValue(0)); + $this->downloadableProductModel->expects($this->any())->method('getLinks') + ->will($this->returnValue(array($this->downloadableLinkModel))); + $this->coreRegistry->expects($this->any())->method('registry') + ->will($this->returnValue($this->productModel)); + $this->downloadableLinkModel->expects($this->any())->method('getId') + ->will($this->returnValue(1)); + $this->downloadableLinkModel->expects($this->any())->method('getTitle') + ->will($this->returnValue('Link Title')); + $this->downloadableLinkModel->expects($this->any())->method('getPrice') + ->will($this->returnValue('10')); + $this->downloadableLinkModel->expects($this->any())->method('getNumberOfDownloads') + ->will($this->returnValue('6')); + $this->downloadableLinkModel->expects($this->any())->method('getLinkUrl') + ->will($this->returnValue(null)); + $this->downloadableLinkModel->expects($this->any())->method('getLinkType') + ->will($this->returnValue('file')); + $this->downloadableLinkModel->expects($this->any())->method('getSampleFile') + ->will($this->returnValue('file/sample.gif')); + $this->downloadableLinkModel->expects($this->any())->method('getSampleType') + ->will($this->returnValue('file')); + $this->downloadableLinkModel->expects($this->any())->method('getSortOrder') + ->will($this->returnValue(0)); + $this->downloadableLinkModel->expects($this->any())->method('getLinkFile') + ->will($this->returnValue('file/link.gif')); + $this->downloadableLinkModel->expects($this->any())->method('getStoreTitle') + ->will($this->returnValue('Store Title')); + $this->escaper->expects($this->any())->method('escapeHtml') + ->will($this->returnValue('Link Title')); + $this->fileHelper->expects($this->any())->method('getFilePath') + ->will($this->returnValue('/file/path/link.gif')); + $this->fileHelper->expects($this->any())->method('ensureFileInFilesystem') + ->will($this->returnValue(true)); + $this->fileHelper->expects($this->any())->method('getFileSize') + ->will($this->returnValue('1.1')); + $this->urlBuilder->expects($this->any())->method('getUrl') + ->will($this->returnValue('final_url')); + $linkData = $this->block->getLinkData(); + foreach ($linkData as $link) { + $fileSave = $link->getFileSave(0); + $sampleFileSave = $link->getSampleFileSave(0); + $this->assertEquals($expectingFileData['file'], $fileSave); + $this->assertEquals($expectingFileData['sample_file'], $sampleFileSave); + + } } } diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php index 7bbd7748a9f1c116d081ada3f717c8a80dc83de0..ee80025890f1ff956787dab13c197b517ebb5338 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php @@ -26,16 +26,117 @@ namespace Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Download class SamplesTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links + * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Samples */ - protected $_block; + protected $block; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $productModel; + + /** + * @var \Magento\Downloadable\Model\Product\Type + */ + protected $downloadableProductModel; + + /** + * @var \Magento\Downloadable\Model\Sample + */ + protected $downloadableSampleModel; + + /** + * @var \Magento\Framework\Escaper + */ + protected $escaper; + + /** + * @var \Magento\Downloadable\Helper\File + */ + protected $fileHelper; + + /** + * @var \Magento\Framework\Registry + */ + protected $coreRegistry; + + /** + * @var \Magento\Backend\Model\Url + */ + protected $urlBuilder; protected function setUp() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_block = $objectManagerHelper->getObject( + + $this->urlBuilder = $this->getMock('Magento\Backend\Model\Url', array('getUrl'), array(), '', false); + $urlFactory = $this->getMock('Magento\Backend\Model\UrlFactory', array(), array(), '', false); + $this->fileHelper = $this->getMock( + '\Magento\Downloadable\Helper\File', + array( + 'getFilePath', + 'ensureFileInFilesystem', + 'getFileSize' + ), + array(), + '', + false + ); + $this->productModel = $this->getMock( + 'Magento\Catalog\Model\Product', + array( + '__wakeup', + 'getTypeId', + 'getTypeInstance', + 'getStoreId' + ), + array(), + '', + false + ); + $this->downloadableProductModel = $this->getMock( + '\Magento\Downloadable\Model\Product\Type', + array( + '__wakeup', + 'getSamples' + ), + array(), + '', + false + ); + $this->downloadableSampleModel = $this->getMock( + '\Magento\Downloadable\Model\Sample', + array( + '__wakeup', + 'getId', + 'getTitle', + 'getSampleFile', + 'getSampleType', + 'getSortOrder' + ), + array(), + '', + false + ); + $this->coreRegistry = $this->getMock( + '\Magento\Framework\Registry', + array( + '__wakeup', + 'registry' + ), + array(), + '', + false + ); + $this->escaper = $this->getMock('\Magento\Framework\Escaper', array('escapeHtml'), array(), '', false); + $this->block = $objectManagerHelper->getObject( 'Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Samples', - array('urlBuilder' => $this->getMock('Magento\Backend\Model\Url', array(), array(), '', false)) + array( + 'urlBuilder' => $this->urlBuilder, + 'urlFactory' => $urlFactory, + 'coreRegistry' => $this->coreRegistry, + 'escaper' => $this->escaper, + 'downloadableFile' => $this->fileHelper) ); } @@ -44,6 +145,56 @@ class SamplesTest extends \PHPUnit_Framework_TestCase */ public function testGetConfig() { - $this->assertInstanceOf('Magento\Framework\Object', $this->_block->getConfig()); + $this->assertInstanceOf('Magento\Framework\Object', $this->block->getConfig()); + } + + public function testGetSampleData() + { + $expectingFileData = array( + 'sample_file' => array( + 'file' => 'file/sample.gif', + 'name' => '<a href="final_url">sample.gif</a>', + 'size' => '1.1', + 'status' => 'old' + ) + ); + + $this->productModel->expects($this->any())->method('getTypeId') + ->will($this->returnValue('downloadable')); + $this->productModel->expects($this->any())->method('getTypeInstance') + ->will($this->returnValue($this->downloadableProductModel)); + $this->productModel->expects($this->any())->method('getStoreId') + ->will($this->returnValue(0)); + $this->downloadableProductModel->expects($this->any())->method('getSamples') + ->will($this->returnValue(array($this->downloadableSampleModel))); + $this->coreRegistry->expects($this->any())->method('registry') + ->will($this->returnValue($this->productModel)); + $this->downloadableSampleModel->expects($this->any())->method('getId') + ->will($this->returnValue(1)); + $this->downloadableSampleModel->expects($this->any())->method('getTitle') + ->will($this->returnValue('Sample Title')); + $this->downloadableSampleModel->expects($this->any())->method('getSampleUrl') + ->will($this->returnValue(null)); + $this->downloadableSampleModel->expects($this->any())->method('getSampleFile') + ->will($this->returnValue('file/sample.gif')); + $this->downloadableSampleModel->expects($this->any())->method('getSampleType') + ->will($this->returnValue('file')); + $this->downloadableSampleModel->expects($this->any())->method('getSortOrder') + ->will($this->returnValue(0)); + $this->escaper->expects($this->any())->method('escapeHtml') + ->will($this->returnValue('Sample Title')); + $this->fileHelper->expects($this->any())->method('getFilePath') + ->will($this->returnValue('/file/path/sample.gif')); + $this->fileHelper->expects($this->any())->method('ensureFileInFilesystem') + ->will($this->returnValue(true)); + $this->fileHelper->expects($this->any())->method('getFileSize') + ->will($this->returnValue('1.1')); + $this->urlBuilder->expects($this->any())->method('getUrl') + ->will($this->returnValue('final_url')); + $sampleData = $this->block->getSampleData(); + foreach ($sampleData as $sample) { + $fileSave = $sample->getFileSave(0); + $this->assertEquals($expectingFileData['sample_file'], $fileSave); + } } } diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1f67f12178b20e30b54355b2cca93513b46fa179 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php @@ -0,0 +1,261 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class LinkTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link */ + protected $link; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\App\RequestInterface + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface + */ + protected $response; + + /** + * @var \Magento\Downloadable\Model\Link + */ + protected $linkModel; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Downloadable\Helper\File + */ + protected $fileHelper; + + /** + * @var \Magento\Downloadable\Helper\Download + */ + protected $downloadHelper; + + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + array( + 'getParam', + 'getModuleName', + 'setModuleName', + 'getActionName', + 'setActionName', + 'getCookie' + ) + ); + $this->response = $this->getMock( + '\Magento\Framework\App\ResponseInterface', + array( + 'setHttpResponseCode', + 'clearBody', + 'sendHeaders', + 'sendResponse', + 'setHeader' + ) + ); + $this->fileHelper = $this->getMock( + '\Magento\Downloadable\Helper\File', + array( + 'getFilePath' + ), + array(), + '', + false + ); + $this->downloadHelper = $this->getMock( + 'Magento\Downloadable\Helper\Download', + array( + 'setResource', + 'getFilename', + 'getContentType', + 'output', + 'getFileSize', + 'getContentDisposition' + ), + array(), + '', + false + ); + $this->linkModel = $this->getMock( + '\Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link', + array( + 'load', + 'getId', + 'getLinkType', + 'getLinkUrl', + 'getSampleUrl', + 'getSampleType', + 'getBasePath', + 'getBaseSamplePath', + 'getLinkFile', + 'getSampleFile' + ), + array(), + '', + false + ); + $this->objectManager = $this->getMock( + '\Magento\Framework\ObjectManager\ObjectManager', + array( + 'create', + 'get' + ), + array(), + '', + false + ); + + $this->link = $this->objectManagerHelper->getObject( + 'Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link', + [ + 'objectManager' => $this->objectManager, + 'request' => $this->request, + 'response' => $this->response + ] + ); + } + + /** + * @dataProvider executeDataProvider + * @param string $fileType + */ + public function testExecuteFile($fileType) + { + $this->request->expects($this->at(0))->method('getParam')->with('id', 0) + ->will($this->returnValue(1)); + $this->request->expects($this->at(1))->method('getParam')->with('type', 0) + ->will($this->returnValue($fileType)); + $this->response->expects($this->once())->method('setHttpResponseCode') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('clearBody') + ->will($this->returnSelf()); + $this->response->expects($this->any())->method('setHeader') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('sendHeaders') + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1))->method('get')->with('Magento\Downloadable\Helper\File') + ->will($this->returnValue($this->fileHelper)); + $this->objectManager->expects($this->at(2))->method('get')->with('Magento\Downloadable\Model\Link') + ->will($this->returnValue($this->linkModel)); + $this->objectManager->expects($this->at(3))->method('get')->with('Magento\Downloadable\Helper\Download') + ->will($this->returnValue($this->downloadHelper)); + $this->fileHelper->expects($this->once())->method('getFilePath') + ->will($this->returnValue('filepath/'. $fileType . '.jpg')); + $this->downloadHelper->expects($this->once())->method('setResource') + ->will($this->returnSelf()); + $this->downloadHelper->expects($this->once())->method('getFilename') + ->will($this->returnValue('link.jpg')); + $this->downloadHelper->expects($this->once())->method('getContentType') + ->will($this->returnSelf('file')); + $this->downloadHelper->expects($this->once())->method('getFileSize') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('getContentDisposition') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('output') + ->will($this->returnSelf()); + $this->linkModel->expects($this->once())->method('load') + ->will($this->returnSelf()); + $this->linkModel->expects($this->once())->method('getId') + ->will($this->returnValue('1')); + $this->linkModel->expects($this->any())->method('get' . $fileType . 'Type') + ->will($this->returnValue('file')); + $this->objectManager->expects($this->once())->method('create') + ->will($this->returnValue($this->linkModel)); + + $this->link->execute(); + } + + /** + * @dataProvider executeDataProvider + * @param string $fileType + */ + public function testExecuteUrl($fileType) + { + $this->request->expects($this->at(0))->method('getParam') + ->with('id', 0)->will($this->returnValue(1)); + $this->request->expects($this->at(1))->method('getParam') + ->with('type', 0)->will($this->returnValue($fileType)); + $this->response->expects($this->once())->method('setHttpResponseCode') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('clearBody') + ->will($this->returnSelf()); + $this->response->expects($this->any())->method('setHeader') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('sendHeaders') + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1))->method('get')->with('Magento\Downloadable\Helper\Download') + ->will($this->returnValue($this->downloadHelper)); + $this->downloadHelper->expects($this->once())->method('setResource') + ->will($this->returnSelf()); + $this->downloadHelper->expects($this->once())->method('getFilename') + ->will($this->returnValue('link.jpg')); + $this->downloadHelper->expects($this->once())->method('getContentType') + ->will($this->returnSelf('url')); + $this->downloadHelper->expects($this->once())->method('getFileSize') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('getContentDisposition') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('output') + ->will($this->returnSelf()); + $this->linkModel->expects($this->once())->method('load') + ->will($this->returnSelf()); + $this->linkModel->expects($this->once())->method('getId') + ->will($this->returnValue('1')); + $this->linkModel->expects($this->once())->method('get' . $fileType . 'Type') + ->will($this->returnValue('url')); + $this->linkModel->expects($this->once())->method('get' . $fileType . 'Url') + ->will($this->returnValue('http://url.magento.com')); + $this->objectManager->expects($this->once())->method('create') + ->will($this->returnValue($this->linkModel)); + + $this->link->execute(); + } + + /** + * @return array + */ + public function executeDataProvider() + { + return array( + array('link'), + array('sample') + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e61e06da409835a0523204df82e29e8fd4f21b9b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php @@ -0,0 +1,238 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class SampleTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample */ + protected $sample; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\App\RequestInterface + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface + */ + protected $response; + + /** + * @var \Magento\Downloadable\Model\Sample + */ + protected $sampleModel; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Downloadable\Helper\File + */ + protected $fileHelper; + + /** + * @var \Magento\Downloadable\Helper\Download + */ + protected $downloadHelper; + + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + array( + 'getParam', + 'getModuleName', + 'setModuleName', + 'getActionName', + 'setActionName', + 'getCookie' + ) + ); + $this->response = $this->getMock( + '\Magento\Framework\App\ResponseInterface', + array( + 'setHttpResponseCode', + 'clearBody', + 'sendHeaders', + 'sendResponse', + 'setHeader' + ) + ); + $this->fileHelper = $this->getMock( + '\Magento\Downloadable\Helper\File', + array( + 'getFilePath' + ), + array(), + '', + false + ); + $this->downloadHelper = $this->getMock( + 'Magento\Downloadable\Helper\Download', + array( + 'setResource', + 'getFilename', + 'getContentType', + 'output', + 'getFileSize', + 'getContentDisposition' + ), + array(), + '', + false + ); + $this->sampleModel = $this->getMock( + '\Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample', + array( + 'load', + 'getId', + 'getSampleType', + 'getSampleUrl', + 'getBasePath', + 'getBaseSamplePath', + 'getSampleFile', + ), + array(), + '', + false + ); + $this->objectManager = $this->getMock( + '\Magento\Framework\ObjectManager\ObjectManager', + array( + 'create', + 'get' + ), + array(), + '', + false + ); + $this->sample = $this->objectManagerHelper->getObject( + 'Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample', + array( + 'objectManager' => $this->objectManager, + 'request' => $this->request, + 'response' => $this->response + ) + ); + } + + /** + * Execute download sample file action + */ + public function testExecuteFile() + { + $this->request->expects($this->at(0))->method('getParam')->with('id', 0) + ->will($this->returnValue(1)); + $this->response->expects($this->once())->method('setHttpResponseCode') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('clearBody') + ->will($this->returnSelf()); + $this->response->expects($this->any())->method('setHeader') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('sendHeaders') + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1))->method('get')->with('Magento\Downloadable\Helper\File') + ->will($this->returnValue($this->fileHelper)); + $this->objectManager->expects($this->at(2))->method('get')->with('Magento\Downloadable\Model\Sample') + ->will($this->returnValue($this->sampleModel)); + $this->objectManager->expects($this->at(3))->method('get')->with('Magento\Downloadable\Helper\Download') + ->will($this->returnValue($this->downloadHelper)); + $this->fileHelper->expects($this->once())->method('getFilePath') + ->will($this->returnValue('filepath/sample.jpg')); + $this->downloadHelper->expects($this->once())->method('setResource') + ->will($this->returnSelf()); + $this->downloadHelper->expects($this->once())->method('getFilename') + ->will($this->returnValue('sample.jpg')); + $this->downloadHelper->expects($this->once())->method('getContentType') + ->will($this->returnSelf('file')); + $this->downloadHelper->expects($this->once())->method('getFileSize') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('getContentDisposition') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('output') + ->will($this->returnSelf()); + $this->sampleModel->expects($this->once())->method('load') + ->will($this->returnSelf()); + $this->sampleModel->expects($this->once())->method('getId') + ->will($this->returnValue('1')); + $this->sampleModel->expects($this->any())->method('getSampleType') + ->will($this->returnValue('file')); + $this->objectManager->expects($this->once())->method('create') + ->will($this->returnValue($this->sampleModel)); + + $this->sample->execute(); + } + + /** + * Execute download sample url action + */ + public function testExecuteUrl() + { + $this->request->expects($this->at(0))->method('getParam')->with('id', 0) + ->will($this->returnValue(1)); + $this->response->expects($this->once())->method('setHttpResponseCode') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('clearBody') + ->will($this->returnSelf()); + $this->response->expects($this->any())->method('setHeader') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('sendHeaders') + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1))->method('get')->with('Magento\Downloadable\Helper\Download') + ->will($this->returnValue($this->downloadHelper)); + $this->downloadHelper->expects($this->once())->method('setResource') + ->will($this->returnSelf()); + $this->downloadHelper->expects($this->once())->method('getFilename') + ->will($this->returnValue('sample.jpg')); + $this->downloadHelper->expects($this->once())->method('getContentType') + ->will($this->returnSelf('url')); + $this->downloadHelper->expects($this->once())->method('getFileSize') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('getContentDisposition') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('output') + ->will($this->returnSelf()); + $this->sampleModel->expects($this->once())->method('load') + ->will($this->returnSelf()); + $this->sampleModel->expects($this->once())->method('getId') + ->will($this->returnValue('1')); + $this->sampleModel->expects($this->any())->method('getSampleType') + ->will($this->returnValue('url')); + $this->objectManager->expects($this->once())->method('create') + ->will($this->returnValue($this->sampleModel)); + + $this->sample->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php index f0a63231c88bf9c9d0a6e82d1b0d430a941d45e6..f7e4cd0e1b022c86190f8fca631fb65f0f17066a 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php @@ -30,7 +30,14 @@ use Magento\Framework\Filesystem\Directory\ReadInterface as DirReadInterface; use Magento\Downloadable\Helper\File as DownloadableFile; /** - * @runInSeparateProcess + * @bug https://github.com/sebastianbergmann/phpunit/issues/314 + * Workaround: use the "require_once" below and declare "preserveGlobalState disabled" in the test class + */ +require_once __DIR__ . '/../../../../framework/bootstrap.php'; + +/** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled */ class DownloadTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php index 8e005ca910a41632edf348345e1eb88168873414..da4bbfb6efa659e2f0321fd2f5e7e5356ceb2980 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php @@ -61,7 +61,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected $entityTypeMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; @@ -94,7 +94,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase ->method('getEntityType') ->will($this->returnValue($this->entityTypeMock)); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->storeManagerMock->expects($this->any()) ->method('getStore') ->will($this->returnSelf()); diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php index e67ba201eca24f2b75c3b2ba73ce5a7e64a304b0..efcf54deb8e109d252773fc0f8ad971bc990a11f 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php @@ -56,7 +56,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected $coreResourceMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; @@ -101,7 +101,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase false ); $this->storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/Email/Block/Adminhtml/Template/PreviewTest.php b/dev/tests/unit/testsuite/Magento/Email/Block/Adminhtml/Template/PreviewTest.php index 5cc0a39112c5737bdb5f4e646105ab577ed612be..aae7ab9a9f45efafbc6284ff6a21d9180597e2c4 100644 --- a/dev/tests/unit/testsuite/Magento/Email/Block/Adminhtml/Template/PreviewTest.php +++ b/dev/tests/unit/testsuite/Magento/Email/Block/Adminhtml/Template/PreviewTest.php @@ -71,7 +71,7 @@ class PreviewTest extends \PHPUnit_Framework_TestCase $design = $this->getMock('Magento\Framework\View\DesignInterface'); $store = $this->getMock('Magento\Store\Model\Store', array('getId', '__wakeup'), array(), '', false); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getDefaultStoreView')->will($this->returnValue(null)); $storeManager->expects($this->any())->method('getStores')->will($this->returnValue([$store])); @@ -158,7 +158,7 @@ class PreviewTest extends \PHPUnit_Framework_TestCase $eventManage = $this->getMock('Magento\Framework\Event\ManagerInterface'); $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $design = $this->getMock('Magento\Framework\View\DesignInterface'); - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getDefaultStoreView')->will($this->returnValue(null)); $storeManager->expects($this->any())->method('getStores')->will($this->returnValue([])); diff --git a/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php b/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php index 9736c734575660fcd0667691e76a81840504950d..627a354c85daf5d3730ddfe0f298f2bd37d45873 100644 --- a/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php +++ b/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php @@ -68,7 +68,7 @@ class CarrierTest extends \PHPUnit_Framework_TestCase $store = $this->getMock('Magento\Store\Model\Store', ['getBaseCurrencyCode', '__wakeup'], [], '', false); $storeManager = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', [ 'getStore', 'setIsSingleStoreModeAllowed', diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/BootstrapTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/BootstrapTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2fd488c54592fe96f9647865cbf21dc8e4c3dc53 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/BootstrapTest.php @@ -0,0 +1,248 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\App; + +class BootstrapTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\AppInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $application; + + /** + * @var \Magento\Framework\App\ObjectManagerFactory | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerFactory; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager; + + /** + * @var \Magento\Framework\Logger | \PHPUnit_Framework_MockObject_MockObject + */ + protected $logger; + + /** + * @var \Magento\Framework\App\Filesystem\DirectoryList | \PHPUnit_Framework_MockObject_MockObject + */ + protected $dirs; + + /** + * @var \Magento\Framework\Filesystem\Directory\ReadInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $configDir; + + /** + * @var MaintenanceMode | \PHPUnit_Framework_MockObject_MockObject + */ + protected $maintenanceMode; + + /** + * @var \Magento\Framework\App\Bootstrap | \PHPUnit_Framework_MockObject_MockObject + */ + protected $bootstrapMock; + + public function setUp() + { + $this->objectManagerFactory = $this->getMock('\Magento\Framework\App\ObjectManagerFactory', [], [], '', false); + $this->objectManager = $this->getMockForAbstractClass('\Magento\Framework\ObjectManager'); + $this->dirs = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', ['getDir'], [], '', false); + $this->maintenanceMode = $this->getMock('\Magento\Framework\App\MaintenanceMode', ['isOn'], [], '', false); + $filesystem = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); + + $this->logger = $this->getMock('Magento\Framework\Logger', [], [], '', false); + + $mapObjectManager = [ + ['Magento\Framework\App\Filesystem\DirectoryList', $this->dirs], + ['Magento\Framework\App\MaintenanceMode', $this->maintenanceMode], + ['Magento\Framework\App\Filesystem', $filesystem], + ['Magento\Framework\Logger', $this->logger] + ]; + + $this->objectManager->expects($this->any())->method('get') + ->will(($this->returnValueMap($mapObjectManager))); + + $this->configDir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); + + $filesystem->expects($this->any())->method('getDirectoryRead') + ->will(($this->returnValue($this->configDir))); + + $this->application = $this->getMockForAbstractClass('\Magento\Framework\AppInterface'); + + $this->objectManager->expects($this->any())->method('create') + ->will(($this->returnValue($this->application))); + + $this->objectManagerFactory->expects($this->any())->method('create') + ->will(($this->returnValue($this->objectManager))); + + $this->bootstrapMock = $this->getMock('\Magento\Framework\App\Bootstrap', + ['assertMaintenance', 'assertInstalled', 'getIsExpected', 'isInstalled', 'terminate'], + [$this->objectManagerFactory, '', ['value1', 'value2']] + ); + } + + public function testGetParams() + { + $testParams = ['testValue1', 'testValue2']; + $bootstrap = self::createBootstrap($testParams); + $this->assertSame($testParams, $bootstrap->getParams()); + } + + /** + * Creates a bootstrap object + * + * @param array $testParams + * @return Bootstrap + */ + private function createBootstrap($testParams = ['value1', 'value2']) + { + return new Bootstrap($this->objectManagerFactory, '', $testParams); + } + + public function testCreateApplication() + { + $bootstrap = self::createBootstrap(); + $testArgs = ['arg1', 'arg2']; + $this->assertSame($this->application, $bootstrap->createApplication('someApplicationType', $testArgs)); + } + + public function testGetObjectManager() + { + $bootstrap = self::createBootstrap(); + $this->assertSame($this->objectManager, $bootstrap->getObjectManager()); + } + + public function testGetDirList() + { + $bootstrap = self::createBootstrap(); + $this->assertSame($this->dirs, $bootstrap->getDirList()); + } + + public function testIsDeveloperMode() + { + $bootstrap = self::createBootstrap(); + $this->assertFalse($bootstrap->isDeveloperMode()); + $testParams = [State::PARAM_MODE => State::MODE_DEVELOPER]; + $bootstrap = self::createBootstrap($testParams); + $this->assertTrue($bootstrap->isDeveloperMode()); + } + + public function testRunNoErrors() + { + $responseMock = $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface'); + $this->bootstrapMock->expects($this->once())->method('assertMaintenance')->will($this->returnValue(null)); + $this->bootstrapMock->expects($this->once())->method('assertInstalled')->will($this->returnValue(null)); + $this->application->expects($this->once())->method('launch')->willReturn($responseMock); + $this->bootstrapMock->run($this->application); + } + + public function testRunWithMaintenanceErrors() + { + $expectedException = new \Exception(''); + $this->bootstrapMock->expects($this->once())->method('assertMaintenance') + ->will($this->throwException($expectedException)); + $this->bootstrapMock->expects($this->once())->method('terminate')->with($expectedException); + $this->application->expects($this->once())->method('catchException')->willReturn(false); + $this->bootstrapMock->run($this->application); + } + + public function testRunWithInstallErrors() + { + $expectedException = new \Exception(''); + $this->bootstrapMock->expects($this->once())->method('assertMaintenance')->will($this->returnValue(null)); + $this->bootstrapMock->expects($this->once())->method('assertInstalled') + ->will($this->throwException($expectedException)); + $this->bootstrapMock->expects($this->once())->method('terminate')->with($expectedException); + $this->application->expects($this->once())->method('catchException')->willReturn(false); + $this->bootstrapMock->run($this->application); + } + + public function testRunWithBothErrors() + { + $expectedMaintenanceException = new \Exception(''); + $this->bootstrapMock->expects($this->once())->method('assertMaintenance') + ->will($this->throwException($expectedMaintenanceException)); + $this->bootstrapMock->expects($this->never())->method('assertInstalled'); + $this->bootstrapMock->expects($this->once())->method('terminate')->with($expectedMaintenanceException); + $this->application->expects($this->once())->method('catchException')->willReturn(false); + $this->bootstrapMock->run($this->application); + } + + /** + * @param bool $isOn + * @param bool $isExpected + * + * @dataProvider assertMaintenanceDataProvider + */ + public function testAssertMaintenance($isOn, $isExpected) + { + $bootstrap = self::createBootstrap([Bootstrap::PARAM_REQUIRE_MAINTENANCE => $isExpected]); + $this->maintenanceMode->expects($this->once())->method('isOn')->willReturn($isOn); + $this->application->expects($this->never())->method('launch'); + $this->application->expects($this->once())->method('catchException')->willReturn(true); + $bootstrap->run($this->application); + $this->assertEquals(Bootstrap::ERR_MAINTENANCE, $bootstrap->getErrorCode()); + } + + /** + * @return array + */ + public function assertMaintenanceDataProvider() + { + return [ + [true, false], + [false, true] + ]; + } + + /** + * @param bool $isInstalled + * @param bool $isExpected + * + * @dataProvider assertInstalledDataProvider + */ + public function testAssertInstalled($isInstalled, $isExpected) + { + $bootstrap = self::createBootstrap([Bootstrap::PARAM_REQUIRE_IS_INSTALLED => $isExpected]); + $this->configDir->expects($this->once())->method('isExist')->willReturn($isInstalled); + $this->application->expects($this->never())->method('launch'); + $this->application->expects($this->once())->method('catchException')->willReturn(true); + $bootstrap->run($this->application); + $this->assertEquals(Bootstrap::ERR_IS_INSTALLED, $bootstrap->getErrorCode()); + } + + /** + * @return array + */ + public function assertInstalledDataProvider() + { + return [ + [false, true], + [true, false], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Cache/StateTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Cache/StateTest.php index 14344781c3ec58a87914849c9427ddd917fe6bdd..3562b981dc9581384ceed84c34207ae4fc5cb3a5 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Cache/StateTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Cache/StateTest.php @@ -43,14 +43,13 @@ class StateTest extends \PHPUnit_Framework_TestCase /** * @param string $cacheType * @param array $typeOptions - * @param bool $appInstalled * @param bool $banAll * @param bool $expectedIsEnabled * @dataProvider isEnabledDataProvider */ - public function testIsEnabled($cacheType, $typeOptions, $appInstalled, $banAll, $expectedIsEnabled) + public function testIsEnabled($cacheType, $typeOptions, $banAll, $expectedIsEnabled) { - $model = $this->_buildModel($typeOptions, array(), $appInstalled, $banAll); + $model = $this->_buildModel($typeOptions, array(), $banAll); $actualIsEnabled = $model->isEnabled($cacheType); $this->assertEquals($expectedIsEnabled, $actualIsEnabled); } @@ -64,35 +63,24 @@ class StateTest extends \PHPUnit_Framework_TestCase 'enabled' => array( 'cacheType' => 'cache_type', 'typeOptions' => array('some_type' => false, 'cache_type' => true), - 'appInstalled' => true, 'banAll' => false, 'expectedIsEnabled' => true ), 'disabled' => array( 'cacheType' => 'cache_type', 'typeOptions' => array('some_type' => true, 'cache_type' => false), - 'appInstalled' => true, 'banAll' => false, 'expectedIsEnabled' => false ), 'unknown is disabled' => array( 'cacheType' => 'unknown_cache_type', 'typeOptions' => array('some_type' => true), - 'appInstalled' => true, - 'banAll' => false, - 'expectedIsEnabled' => false - ), - 'disabled, when app is not installed' => array( - 'cacheType' => 'cache_type', - 'typeOptions' => array('cache_type' => true), - 'appInstalled' => false, 'banAll' => false, 'expectedIsEnabled' => false ), 'disabled, when all caches are banned' => array( 'cacheType' => 'cache_type', 'typeOptions' => array('cache_type' => true), - 'appInstalled' => true, 'banAll' => true, 'expectedIsEnabled' => false ) @@ -104,14 +92,12 @@ class StateTest extends \PHPUnit_Framework_TestCase * * @param array|false $cacheTypeOptions * @param array|false $resourceTypeOptions - * @param bool $appInstalled * @param bool $banAll * @return \Magento\Framework\App\Cache\StateInterface */ protected function _buildModel( $cacheTypeOptions, $resourceTypeOptions = false, - $appInstalled = true, $banAll = false ) { $this->_cacheFrontend = $this->getMock('Magento\Framework\Cache\FrontendInterface'); @@ -144,13 +130,9 @@ class StateTest extends \PHPUnit_Framework_TestCase $this->returnValue($resourceTypeOptions) ); - $appState = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $appState->expects($this->any())->method('isInstalled')->will($this->returnValue($appInstalled)); - $this->_model = new \Magento\Framework\App\Cache\State( $this->_resource, $cacheFrontendPool, - $appState, $banAll ); diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/EntryPoint/EntryPointTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/EntryPoint/EntryPointTest.php deleted file mode 100644 index 6a743df42d8b8ebfcd2b398b9b4e0c1b6688af11..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/App/EntryPoint/EntryPointTest.php +++ /dev/null @@ -1,184 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\EntryPoint; - -class EntryPointTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\App\EntryPoint\EntryPoint - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_objectManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_responseMock; - - /** - * @var string - */ - protected $_rootDir; - - /** - * @return void - */ - protected function setUp() - { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); - $this->_responseMock = $this->getMock('Magento\Framework\App\Response\Http', array(), array(), '', false); - $this->_rootDir = realpath(__DIR__ . '/../../../../../../../'); - } - - /** - * @return void - */ - public function testRunExecutesApplication() - { - $this->_model = new \Magento\Framework\App\EntryPoint\EntryPoint( - $this->_rootDir, - array(), - $this->_objectManagerMock - ); - - $applicationName = '\Magento\Framework\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\Framework\AppInterface'); - $applicationMock->expects($this->once())->method('launch')->will($this->returnValue($this->_responseMock)); - $this->_objectManagerMock->expects( - $this->once() - )->method( - 'create' - )->with( - $applicationName, - array() - )->will( - $this->returnValue($applicationMock) - ); - $this->assertNull($this->_model->run($applicationName)); - } - - /** - * @return void - */ - public function testRunCatchesExceptionThrownByApplicationDeveloperMode() - { - $this->_model = new \Magento\Framework\App\EntryPoint\EntryPoint( - $this->_rootDir, - array('MAGE_MODE' => 'developer'), - $this->_objectManagerMock - ); - - $applicationName = '\Magento\Framework\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\Framework\AppInterface'); - $applicationMock->expects( - $this->once() - )->method( - 'launch' - )->will( - $this->throwException(new \Exception('Something went wrong.')) - ); - $this->_objectManagerMock->expects( - $this->once() - )->method( - 'create' - )->with( - $applicationName, - array() - )->will( - $this->returnValue($applicationMock) - ); - // clean output - ob_start(); - $this->assertNull($this->_model->run($applicationName)); - ob_end_clean(); - } - - /** - * @return void - */ - public function testRunCatchesExceptionThrownByApplicationNonDeveloperMode() - { - $this->_model = new \Magento\Framework\App\EntryPoint\EntryPoint( - $this->_rootDir, - array(), - $this->_objectManagerMock - ); - - $exception = new \Exception('Something went wrong.'); - - $applicationName = '\Magento\Framework\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\Framework\AppInterface'); - $applicationMock->expects( - $this->once() - )->method( - 'launch' - )->will( - $this->throwException($exception) - ); - - $loggerMock = $this->getMock( - '\Magento\Framework\Logger', - array(), - array(), - '', - false - ); - $loggerMock->expects( - $this->once() - )->method( - 'logException' - )->will( - $this->throwException($exception) - ); - - $this->_objectManagerMock->expects( - $this->at(0) - )->method( - 'create' - )->with( - $applicationName, - array() - )->will( - $this->returnValue($applicationMock) - ); - $this->_objectManagerMock->expects( - $this->at(1) - )->method( - 'get' - )->with( - 'Magento\Framework\Logger' - )->will( - $this->returnValue($loggerMock) - ); - - // clean output - ob_start(); - $this->assertNull($this->_model->run($applicationName)); - ob_end_clean(); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Error/HandlerTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Error/HandlerTest.php deleted file mode 100644 index da7af2a173e1c98b8d8ac9eb442d0dab956b0d18..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Error/HandlerTest.php +++ /dev/null @@ -1,175 +0,0 @@ -<?php -/** - * Unit Test for \Magento\Framework\App\Error\Handler - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\Error; - -class HandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * Logger mock - * - * @var \Magento\Framework\Logger|\PHPUnit_Framework_MockObject_MockObject - */ - protected $logger; - - /** - * Filesystem mock - * - * @var \Magento\Framework\App\Filesystem|\PHPUnit_Framework_MockObject_MockObject - */ - protected $filesystem; - - /** - * App state mock - * - * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject - */ - protected $appState; - - /** - * Handler instance - * - * @var \Magento\Framework\App\Error\Handler - */ - protected $handler; - - protected function setUp() - { - $this->logger = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); - $this->filesystem = $this->getMock('Magento\Framework\App\Filesystem', array(), array(), '', false); - $this->appState = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->handler = new \Magento\Framework\App\Error\Handler($this->logger, $this->filesystem, $this->appState); - } - - /** - * Test for processException method print - * - * @covers \Magento\Framework\Error\Handler::processException - */ - public function testProcessExceptionPrint() - { - $this->appState->expects( - $this->any() - )->method( - 'getMode' - )->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER) - ); - $exception = new \Exception('TestMessage'); - - ob_start(); - $this->handler->processException($exception); - $actualResult = ob_get_contents(); - ob_end_clean(); - $this->assertRegExp('/TestMessage/', $actualResult); - } - - /** - * Test for processException method report - * - * @covers \Magento\Framework\Error\Handler::processException - * @runInSeparateProcess - */ - public function testProcessExceptionReport() - { - $this->appState->expects( - $this->any() - )->method( - 'getMode' - )->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEFAULT) - ); - $this->filesystem->expects( - $this->atLeastOnce() - )->method( - 'getPath' - )->with( - \Magento\Framework\App\Filesystem::PUB_DIR - )->will( - $this->returnValue(dirname(__DIR__) . '/../../_files') - ); - - $exception = new \Exception('TestMessage'); - $this->handler->processException($exception); - } - - /** - * Test for setting error handler and logging - * - * @covers \Magento\Framework\Error\Handler::handler - * @throws \Exception - */ - public function testErrorHandlerLogging() - { - $this->appState->expects( - $this->any() - )->method( - 'getMode' - )->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEFAULT) - ); - $this->logger->expects( - $this->once() - )->method( - 'log' - )->with( - $this->stringContains('testErrorHandlerLogging'), - \Zend_Log::ERR - ); - set_error_handler(array($this->handler, 'handler')); - try { - trigger_error('testErrorHandlerLogging', E_USER_NOTICE); - restore_error_handler(); - } catch (\Exception $e) { - restore_error_handler(); - throw $e; - } - } - - /** - * Test for setting error handler and printing - * - * @covers \Magento\Framework\Error\Handler::handler - * @expectedException \Exception - * @throws \Exception - */ - public function testErrorHandlerPrint() - { - $this->appState->expects( - $this->any() - )->method( - 'getMode' - )->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER) - ); - set_error_handler(array($this->handler, 'handler')); - try { - trigger_error('testErrorHandlerPrint', E_USER_NOTICE); - } catch (\Exception $e) { - restore_error_handler(); - throw $e; - } - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Error/HandlerTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/ErrorHandlerTest.php similarity index 78% rename from dev/tests/unit/testsuite/Magento/Framework/Error/HandlerTest.php rename to dev/tests/unit/testsuite/Magento/Framework/App/ErrorHandlerTest.php index 06f2dd04a6833a99ebf3046b5e58331ce73d34f6..e231e27ebc60dfcf39ce180d0ea2bd9c1033f201 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Error/HandlerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/ErrorHandlerTest.php @@ -21,29 +21,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\Error; -/** - * Class HandlerTest - */ -class HandlerTest extends \PHPUnit_Framework_TestCase +namespace Magento\Framework\App; + +class ErrorHandlerTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Error\Handler + * @var \Magento\Framework\App\ErrorHandler */ protected $object; protected function setUp() { - $this->object = new Handler(); - } - - public function testProcessException() - { - $expectedMessage = 'test message'; - - $this->expectOutputRegex('/(' . $expectedMessage . ')\s*?.*(internal function)((.*\s.*)*)({main})/'); - $this->object->processException(new \Exception($expectedMessage), []); + $this->object = new ErrorHandler(); } /** @@ -61,13 +51,6 @@ class HandlerTest extends \PHPUnit_Framework_TestCase public function handlerProvider() { return [ - [E_STRICT, 'error_string', 'pear', true], - [E_DEPRECATED, 'error_string', 'pear', true], - [E_STRICT, 'pear', 0, true], - [E_DEPRECATED, 'pear', 0, true], - [E_STRICT, 'pear', 'pear', true], - [E_DEPRECATED, 'pear', 'pear', true], - [E_WARNING, 'open_basedir', 'pear', true], [0, 'DateTimeZone::__construct', 0, false], [0, 0, 0, false] ]; diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Filesystem/DirectoryList/VerificationTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Filesystem/DirectoryList/VerificationTest.php index 542006ab7cb5b4773ec4d2d4fb35d46a6db209c1..ef893a633d00c52d934d86f13811dd301b920d72 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Filesystem/DirectoryList/VerificationTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Filesystem/DirectoryList/VerificationTest.php @@ -81,7 +81,7 @@ class VerificationTest extends \PHPUnit_Framework_TestCase * @param string $mode * @param array $expectedDirs * @dataProvider notWritableDataProvider - * @expectedException \Magento\Framework\BootstrapException + * @expectedException \Magento\Framework\App\InitException */ public function testNotWritable($mode, $expectedDirs) { @@ -114,7 +114,7 @@ class VerificationTest extends \PHPUnit_Framework_TestCase * @param string $mode * @param array $expectedDirs * @dataProvider createExceptionDataProvider - * @expectedException \Magento\Framework\BootstrapException + * @expectedException \Magento\Framework\App\InitException */ public function testCreateException($mode, $expectedDirs) { diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php index 96fb6af315d312b4fad88c2d4864ee0c664f2877..8deeb7f74a7e4cecc1c2a8107bc75a1673821afa 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php @@ -31,11 +31,6 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ protected $_objectManager; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_stateMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -82,11 +77,6 @@ class HttpTest extends \PHPUnit_Framework_TestCase $areaListMock->expects($this->once())->method('getCodeByFrontName')->with($frontName)->will( $this->returnValue($areaCode) ); - $this->_stateMock = $this->getMockBuilder('Magento\Framework\App\State') - ->disableOriginalConstructor() - ->setMethods(['setAreaCode', 'getMode']) - ->getMock(); - $this->_stateMock->expects($this->once())->method('setAreaCode')->with($areaCode); $areaConfig = []; $configLoaderMock = $this->getMockBuilder( 'Magento\Framework\App\ObjectManager\ConfigLoader' @@ -133,12 +123,11 @@ class HttpTest extends \PHPUnit_Framework_TestCase 'request' => $this->_requestMock, 'response' => $this->_responseMock, 'configLoader' => $configLoaderMock, - 'state' => $this->_stateMock, 'filesystem' => $this->_filesystemMock ] ); } - + public function testLaunchSuccess() { $this->_eventManagerMock->expects($this->once())->method('dispatch')->with( @@ -148,7 +137,11 @@ class HttpTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->_responseMock, $this->_http->launch()); } - public function testLaunchDispatchException() + /** + * @expectedException \Exception + * @expectedExceptionMessage Message + */ + public function testLaunchException() { $this->_frontControllerMock->expects($this->once())->method('dispatch')->with($this->_requestMock)->will( $this->returnCallback( @@ -157,14 +150,6 @@ class HttpTest extends \PHPUnit_Framework_TestCase } ) ); - $this->_stateMock->expects($this->once())->method('getMode')->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER) - ); - $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(500); - - $this->_responseMock->expects($this->once())->method('setBody')->with( - $this->matchesRegularExpression('/Message[\n]+<pre>Message[\n]*(.|\n)*<\/pre>/') - ); - $this->assertSame($this->_responseMock, $this->_http->launch()); + $this->_http->launch(); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/MaintenanceModeTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/MaintenanceModeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c7b0e0ffa906fb7afbfe36b3869dea72d2771a6c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/MaintenanceModeTest.php @@ -0,0 +1,168 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\App; + +class MaintenanceModeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MaintenanceMode + */ + protected $model; + + /** + * @var \Magento\Framework\Filesystem\Directory\WriteInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $flagDir ; + + protected function setUp() + { + $this->flagDir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $filesystem = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); + $filesystem->expects($this->any()) + ->method('getDirectoryWrite') + ->will($this->returnValue($this->flagDir)); + + $this->model = new MaintenanceMode($filesystem); + } + + public function testIsOnInitial() + { + $this->flagDir->expects($this->once())->method('isExist') + ->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(false)); + $this->assertFalse($this->model->isOn()); + } + + public function testSetMaintenanceModeOn() + { + $this->flagDir->expects($this->at(0))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(false)); + $this->flagDir->expects($this->at(1))->method('touch')->will($this->returnValue(true)); + $this->flagDir->expects($this->at(2))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(true)); + $this->flagDir->expects($this->at(3))->method('isExist')->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue(false)); + + + $this->assertFalse($this->model->isOn()); + $this->assertTrue($this->model->set(true)); + $this->assertTrue($this->model->isOn()); + } + + public function testSetMaintenanceModeOff() + { + $this->flagDir->expects($this->at(0))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(true)); + $this->flagDir->expects($this->at(1))->method('delete')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(false)); + $this->flagDir->expects($this->at(2))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(false)); + + $this->assertFalse($this->model->set(false)); + $this->assertFalse($this->model->isOn()); + } + + public function testSetAddresses() + { + $mapIsExist = [ + [MaintenanceMode::FLAG_FILENAME, true], + [MaintenanceMode::IP_FILENAME, true] + ]; + $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapIsExist)); + $this->flagDir->expects($this->any())->method('writeFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue(true)); + + $this->flagDir->expects($this->any())->method('readFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue('')); + + $this->model->setAddresses(''); + $this->assertEquals([''], $this->model->getAddressInfo()); + } + + public function testSetSingleAddresses() + { + $mapIsExist = [ + [MaintenanceMode::FLAG_FILENAME, true], + [MaintenanceMode::IP_FILENAME, true] + ]; + $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapIsExist)); + $this->flagDir->expects($this->any())->method('delete')->will($this->returnValueMap($mapIsExist)); + + $this->flagDir->expects($this->any())->method('writeFile') + ->will($this->returnValue(10)); + + $this->flagDir->expects($this->any())->method('readFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue('address1')); + + $this->model->setAddresses('address1'); + $this->assertEquals(['address1'], $this->model->getAddressInfo()); + } + + public function testOnSetMultipleAddresses() + { + $mapIsExist = [ + [MaintenanceMode::FLAG_FILENAME, true], + [MaintenanceMode::IP_FILENAME, true] + ]; + $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapIsExist)); + $this->flagDir->expects($this->any())->method('delete')->will($this->returnValueMap($mapIsExist)); + + $this->flagDir->expects($this->any())->method('writeFile') + ->will($this->returnValue(10)); + + $this->flagDir->expects($this->any())->method('readFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue('address1,10.50.60.123')); + + $expectedArray = ['address1', '10.50.60.123']; + $this->model->setAddresses('address1,10.50.60.123'); + $this->assertEquals($expectedArray, $this->model->getAddressInfo()); + $this->assertFalse($this->model->isOn('address1')); + $this->assertTrue($this->model->isOn('address3')); + } + + public function testOffSetMultipleAddresses() + { + $mapIsExist = [ + [MaintenanceMode::FLAG_FILENAME, false], + [MaintenanceMode::IP_FILENAME, true] + ]; + $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapIsExist)); + $this->flagDir->expects($this->any())->method('delete')->will($this->returnValueMap($mapIsExist)); + + $this->flagDir->expects($this->any())->method('readFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue('address1,10.50.60.123')); + + $expectedArray = ['address1', '10.50.60.123']; + $this->model->setAddresses('address1,10.50.60.123'); + $this->assertEquals($expectedArray, $this->model->getAddressInfo()); + $this->assertFalse($this->model->isOn('address1')); + $this->assertFalse($this->model->isOn('address3')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php index 971325cc79f801260a21eaabff7f9684461886b4..e3e0e1de7ac81fa589c21833d1053baee65a3f80 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php @@ -104,6 +104,11 @@ class VersionTest extends \PHPUnit_Framework_TestCase ->with(Version::COOKIE_PERIOD) ->will($this->returnSelf()); + $publicCookieMetadataMock->expects($this->once()) + ->method('setHttpOnly') + ->with(false) + ->will($this->returnSelf()); + $this->cookieMetadataFactoryMock->expects($this->once()) ->method('createPublicCookieMetadata') ->with() diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php index ef6d099e019b3cb6cca1ddf8a5332729cad13446..0af640c14497552987eae922521912a2089b5ce5 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php @@ -93,8 +93,10 @@ class HttpTest extends \PHPUnit_Framework_TestCase $data = ['some-vary-key' => 'some-vary-value']; $expectedCookieName = Http::COOKIE_VARY_STRING; $expectedCookieValue = sha1(serialize($data)); - $publicCookieMetadataMock = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata'); - $publicCookieMetadataMock->expects($this->once()) + $sensitiveCookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata') + ->disableOriginalConstructor() + ->getMock(); + $sensitiveCookieMetadataMock->expects($this->once()) ->method('setPath') ->with('/') ->will($this->returnSelf()); @@ -107,15 +109,15 @@ class HttpTest extends \PHPUnit_Framework_TestCase ); $this->cookieMetadataFactoryMock->expects($this->once()) - ->method('createPublicCookieMetadata') + ->method('createSensitiveCookieMetadata') ->with() ->will( - $this->returnValue($publicCookieMetadataMock) + $this->returnValue($sensitiveCookieMetadataMock) ); $this->cookieManagerMock->expects($this->once()) - ->method('setPublicCookie') - ->with($expectedCookieName, $expectedCookieValue, $publicCookieMetadataMock); + ->method('setSensitiveCookie') + ->with($expectedCookieName, $expectedCookieValue, $sensitiveCookieMetadataMock); $this->model->sendVary(); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/State/MaintenanceModeTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/State/MaintenanceModeTest.php deleted file mode 100644 index b64a61335c43f36acc74eb6cff1ee0d16e396482..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/App/State/MaintenanceModeTest.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\State; - -class MaintenanceModeTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\App\State\MaintenanceMode - */ - protected $model; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write | \PHPUnit_Framework_MockObject_MockObject - */ - protected $directoryWrite; - - /** - * @var \Magento\Framework\App\Filesystem | \PHPUnit_Framework_MockObject_MockObject - */ - protected $filesystem; - - protected function setUp() - { - $this->directoryWrite = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); - $this->filesystem = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); - - $this->model = (new \Magento\TestFramework\Helper\ObjectManager($this))->getObject( - 'Magento\Framework\App\State\MaintenanceMode', - ['filesystem' => $this->filesystem] - ); - } - - protected function getDirectory() - { - $this->filesystem->expects($this->once())->method('getDirectoryWrite')->with(MaintenanceMode::FLAG_DIR) - ->will($this->returnValue($this->directoryWrite)); - } - - public function testTurnOnMaintenanceMode() - { - $this->getDirectory(); - $this->directoryWrite->expects($this->once())->method('writeFile') - ->with(MaintenanceMode::FLAG_FILENAME, 'data') - ->will($this->returnValue(123)); - - $this->assertTrue($this->model->turnOn('data')); - } - - public function testTurnOnMaintenanceModeFailed() - { - $this->getDirectory(); - $this->directoryWrite->expects($this->once())->method('writeFile') - ->with(MaintenanceMode::FLAG_FILENAME, 'data') - ->will($this->throwException(new \Magento\Framework\Filesystem\FilesystemException('failed'))); - - $this->assertFalse($this->model->turnOn('data')); - } - - public function testTurnOffMaintenanceMode() - { - $this->getDirectory(); - $this->directoryWrite->expects($this->once())->method('delete')->with(MaintenanceMode::FLAG_FILENAME); - - $this->assertTrue($this->model->turnOff()); - } - - public function testTurnOffMaintenanceModeFailed() - { - $this->getDirectory(); - $this->directoryWrite->expects($this->once())->method('delete')->with(MaintenanceMode::FLAG_FILENAME) - ->will($this->throwException(new \Magento\Framework\Filesystem\FilesystemException('failed'))); - - $this->assertFalse($this->model->turnOff()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/StaticResourceTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/StaticResourceTest.php index 0a281b70b90ffb4d352d05682f5ff8df7567a4f4..5bf35551dd1366fe1ed304d26f51b7e9664b68f8 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/StaticResourceTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/StaticResourceTest.php @@ -73,7 +73,7 @@ class StaticResourceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->state = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->response = $this->getMockForAbstractClass('Magento\Framework\App\Response\FileInterface'); + $this->response = $this->getMock('Magento\Core\Model\File\Storage\Response', array(), array(), '', false); $this->request = $this->getMock('Magento\Framework\App\Request\Http', array(), array(), '', false); $this->publisher = $this->getMock('Magento\Framework\App\View\Asset\Publisher', array(), array(), '', false); $this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', array(), array(), '', false); @@ -202,4 +202,18 @@ class StaticResourceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('short/path.js')); $this->object->launch(); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $bootstrap->expects($this->at(0))->method('isDeveloperMode')->willReturn(false); + $bootstrap->expects($this->at(1))->method('isDeveloperMode')->willReturn(true); + $exception = new \Exception('message'); + $this->response->expects($this->exactly(2))->method('setHttpResponseCode')->with(404); + $this->response->expects($this->exactly(2))->method('setHeader')->with('Content-Type', 'text/plain'); + $this->response->expects($this->exactly(2))->method('sendResponse'); + $this->response->expects($this->once())->method('setBody')->with($this->stringStartsWith('message')); + $this->assertTrue($this->object->catchException($bootstrap, $exception)); + $this->assertTrue($this->object->catchException($bootstrap, $exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Backup/MediaTest.php b/dev/tests/unit/testsuite/Magento/Framework/Backup/MediaTest.php index e348385cab3962d73bb729d784f65798ef8637eb..7ea99ba9d5af4039b8e9143369893d6bae1a8847 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Backup/MediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Backup/MediaTest.php @@ -26,7 +26,6 @@ namespace Magento\Framework\Backup; require_once __DIR__ . '/_files/Fs.php'; require_once __DIR__ . '/_files/Helper.php'; require_once __DIR__ . '/_files/io.php'; -require_once __DIR__ . '/_files/app_dirs.php'; class MediaTest extends \PHPUnit_Framework_TestCase { @@ -45,6 +44,11 @@ class MediaTest extends \PHPUnit_Framework_TestCase */ protected $_backupDbMock; + public static function setUpBeforeClass() + { + require __DIR__ . '/_files/app_dirs.php'; + } + protected function setUp() { $this->_backupDbMock = $this->getMock('Magento\Framework\Backup\Db', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Backup/NomediaTest.php b/dev/tests/unit/testsuite/Magento/Framework/Backup/NomediaTest.php index a5c598c3fecb5717803619339a70833163512480..b7381a0a0df8f7434d7177f347a8832142ece321 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Backup/NomediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Backup/NomediaTest.php @@ -26,7 +26,6 @@ namespace Magento\Framework\Backup; require_once __DIR__ . '/_files/Fs.php'; require_once __DIR__ . '/_files/Helper.php'; require_once __DIR__ . '/_files/io.php'; -require_once __DIR__ . '/_files/app_dirs.php'; class NomediaTest extends \PHPUnit_Framework_TestCase { @@ -45,6 +44,11 @@ class NomediaTest extends \PHPUnit_Framework_TestCase */ protected $_backupDbMock; + public static function setUpBeforeClass() + { + require __DIR__ . '/_files/app_dirs.php'; + } + protected function setUp() { $this->_backupDbMock = $this->getMock('Magento\Framework\Backup\Db', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php b/dev/tests/unit/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php index 46c23a85d4360920fd30574b6c5b4c3e2e1d5cbb..517a5f11c148a3c987270f1e8d22b70940f204fc 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php @@ -169,7 +169,7 @@ class MysqlTest extends \PHPUnit_Framework_TestCase * Test DDL query inside transaction in Developer mode * * @dataProvider ddlSqlQueryProvider - * @expectedException \PHPUnit_Framework_Error + * @expectedException \Exception * @expectedExceptionMessage DDL statements are not allowed in transactions */ public function testCheckDdlTransaction($ddlQuery) diff --git a/dev/tests/unit/testsuite/Magento/Framework/DB/SelectTest.php b/dev/tests/unit/testsuite/Magento/Framework/DB/SelectTest.php index db2cbe5e70951cc7e5a9ec12b042b6e78363a250..d20fb2ef087ab6778e334f84db8923d3af72922c 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/DB/SelectTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/DB/SelectTest.php @@ -23,27 +23,75 @@ */ namespace Magento\Framework\DB; +use Magento\TestFramework\Helper\ObjectManager; + class SelectTest extends \PHPUnit_Framework_TestCase { + public function testGetMatchQuery() + { + /** @var Select $select */ + $select = (new ObjectManager($this))->getObject('Magento\Framework\DB\Select'); + + $result = $select->getMatchQuery( + ['title', 'description'], + 'some searchable text', + Select::FULLTEXT_MODE_NATURAL + ); + $expectedResult = "MATCH (title, description) AGAINST ('some searchable text' IN NATURAL LANGUAGE MODE)"; + + $this->assertEquals($expectedResult, $result); + } + + public function testMatch() + { + $adapter = $this->getMock( + 'Zend_Db_Adapter_Pdo_Mysql', + array('supportStraightJoin', 'quote'), + array(), + '', + false + ); + $adapter->expects($this->at(0))->method('quote') + ->with($this->equalTo('some searchable text')) + ->will($this->returnValue("'some searchable text'")); + $adapter->expects($this->at(1))->method('quote') + ->will($this->returnValue('')); + + /** @var Select $select */ + $select = (new ObjectManager($this))->getObject( + 'Magento\Framework\DB\Select', + ['adapter' => $adapter] + ); + + $select->from('test'); + $select->match(['title', 'description'], 'some searchable text', true, Select::FULLTEXT_MODE_NATURAL); + + $expectedResult = "SELECT `test`.* FROM `test` WHERE (MATCH (title, description) " . + "AGAINST ('some searchable text' IN NATURAL LANGUAGE MODE))"; + $result = $select->assemble(); + + $this->assertEquals($expectedResult, $result); + } + public function testWhere() { - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(1, "'5'")); + $select = new Select($this->_getAdapterMockWithMockedQuote(1, "'5'")); $select->from('test')->where('field = ?', 5); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (field = '5')", $select->assemble()); - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(1, "''")); + $select = new Select($this->_getAdapterMockWithMockedQuote(1, "''")); $select->from('test')->where('field = ?'); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (field = '')", $select->assemble()); - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(1, "'%?%'")); + $select = new Select($this->_getAdapterMockWithMockedQuote(1, "'%?%'")); $select->from('test')->where('field LIKE ?', '%value?%'); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (field LIKE '%?%')", $select->assemble()); - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(0)); - $select->from('test')->where("field LIKE '%value?%'", null, \Magento\Framework\DB\Select::TYPE_CONDITION); + $select = new Select($this->_getAdapterMockWithMockedQuote(0)); + $select->from('test')->where("field LIKE '%value?%'", null, Select::TYPE_CONDITION); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (field LIKE '%value?%')", $select->assemble()); - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(1, "'1', '2', '4', '8'")); + $select = new Select($this->_getAdapterMockWithMockedQuote(1, "'1', '2', '4', '8'")); $select->from('test')->where("id IN (?)", array(1, 2, 4, 8)); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (id IN ('1', '2', '4', '8'))", $select->assemble()); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Event/Config/DataTest.php b/dev/tests/unit/testsuite/Magento/Framework/Event/Config/DataTest.php deleted file mode 100644 index 78443ac9623d75debc773bd9b4013dff6b234415..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/Event/Config/DataTest.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\Event\Config; - -class DataTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\Event\Config\Data - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_readerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configScopeMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_cacheMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - protected function setUp() - { - $this->_readerMock = $this->getMock('Magento\Framework\Event\Config\Reader', array(), array(), '', false); - $this->_configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); - $this->_cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->_model = new \Magento\Framework\Event\Config\Data( - $this->_readerMock, - $this->_configScopeMock, - $this->_cacheMock, - $this->_appStateMock - ); - } - - public function testGet() - { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_configScopeMock->expects($this->once())->method('getCurrentScope')->will($this->returnValue('value')); - $this->assertEquals(null, $this->_model->get()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Less/PreProcessor/Instruction/MagentoImportTest.php b/dev/tests/unit/testsuite/Magento/Framework/Less/PreProcessor/Instruction/MagentoImportTest.php index 7361d84815a7749525bcf2c99baca69a1c86514b..8dc8eb5a911684b388253cb70415ffd8367728ad 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Less/PreProcessor/Instruction/MagentoImportTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Less/PreProcessor/Instruction/MagentoImportTest.php @@ -52,9 +52,9 @@ class MagentoImportTest extends \PHPUnit_Framework_TestCase private $assetRepo; /** - * @var \Magento\Framework\View\Design\Theme\Provider|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\View\Design\Theme\ListInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $themeProvider; + private $themeList; /** * @var \Magento\Framework\Less\PreProcessor\Instruction\Import @@ -71,13 +71,13 @@ class MagentoImportTest extends \PHPUnit_Framework_TestCase $this->asset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); $this->asset->expects($this->any())->method('getContentType')->will($this->returnValue('css')); $this->assetRepo = $this->getMock('\Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->themeProvider = $this->getMock('\Magento\Framework\View\Design\Theme\Provider', [], [], '', false); + $this->themeList = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Theme\ListInterface'); $this->object = new \Magento\Framework\Less\PreProcessor\Instruction\MagentoImport( $this->design, $this->fileSource, $this->errorHandler, $this->assetRepo, - $this->themeProvider + $this->themeList ); } @@ -104,7 +104,7 @@ class MagentoImportTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($relatedAsset)); $relatedAsset->expects($this->once())->method('getContext')->will($this->returnValue($context)); $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); - $this->themeProvider->expects($this->once())->method('getThemeModel')->will($this->returnValue($theme)); + $this->themeList->expects($this->once())->method('getThemeByFullPath')->will($this->returnValue($theme)); $files = []; foreach ($foundFiles as $file) { $fileObject = $this->getMock('Magento\Framework\View\File', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php b/dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php index 1375f86eaace235ab65879ecc2042dedb8f59c40..fcea02f8df33752c1e415566557b709818257c3c 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php @@ -31,11 +31,6 @@ class ListsTest extends \PHPUnit_Framework_TestCase */ protected $listsModel; - /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\State - */ - protected $mockAppState; - /** * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\ScopeResolverInterface */ @@ -53,9 +48,6 @@ class ListsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mockAppState = $this->getMockBuilder('\Magento\Framework\App\State') - ->disableOriginalConstructor() - ->getMock(); $this->mockScopeResolver = $this->getMockBuilder('\Magento\Framework\App\ScopeResolverInterface') ->disableOriginalConstructor() ->getMock(); @@ -71,7 +63,6 @@ class ListsTest extends \PHPUnit_Framework_TestCase ->with($locale); $this->listsModel = new \Magento\Framework\Locale\Lists( - $this->mockAppState, $this->mockScopeResolver, $this->mockConfig, $this->mockLocaleResolver, @@ -169,10 +160,6 @@ class ListsTest extends \PHPUnit_Framework_TestCase ->method('getLocale') ->will($this->returnValue($locale)); - $this->mockAppState->expects($this->once()) - ->method('isInstalled') - ->will($this->returnValue(false)); - $allowedCurrencies = ['USD', 'GBP', 'EUR']; $this->mockConfig->expects($this->once()) diff --git a/dev/tests/unit/testsuite/Magento/Framework/LoggerTest.php b/dev/tests/unit/testsuite/Magento/Framework/LoggerTest.php index 76509bb84a0edac41b2926a29f91ff90a90703f9..4bb5fed75380081d5f2ed48cd050de60b1fe9d5e 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/LoggerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/LoggerTest.php @@ -47,9 +47,28 @@ class LoggerTest extends \PHPUnit_Framework_TestCase */ protected $directory; + /** + * @var string + */ + private static $logDir; + + public static function setUpBeforeClass() + { + self::$logDir = TESTS_TEMP_DIR . '/var/log'; + if (!is_dir(self::$logDir)) { + mkdir(self::$logDir, 0777, true); + } + } + + public static function tearDownAfterClass() + { + $filesystemAdapter = new \Magento\Framework\Filesystem\Driver\File(); + $filesystemAdapter->deleteDirectory(self::$logDir); + } + protected function setUp() { - $logDir = TESTS_TEMP_DIR . '/var/log'; + $logDir = self::$logDir; $this->filesystemMock = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); $this->directory = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); $this->filesystemMock->expects($this->any()) @@ -66,15 +85,16 @@ class LoggerTest extends \PHPUnit_Framework_TestCase ) ); - if (!is_dir($logDir)) { - mkdir($logDir, 0777, true); - } - $this->model = new \Magento\Framework\Logger($this->filesystemMock); $this->loggersProperty = new \ReflectionProperty($this->model, '_loggers'); $this->loggersProperty->setAccessible(true); } + protected function tearDown() + { + $this->model = null; // will cause __descruct() in the underlying log class, which will close the open log files + } + /** * @param string $key * @param string $fileOrWrapper @@ -206,4 +226,4 @@ class LoggerTest extends \PHPUnit_Framework_TestCase $this->model->logFile($message, \Zend_Log::DEBUG, $filename); $this->assertTrue($this->model->hasLog($filename)); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Module/Declaration/Reader/FilesystemTest.php b/dev/tests/unit/testsuite/Magento/Framework/Module/Declaration/Reader/FilesystemTest.php index ad681ab342730677a089d6bdfddfd345158d17fe..52f19ed5882b8fb0e80d5bcdd15c49a7e993da2f 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Module/Declaration/Reader/FilesystemTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Module/Declaration/Reader/FilesystemTest.php @@ -43,9 +43,6 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase ); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - $dependencyManager = $this->getMock('Magento\Framework\Module\DependencyManagerInterface'); $dependencyManager->expects( $this->any() @@ -60,7 +57,6 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase $converter, $schemaLocatorMock, $validationStateMock, - $appStateMock, $dependencyManager ); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Module/ManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Module/ManagerTest.php index 2af2740373d5766fcb3a120b81e5affcba3e02c1..151fd28cfa20d57d003d9ec5ce5f155dc36db9a8 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Module/ManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Module/ManagerTest.php @@ -45,41 +45,47 @@ class ManagerTest extends \PHPUnit_Framework_TestCase */ private $_outputConfig; + /** + * @var \Magento\Framework\Module\ResourceInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $moduleResource; + protected function setUp() { $this->_moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); + $this->_moduleList->expects($this->any()) + ->method('getModule') + ->will($this->returnValueMap([ + ['Module_One', ['name' => 'One_Module', 'schema_version' => '1']], + ['Module_Two', ['name' => 'Two_Module', 'schema_version' => '2']], + ['Module_Three', ['name' => 'Two_Three']], + ])); $this->_outputConfig = $this->getMockForAbstractClass('Magento\Framework\Module\Output\ConfigInterface'); + $this->moduleResource = $this->getMockForAbstractClass('\Magento\Framework\Module\ResourceInterface'); $this->_model = new \Magento\Framework\Module\Manager( $this->_outputConfig, $this->_moduleList, + $this->moduleResource, array( - 'Fixture_Module' => self::XML_PATH_OUTPUT_ENABLED, + 'Module_Two' => self::XML_PATH_OUTPUT_ENABLED, ) ); } public function testIsEnabledReturnsTrueForActiveModule() { - $this->_moduleList->expects( - $this->once() - )->method( - 'getModule' - )->will( - $this->returnValue(array('name' => 'Some_Module')) - ); - $this->assertTrue($this->_model->isEnabled('Some_Module')); + $this->assertTrue($this->_model->isEnabled('Module_One')); } public function testIsEnabledReturnsFalseForInactiveModule() { - $this->_moduleList->expects($this->once())->method('getModule'); - $this->assertFalse($this->_model->isEnabled('Some_Module')); + $this->assertFalse($this->_model->isEnabled('Disabled_Module')); } public function testIsOutputEnabledReturnsFalseForDisabledModule() { $this->_outputConfig->expects($this->any())->method('isSetFlag')->will($this->returnValue(true)); - $this->assertFalse($this->_model->isOutputEnabled('Nonexisting_Module')); + $this->assertFalse($this->_model->isOutputEnabled('Disabled_Module')); } /** @@ -89,23 +95,12 @@ class ManagerTest extends \PHPUnit_Framework_TestCase */ public function testIsOutputEnabledGenericConfigPath($configValue, $expectedResult) { - $this->_moduleList->expects( - $this->any() - )->method( - 'getModule' - )->will( - $this->returnValue(array('name' => 'Module_EnabledOne')) - ); - $this->_outputConfig->expects( - $this->once() - )->method( - 'isEnabled' - )->with( - 'Module_EnabledOne' - )->will( - $this->returnValue($configValue) - ); - $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_EnabledOne')); + $this->_outputConfig->expects($this->once()) + ->method('isEnabled') + ->with('Module_One') + ->will($this->returnValue($configValue)) + ; + $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_One')); } public function isOutputEnabledGenericConfigPathDataProvider() @@ -115,36 +110,89 @@ class ManagerTest extends \PHPUnit_Framework_TestCase /** * @param bool $configValue - * @param string $moduleName * @param bool $expectedResult * @dataProvider isOutputEnabledCustomConfigPathDataProvider */ - public function testIsOutputEnabledCustomConfigPath($configValue, $moduleName, $expectedResult) + public function testIsOutputEnabledCustomConfigPath($configValue, $expectedResult) { - $this->_moduleList->expects( - $this->any() - )->method( - 'getModule' - )->will( - $this->returnValue(array('name' => $moduleName)) - ); - $this->_outputConfig->expects( - $this->at(0) - )->method( - 'isSetFlag' - )->with( - self::XML_PATH_OUTPUT_ENABLED - )->will( - $this->returnValue($configValue) - ); - $this->assertEquals($expectedResult, $this->_model->isOutputEnabled($moduleName)); + $this->_outputConfig->expects($this->at(0)) + ->method('isSetFlag') + ->with(self::XML_PATH_OUTPUT_ENABLED) + ->will($this->returnValue($configValue)) + ; + $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_Two')); } public function isOutputEnabledCustomConfigPathDataProvider() { return array( - 'path literal, output disabled' => array(false, 'Fixture_Module', false), - 'path literal, output enabled' => array(true, 'Fixture_Module', true), + 'path literal, output disabled' => array(false, false), + 'path literal, output enabled' => array(true, true), ); } + + /** + * @param string $moduleName + * @param string|bool $dbVersion + * @param bool $expectedResult + * + * @dataProvider isDbUpToDateDataProvider + */ + public function testIsDbSchemaUpToDate($moduleName, $dbVersion, $expectedResult) + { + $resourceName = 'resource'; + $this->moduleResource->expects($this->once()) + ->method('getDbVersion') + ->with($resourceName) + ->will($this->returnValue($dbVersion)); + $this->assertSame($expectedResult, $this->_model->isDbSchemaUpToDate($moduleName, $resourceName)); + } + + /** + * @param string $moduleName + * @param string|bool $dbVersion + * @param bool $expectedResult + * + * @dataProvider isDbUpToDateDataProvider + */ + public function testIsDbDataUpToDate($moduleName, $dbVersion, $expectedResult) + { + $resourceName = 'resource'; + $this->moduleResource->expects($this->once()) + ->method('getDataVersion') + ->with($resourceName) + ->will($this->returnValue($dbVersion)); + $this->assertSame($expectedResult, $this->_model->isDbDataUpToDate($moduleName, $resourceName)); + } + + /** + * @return array + */ + public function isDbUpToDateDataProvider() + { + return [ + 'version in config == version in db' => ['Module_One', '1', true], + 'version in config < version in db' => ['Module_One', '2', false], + 'version in config > version in db' => ['Module_Two', '1', false], + 'no version in db' => ['Module_One', false, false], + ]; + } + + /** + * @expectedException \UnexpectedValueException + * @expectedExceptionMessage Schema version for module 'Module_Three' is not specified + */ + public function testIsDbSchemaUpToDateException() + { + $this->_model->isDbSchemaUpToDate('Module_Three', 'resource'); + } + + /** + * @expectedException \UnexpectedValueException + * @expectedExceptionMessage Schema version for module 'Module_Three' is not specified + */ + public function testIsDbDataUpToDateException() + { + $this->_model->isDbDataUpToDate('Module_Three', 'resource'); + } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php b/dev/tests/unit/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..56b2fb365aef1f2b795763d4ab4d7958dfd3afa5 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php @@ -0,0 +1,198 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Module\Plugin; + +class DbStatusValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Module\Plugin\DbStatusValidator + */ + protected $_model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_cacheMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_dbUpdaterMock; + + /** + * @var \Closure + */ + protected $closureMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + private $moduleManager; + + protected function setUp() + { + $this->_cacheMock = $this->getMock('\Magento\Framework\Cache\FrontendInterface'); + $this->_dbUpdaterMock = $this->getMock('\Magento\Framework\Module\Updater', [], [], '', false); + $this->closureMock = function () { + return 'Expected'; + }; + $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); + $moduleList = $this->getMockForAbstractClass('\Magento\Framework\Module\ModuleListInterface'); + $moduleList->expects($this->any()) + ->method('getModules') + ->will($this->returnValue([ + 'Module_One' => 'module_one', + 'Module_Two' => 'module_two', + ])); + $resourceResolver = $this->getMockForAbstractClass('\Magento\Framework\Module\ResourceResolverInterface'); + $resourceResolver->expects($this->any()) + ->method('getResourceList') + ->will($this->returnCallback(function ($moduleName) { + return ['resource_' . $moduleName]; + })); + $this->moduleManager = $this->getMock('\Magento\Framework\Module\Manager', [], [], '', false); + $this->_model = new DbStatusValidator( + $this->_cacheMock, + $moduleList, + $resourceResolver, + $this->moduleManager + ); + } + + public function testAroundDispatch() + { + $this->_cacheMock->expects($this->once()) + ->method('load') + ->with('db_is_up_to_date') + ->will($this->returnValue(false)) + ; + $returnMap = [ + ['Module_One', 'resource_Module_One', true], + ['Module_Two', 'resource_Module_Two', true], + ]; + $this->moduleManager->expects($this->any()) + ->method('isDbSchemaUpToDate') + ->will($this->returnValueMap($returnMap)); + $this->moduleManager->expects($this->any()) + ->method('isDbDataUpToDate') + ->will($this->returnValueMap($returnMap)); + + $this->assertEquals( + 'Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) + ); + } + + public function testAroundDispatchCached() + { + $this->_cacheMock->expects($this->once()) + ->method('load') + ->with('db_is_up_to_date') + ->will($this->returnValue(true)) + ; + $this->moduleManager->expects($this->never()) + ->method('isDbSchemaUpToDate'); + $this->moduleManager->expects($this->never()) + ->method('isDbDataUpToDate'); + $this->assertEquals( + 'Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) + ); + } + + /** + * @param array $schemaValueMap + * @param array $dataValueMap + * + * @dataProvider aroundDispatchExceptionDataProvider + * @expectedException \Magento\Framework\Module\Exception + * @expectedExceptionMessage Looks like database is outdated. Please, use setup tool to perform update + */ + public function testAroundDispatchException(array $schemaValueMap, array $dataValueMap) + { + $this->_cacheMock->expects($this->once()) + ->method('load') + ->with('db_is_up_to_date') + ->will($this->returnValue(false)) + ; + $this->_cacheMock->expects($this->never())->method('save'); + $this->moduleManager->expects($this->any()) + ->method('isDbSchemaUpToDate') + ->will($this->returnValueMap($schemaValueMap)); + $this->moduleManager->expects($this->any()) + ->method('isDbDataUpToDate') + ->will($this->returnValueMap($dataValueMap)); + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock); + } + + /** + * @return array + */ + public function aroundDispatchExceptionDataProvider() + { + return [ + 'schema is outdated' => [ + [ + ['Module_One', 'resource_Module_One', false], + ['Module_Two', 'resource_Module_Two', true], + ], + [ + ['Module_One', 'resource_Module_One', true], + ['Module_Two', 'resource_Module_Two', true], + ], + ], + 'data is outdated' => [ + [ + ['Module_One', 'resource_Module_One', true], + ['Module_Two', 'resource_Module_Two', true], + ], + [ + ['Module_One', 'resource_Module_One', true], + ['Module_Two', 'resource_Module_Two', false], + ], + ], + 'both schema and data are outdated' => [ + [ + ['Module_One', 'resource_Module_One', false], + ['Module_Two', 'resource_Module_Two', false], + ], + [ + ['Module_One', 'resource_Module_One', false], + ['Module_Two', 'resource_Module_Two', false], + ], + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Module/UpdaterTest.php b/dev/tests/unit/testsuite/Magento/Framework/Module/UpdaterTest.php index 2b75fe0a8f60cd2578ec3279d8e5afe5e719d213..4ba40bc456dc21e57b3436ae1d457c6bbf17d3f5 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Module/UpdaterTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Module/UpdaterTest.php @@ -50,6 +50,11 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase */ protected $_resourceSetupMock; + /** + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + private $moduleManager; + /** * @var \Magento\Framework\Module\Updater */ @@ -79,101 +84,110 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase $this->_moduleListMock->expects($this->any())->method('getModules')->will($this->returnValue($moduleList)); $resourceList = array('catalog_setup'); - $this->_resourceResolver->expects( - $this->any() - )->method( - 'getResourceList' - )->with( - 'Test_Module' - )->will( - $this->returnValue($resourceList) - ); + $this->_resourceResolver->expects($this->any()) + ->method('getResourceList') + ->with('Test_Module') + ->will($this->returnValue($resourceList)) + ; - $this->_factoryMock->expects( - $this->any() - )->method( - 'create' - )->with( - 'catalog_setup', - 'Test_Module' - )->will( - $this->returnValue($this->_resourceSetupMock) - ); + $this->moduleManager = $this->getMock('\Magento\Framework\Module\Manager', [], [], '', false); $this->_model = new \Magento\Framework\Module\Updater( $this->_factoryMock, $this->_appStateMock, $this->_moduleListMock, $this->_resourceResolver, - true + $this->moduleManager ); } - /** - * @covers \Magento\Framework\Module\Updater::updateScheme - */ - public function testUpdateSchemeWithUpdateSkip() + public function testUpdateScheme() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - - $this->_appStateMock->expects($this->never())->method('setUpdateMode'); + $this->moduleManager->expects($this->once()) + ->method('isDbSchemaUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(false)); + $this->_factoryMock->expects($this->any()) + ->method('create') + ->with('catalog_setup', 'Test_Module') + ->will($this->returnValue($this->_resourceSetupMock)) + ; + $this->_appStateMock->expects($this->at(0))->method('setUpdateMode')->with(true); + $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(false); + $this->_resourceSetupMock->expects($this->once())->method('applyUpdates'); + $this->_resourceSetupMock->expects($this->once()) + ->method('getCallAfterApplyAllUpdates') + ->will($this->returnValue(true)); + $this->_resourceSetupMock->expects($this->once())->method('afterApplyAllUpdates'); $this->_model->updateScheme(); } - public function testUpdateSchemeDoesNotApplyUpdatesIfApplicationIsInstalledButUpdatesCanBeSkipped() + public function testUpdateSchemeNoUpdates() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->_resourceSetupMock->expects($this->never())->method('applyUpdates'); + $this->moduleManager->expects($this->once()) + ->method('isDbSchemaUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(true)); + $this->_factoryMock->expects($this->never()) + ->method('create'); $this->_model->updateScheme(); } /** - * @covers \Magento\Framework\Module\Updater::updateScheme + * @covers \Magento\Framework\Module\Updater::updateData */ - public function testUpdateSchemeAppliesUpdatesIfApplicationIsNotInstalled() + public function testUpdateDataNotApplied() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - - $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(true); - - $this->_appStateMock->expects($this->at(2))->method('setUpdateMode')->with(false); - - $this->_resourceSetupMock->expects($this->once())->method('applyUpdates'); - $this->_resourceSetupMock->expects( - $this->once() - )->method( - 'getCallAfterApplyAllUpdates' - )->will( - $this->returnValue(true) - ); - $this->_resourceSetupMock->expects($this->once())->method('afterApplyAllUpdates'); - - $this->_model->updateScheme(); + $this->moduleManager->expects($this->once()) + ->method('isDbDataUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(true)); + $this->_factoryMock->expects($this->never()) + ->method('create'); + $this->_model->updateData(); } - /** - * @covers \Magento\Framework\Module\Updater::updateData - */ - public function testUpdateDataDoesNotApplyDataUpdatesIfSchemaIsNotUpdated() + public function testUpdateData() { - $this->_resourceSetupMock->expects($this->never())->method('applyDataUpdates'); + $this->moduleManager->expects($this->once()) + ->method('isDbSchemaUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(true)); + $this->moduleManager->expects($this->once()) + ->method('isDbDataUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(false)); + $this->_factoryMock->expects($this->any()) + ->method('create') + ->with('catalog_setup', 'Test_Module') + ->will($this->returnValue($this->_resourceSetupMock)) + ; + $this->_appStateMock->expects($this->at(0))->method('setUpdateMode')->with(true); + $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(false); + $this->_resourceSetupMock->expects($this->once()) + ->method('applyDataUpdates'); + $this->_model->updateScheme(); $this->_model->updateData(); } - public function testUpdateDataAppliesDataUpdatesIfSchemaIsUpdated() + public function testUpdateDataNoUpdates() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(true); - $this->_appStateMock->expects($this->at(2))->method('setUpdateMode')->with(false); - $this->_resourceSetupMock->expects($this->once())->method('applyUpdates'); - $this->_resourceSetupMock->expects($this->once())->method('getCallAfterApplyAllUpdates') + $this->moduleManager->expects($this->once()) + ->method('isDbSchemaUpToDate') + ->with('Test_Module', 'catalog_setup') ->will($this->returnValue(true)); - $this->_resourceSetupMock->expects($this->once())->method('afterApplyAllUpdates'); - - $this->_resourceSetupMock->expects($this->once()) - ->method('applyDataUpdates'); + $this->moduleManager->expects($this->once()) + ->method('isDbDataUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(true)); + $this->_factoryMock->expects($this->never()) + ->method('create'); + $this->_appStateMock->expects($this->at(0))->method('setUpdateMode')->with(true); + $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(false); + $this->_factoryMock->expects($this->never()) + ->method('create'); $this->_model->updateScheme(); $this->_model->updateData(); diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php index fc07ca170e0b69772e4d7882bb47248dc287e15d..5dde6b26e2ed0eb0e3454105788ac612955450bd 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php @@ -23,7 +23,7 @@ */ return array( 'preferences' => array( - 'Magento\Framework\Module\UpdaterInterface' => 'Magento\Framework\Module\Updaterter', + 'Magento\Framework\Module\SomeInterface' => 'Magento\Framework\Module\ClassOne', 'Magento\Framework\App\RequestInterface' => 'Magento\Framework\App\Request\Http\Proxy', ), 'Magento\Framework\App\State' => array('arguments' => array('test name' => 'test value')), diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/simple_di_config.xml b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/simple_di_config.xml index 0b7ea68ae8f5aaa8482dd42a7218a1ae97be69a0..7a27c467059c878fb209b5b1267c9b4d6ab93d42 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/simple_di_config.xml +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/simple_di_config.xml @@ -25,7 +25,7 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <!-- Comment within root node --> - <preference for="Magento\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\Updaterter" /> + <preference for="Magento\Framework\Module\SomeInterface" type="Magento\Framework\Module\ClassOne" /> <preference for="Magento\Framework\App\RequestInterface" type="Magento\Framework\App\Request\Http\Proxy" /> <!--Arguments only--> <type name="Magento\Framework\App\State"> diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Helper/CompositeTest.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Helper/CompositeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4d974f7aefaf829e4ecdbf085c3caa03db005aa0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Helper/CompositeTest.php @@ -0,0 +1,85 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\ObjectManager\Helper; + +use Magento\TestFramework\Helper\ObjectManager; +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + +class CompositeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CompositeHelper + */ + protected $compositeHelper; + + /** + * @var ObjectManager + */ + protected $objectManager; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + $this->compositeHelper = $this->objectManager->getObject('Magento\Framework\ObjectManager\Helper\Composite'); + } + + public function testFilterAndSortDeclaredComponents() + { + $firstComponent = new \Magento\Framework\Object(); + $secondComponent = new \Magento\Framework\Object(); + $thirdComponent = new \Magento\Framework\Object(); + $contexts = [ + [ + 'type' => new \Magento\Framework\Object(), + ], + [ + 'sortOrder' => 50, + ], + [ + 'sortOrder' => 20, + 'type' => $firstComponent + ], + [ + 'sortOrder' => 30, + 'type' => $secondComponent, + ], + [ + 'sortOrder' => 10, + 'type' => $thirdComponent + ], + ]; + + $result = $this->compositeHelper->filterAndSortDeclaredComponents($contexts); + + /** Ensure that misconfigured components were filtered out correctly */ + $this->assertCount(3, $result, 'Misconfigured components filtration does not work as expected.'); + + /** Verify that components were ordered according to the defined sort order */ + $incorrectSortingMessage = "Registered components were sorted incorrectly"; + $this->assertSame($thirdComponent, $result[0]['type'], $incorrectSortingMessage); + $this->assertSame($firstComponent, $result[1]['type'], $incorrectSortingMessage); + $this->assertSame($secondComponent, $result[2]['type'], $incorrectSortingMessage); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0ade1982c2eb9d80d6a72a88bf076bb293b193da --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php @@ -0,0 +1,137 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\Search\Adapter\Mysql; + + +use Magento\Framework\App\Resource\Config; +use Magento\Framework\App\Resource; +use Magento\TestFramework\Helper\ObjectManager; + +class AdapterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ResponseFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseFactory; + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $connectionAdapter; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Mapper|\PHPUnit_Framework_MockObject_MockObject + */ + private $mapper; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Adapter + */ + private $adapter; + /** + * @var ObjectManager + */ + private $objectManager; + /** + * @var \Magento\Framework\Search\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $request; + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + private $select; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + + $this->request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + ->setMethods([]) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection']) + ->disableOriginalConstructor() + ->getMock(); + $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + ->setMethods([]) + ->disableOriginalConstructor() + ->getMock(); + $this->connectionAdapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['fetchAssoc']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with(Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($this->connectionAdapter)); + + $this->mapper = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Mapper') + ->setMethods(['buildQuery']) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseFactory = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\ResponseFactory') + ->setMethods([]) + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter = $this->objectManager->getObject( + '\Magento\Framework\Search\Adapter\Mysql\Adapter', + [ + 'mapper' => $this->mapper, + 'responseFactory' => $this->responseFactory, + 'resource' => $this->resource, + ] + ); + } + + public function testQuery() + { + $selectResult = [ + 'documents' => [ + 'id' => 1, + 'sku' => 'Product' + ], + 'aggregations' => [] + ]; + + $this->connectionAdapter->expects($this->once()) + ->method('fetchAssoc') + ->will($this->returnValue($selectResult['documents'])); + $this->mapper->expects($this->once()) + ->method('buildQuery') + ->with($this->request) + ->will($this->returnValue($this->select)); + $this->responseFactory->expects($this->once()) + ->method('create') + ->with($selectResult) + ->will($this->returnArgument(0)); + $response = $this->adapter->query($this->request); + $this->assertEquals($selectResult, $response); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c8e7a7c2b4be1515756540929bb9d3495c2d099e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php @@ -0,0 +1,93 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Builder\Query; + +use Magento\Framework\DB\Select; +use Magento\Framework\Search\Request\Query\Bool; +use Magento\TestFramework\Helper\ObjectManager; + +class MatchTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $scoreBuilder; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match + */ + private $match; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->scoreBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder') + ->setMethods(['addCondition']) + ->disableOriginalConstructor() + ->getMock(); + + $this->match = $helper->getObject('Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match'); + } + + public function testBuildQuery() + { + $boost = 3.14; + + /** @var Select|\PHPUnit_Framework_MockObject_MockObject $select */ + $select = $this->getMockBuilder('Magento\Framework\DB\Select') + ->setMethods(['getMatchQuery', 'match']) + ->disableOriginalConstructor() + ->getMock(); + $select->expects($this->once())->method('getMatchQuery') + ->with($this->equalTo('some_field'), $this->equalTo('-some_value')) + ->will($this->returnValue('matchedQuery')); + $select->expects($this->once())->method('match') + ->with( + $this->equalTo('some_field'), + $this->equalTo('-some_value'), + $this->equalTo(true), + $this->equalTo(Select::FULLTEXT_MODE_BOOLEAN) + ); + + /** @var \Magento\Framework\Search\Request\Query\Match|\PHPUnit_Framework_MockObject_MockObject $query */ + $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Match') + ->setMethods(['getMatches']) + ->disableOriginalConstructor() + ->getMock(); + $query->expects($this->once())->method('getMatches')->will( + $this->returnValue([['field' => 'some_field', 'value' => 'some_value', 'boost' => $boost]]) + ); + + $this->scoreBuilder->expects($this->once())->method('addCondition') + ->with( + $this->equalTo('matchedQuery'), + $this->equalTo($boost) + ); + + $result = $this->match->build($this->scoreBuilder, $select, $query, Bool::QUERY_CONDITION_NOT); + + $this->assertEquals($select, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/DimensionsTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/DimensionsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..797a53395a36f1ea68e9e1d1e68d085b50d71990 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/DimensionsTest.php @@ -0,0 +1,154 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\Framework\Search\Adapter\Mysql\Dimensions as DimensionsBuilder; +use Magento\TestFramework\Helper\ObjectManager; + +class DimensionsTest extends \PHPUnit_Framework_TestCase +{ + + /** @var \Magento\TestFramework\Helper\ObjectManager */ + private $objectManager; + /** @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $adapter; + /** @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject */ + private $resource; + /** @var \Magento\Framework\App\ScopeInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $scope; + /** @var \Magento\Framework\App\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $scopeResolver; + /** @var \Magento\Framework\Search\Request\Dimension|\PHPUnit_Framework_MockObject_MockObject */ + private $dimension; + /** @var DimensionsBuilder */ + private $builder; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + + $this->adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->disableOriginalConstructor() + ->setMethods(['quote', 'quoteIdentifier']) + ->getMockForAbstractClass(); + + $escapeValueCallback = function ($value) { + return '`' . $value . '`'; + }; + + $this->adapter->expects($this->once()) + ->method('quote') + ->will($this->returnCallback($escapeValueCallback)); + $this->adapter->expects($this->once()) + ->method('quoteIdentifier') + ->will($this->returnCallback($escapeValueCallback)); + + $this->resource = $this->getMockBuilder('\Magento\Framework\App\Resource') + ->disableOriginalConstructor() + ->setMethods(['getConnection']) + ->getMock(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($this->adapter)); + + $this->scope = $this->getMockBuilder('\Magento\Framework\App\ScopeInterface') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMockForAbstractClass(); + + $this->scopeResolver = $this->getMockBuilder('\Magento\Framework\App\ScopeResolverInterface') + ->disableOriginalConstructor() + ->setMethods(['getScope']) + ->getMockForAbstractClass(); + + $this->dimension = $this->getMockBuilder('\Magento\Framework\Search\Request\Dimension') + ->disableOriginalConstructor() + ->setMethods(['getName', 'getValue']) + ->getMock(); + + $this->builder = $this->objectManager->getObject( + '\Magento\Framework\Search\Adapter\Mysql\Dimensions', + [ + 'resource' => $this->resource, + 'scopeResolver' => $this->scopeResolver + ] + ); + } + + public function testBuildDimensionWithCustomScope() + { + $name = 'customScopeName'; + $value = 'customScopeId'; + + $this->dimension->expects($this->once()) + ->method('getName') + ->will($this->returnValue($name)); + $this->dimension->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($value)); + + $this->scope->expects($this->never()) + ->method('getId'); + + $this->scopeResolver->expects($this->never()) + ->method('getScope'); + + $query = $this->builder->build($this->dimension); + $this->assertEquals( + sprintf('`%s` = `%s`', $name, $value), + $query + ); + } + + public function testBuildDimensionWithDefaultScope() + { + $name = 'scope'; + $value = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT; + $scopeId = -123456; + + $this->dimension->expects($this->once()) + ->method('getName') + ->will($this->returnValue($name)); + $this->dimension->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($value)); + + $this->scope->expects($this->once()) + ->method('getId') + ->will($this->returnValue($scopeId)); + + $this->scopeResolver->expects($this->once()) + ->method('getScope') + ->with($value) + ->will($this->returnValue($this->scope)); + + $query = $this->builder->build($this->dimension); + $this->assertEquals( + sprintf('`%s` = `%s`', \Magento\Framework\Search\Adapter\Mysql\Dimensions::STORE_FIELD_NAME, $scopeId), + $query + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/RangeTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/RangeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..644ed1ee919edabfa6e3c0ec3df6c6045a3a9b29 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/RangeTest.php @@ -0,0 +1,157 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\Search\Adapter\Mysql\Filter\Builder; + +use Magento\TestFramework\Helper\ObjectManager; + +class RangeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $adapter; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + /** + * @var \Magento\Framework\Search\Request\Filter\Term|\PHPUnit_Framework_MockObject_MockObject + */ + private $requestFilter; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range + */ + private $filter; + + /** + * Set Up + */ + protected function setUp() + { + $objectManager = new ObjectManager($this); + $this->requestFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Range') + ->setMethods(['getField', 'getFrom', 'getTo']) + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['quote']) + ->getMockForAbstractClass(); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection']) + ->disableOriginalConstructor() + ->getMock(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($this->adapter)); + + $this->filter = $objectManager->getObject( + 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range', + [ + 'resource' => $this->resource, + ] + ); + } + + /** + * @param string $field + * @param string $from + * @param string $to + * @param string $expectedResult + * @dataProvider buildQueryDataProvider + */ + public function testBuildQuery($field, $from, $to, $expectedResult) + { + $this->requestFilter->expects($this->once()) + ->method('getField') + ->will($this->returnValue($field)); + $this->requestFilter->expects($this->once()) + ->method('getFrom') + ->will($this->returnValue($from)); + $this->requestFilter->expects($this->once()) + ->method('getTo') + ->will($this->returnValue($to)); + $this->adapter->expects($this->any()) + ->method('quote') + ->will( + $this->returnCallback( + function ($value) { + return '\'' . $value . '\''; + } + ) + ); + + $actualResult = $this->filter->buildFilter($this->requestFilter); + $this->assertEquals($expectedResult, $actualResult); + } + + /** + * Data provider for BuildQuery + * @return array + */ + public function buildQueryDataProvider() + { + return [ + 'rangeWithStrings' => [ + 'field' => 'testField', + 'from' => '0', + 'to' => '10', + 'expectedResult' => 'testField >= \'0\' AND testField < \'10\'', + ], + 'rangeWithIntegers' => [ + 'field' => 'testField', + 'from' => 50, + 'to' => 50, + 'expectedResult' => 'testField >= \'50\' AND testField < \'50\'', + ], + 'rangeWithFloats' => [ + 'field' => 'testField', + 'from' => 50.5, + 'to' => 55.5, + 'expectedResult' => 'testField >= \'50.5\' AND testField < \'55.5\'', + ], + 'rangeWithoutFromValue' => [ + 'field' => 'testField', + 'from' => null, + 'to' => 50, + 'expectedResult' => 'testField < \'50\'', + ], + 'rangeWithoutToValue' => [ + 'field' => 'testField', + 'from' => 50, + 'to' => null, + 'expectedResult' => 'testField >= \'50\'', + ], + 'rangeWithEmptyValues' => [ + 'field' => 'testField', + 'from' => null, + 'to' => null, + 'expectedResult' => '', + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/TermTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/TermTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b51d66be79823a43e359a685e3dd1a0aeb82c9b1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/TermTest.php @@ -0,0 +1,121 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\Search\Adapter\Mysql\Filter\Builder; + +use Magento\TestFramework\Helper\ObjectManager; + +class TermTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $adapter; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + /** + * @var \Magento\Framework\Search\Request\Filter\Term|\PHPUnit_Framework_MockObject_MockObject + */ + private $requestFilter; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term + */ + private $filter; + + /** + * Set up + */ + protected function setUp() + { + $objectManager = new ObjectManager($this); + $this->requestFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + ->setMethods(['getField', 'getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['quote']) + ->getMockForAbstractClass(); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection']) + ->disableOriginalConstructor() + ->getMock(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($this->adapter)); + + $this->filter = $objectManager->getObject( + 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term', + [ + 'resource' => $this->resource, + ] + ); + } + + /** + * @param string $field + * @param string $value + * @param string $expectedResult + * @dataProvider buildQueryDataProvider + */ + public function testBuildQuery($field, $value, $expectedResult) + { + $this->requestFilter->expects($this->once()) + ->method('getField') + ->will($this->returnValue($field)); + $this->requestFilter->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($value)); + $this->adapter->expects($this->once()) + ->method('quote') + ->will($this->returnArgument(0)); + + $actualResult = $this->filter->buildFilter($this->requestFilter); + $this->assertEquals($expectedResult, $actualResult); + } + + /** + * Data provider for BuildQuery + * @return array + */ + public function buildQueryDataProvider() + { + return [ + [ + 'field' => 'testField', + 'value' => 'testValue', + 'expectedResult' => 'testField = testValue', + ], + [ + 'field' => 'testField2', + 'value' => 'testValue2', + 'expectedResult' => 'testField2 = testValue2', + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8c1713f8d4a42baf2af22b6a9fc0fc8abe424b6e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderTest.php @@ -0,0 +1,340 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\Search\Adapter\Mysql\Filter; + +use Magento\TestFramework\Helper\ObjectManager; + +class BuilderTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $adapter; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Filter\Builder + */ + private $builder; + + /** + * Set up + */ + protected function setUp() + { + $objectManager = new ObjectManager($this); + + $this->adapter = $adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['quote']) + ->getMockForAbstractClass(); + $this->adapter->expects($this->any()) + ->method('quote') + ->will($this->returnArgument(0)); + + $rangeBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range') + ->setMethods(['buildFilter']) + ->disableOriginalConstructor() + ->getMock(); + $rangeBuilder->expects($this->any()) + ->method('buildFilter') + ->will( + $this->returnCallback( + function (\Magento\Framework\Search\Request\FilterInterface $filter) use ($adapter) { + /** + * @var \Magento\Framework\Search\Request\Filter\Range $filter + * @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter + */ + return sprintf( + '%s >= %s AND %s < %s', + $filter->getField(), + $adapter->quote($filter->getFrom()), + $filter->getField(), + $adapter->quote($filter->getTo()) + ); + } + ) + ); + + $termBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term') + ->setMethods(['buildFilter']) + ->disableOriginalConstructor() + ->getMock(); + $termBuilder->expects($this->any()) + ->method('buildFilter') + ->will( + $this->returnCallback( + function (\Magento\Framework\Search\Request\FilterInterface $filter) use ($adapter) { + /** + * @var \Magento\Framework\Search\Request\Filter\Term $filter + * @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter + */ + return sprintf( + '%s = %s', + $filter->getField(), + $adapter->quote($filter->getValue()) + ); + } + ) + ); + + $this->builder = $objectManager->getObject( + 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder', + [ + 'range' => $rangeBuilder, + 'term' => $termBuilder, + ] + ); + } + + /** + * @param \Magento\Framework\Search\Request\FilterInterface|\PHPUnit_Framework_MockObject_MockObject $filter + * @param string $expectedResult + * @dataProvider buildFilterDataProvider + */ + public function testBuildFilter($filter, $expectedResult) + { + $actualResult = $this->builder->build($filter); + $this->assertEquals($expectedResult, $actualResult); + } + + public function buildFilterDataProvider() + { + return array_merge( + $this->buildTermFilterDataProvider(), + $this->buildRangeFilterDataProvider(), + $this->buildBoolFilterDataProvider() + ); + } + + /** + * Data provider for BuildFilter + * @return array + */ + public function buildRangeFilterDataProvider() + { + return [ + 'rangeFilter' => [ + 'filter' => $this->createRangeFilter('range1', 0, 10), + 'expectedResult' => '(range1 >= 0 AND range1 < 10)', + ] + ]; + } + + public function buildTermFilterDataProvider() + { + return [ + 'termFilter' => [ + 'filter' => $this->createTermFilter('term1', 123), + 'expectedResult' => '(term1 = 123)', + ], + ]; + } + + public function buildBoolFilterDataProvider() + { + return [ + 'boolFilterWithMust' => [ + 'filter' => $this->createBoolFilter( + [ //must + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ], + [], //should + [] // mustNot + ), + 'expectedResult' => '((term1 = 1) AND (range1 >= 0 AND range1 < 10))', + ], + 'boolFilterWithShould' => [ + 'filter' => $this->createBoolFilter( + [], //must + [ //should + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ], + [] // mustNot + ), + 'expectedResult' => '(((term1 = 1) OR (range1 >= 0 AND range1 < 10)))', + ], + 'boolFilterWithMustNot' => [ + 'filter' => $this->createBoolFilter( + [], //must + [], //should + [ // mustNot + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ] + ), + 'expectedResult' => '(!((term1 = 1) AND (range1 >= 0 AND range1 < 10)))', + ], + 'boolFilterWithAllFields' => [ + 'filter' => $this->createBoolFilter( + [ //must + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ], + [ //should + $this->createTermFilter('term2', 1), + $this->createRangeFilter('range2', 0, 10), + ], + [ // mustNot + $this->createTermFilter('term3', 1), + $this->createRangeFilter('range3', 0, 10), + ] + ), + 'expectedResult' => '((term1 = 1) AND (range1 >= 0 AND range1 < 10)' + . ' AND ((term2 = 1) OR (range2 >= 0 AND range2 < 10))' + . ' AND !((term3 = 1) AND (range3 >= 0 AND range3 < 10)))', + ], + 'boolFilterInBoolFilter' => [ + 'filter' => $this->createBoolFilter( + [ //must + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ], + [ //should + $this->createTermFilter('term2', 1), + $this->createRangeFilter('range2', 0, 10), + ], + [ // mustNot + $this->createTermFilter('term3', 1), + $this->createRangeFilter('range3', 0, 10), + $this->createBoolFilter( + [ //must + $this->createTermFilter('term4', 1), + $this->createRangeFilter('range4', 0, 10), + ], + [ //should + $this->createTermFilter('term5', 1), + $this->createRangeFilter('range5', 0, 10), + ], + [ // mustNot + $this->createTermFilter('term6', 1), + $this->createRangeFilter('range6', 0, 10), + ] + ), + ] + ), + 'expectedResult' => '((term1 = 1) AND (range1 >= 0 AND range1 < 10)' + . ' AND ((term2 = 1) OR (range2 >= 0 AND range2 < 10))' + . ' AND !((term3 = 1) AND (range3 >= 0 AND range3 < 10)' + . ' AND ((term4 = 1) AND (range4 >= 0 AND range4 < 10)' + . ' AND ((term5 = 1) OR (range5 >= 0 AND range5 < 10))' + . ' AND !((term6 = 1) AND (range6 >= 0 AND range6 < 10)))' + . '))', + + ], + 'boolEmpty' => [ + 'filter' => $this->createBoolFilter([], [], []), + 'expectedResult' => '', + ] + ]; + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Unknown filter type 'unknownType' + */ + public function testUnknownFilterType() + { + /** @var \Magento\Framework\Search\Request\FilterInterface|\PHPUnit_Framework_MockObject_MockObject $filter */ + $filter = $this->getMockBuilder('Magento\Framework\Search\Request\FilterInterface') + ->setMethods(['getType']) + ->getMockForAbstractClass(); + $filter->expects($this->exactly(2)) + ->method('getType') + ->will($this->returnValue('unknownType')); + $this->builder->build($filter); + } + + /** + * @param $field + * @param $from + * @param $to + * @return \Magento\Framework\Search\Request\Filter\Bool|\PHPUnit_Framework_MockObject_MockObject + */ + private function createRangeFilter($field, $from, $to) + { + $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Range') + ->setMethods(['getField', 'getFrom', 'getTo']) + ->disableOriginalConstructor() + ->getMock(); + + $filter->expects($this->exactly(2)) + ->method('getField') + ->will($this->returnValue($field)); + $filter->expects($this->once()) + ->method('getFrom') + ->will($this->returnValue($from)); + $filter->expects($this->once()) + ->method('getTo') + ->will($this->returnValue($to)); + return $filter; + } + + /** + * @param $field + * @param $value + * @return \Magento\Framework\Search\Request\Filter\Bool|\PHPUnit_Framework_MockObject_MockObject + */ + private function createTermFilter($field, $value) + { + $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + ->setMethods(['getField', 'getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $filter->expects($this->exactly(1)) + ->method('getField') + ->will($this->returnValue($field)); + $filter->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($value)); + return $filter; + } + + /** + * @param array $must + * @param array $should + * @param array $mustNot + * @return \Magento\Framework\Search\Request\Filter\Bool|\PHPUnit_Framework_MockObject_MockObject + */ + private function createBoolFilter(array $must, array $should, array $mustNot) + { + $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Bool') + ->setMethods(['getMust', 'getShould', 'getMustNot']) + ->disableOriginalConstructor() + ->getMock(); + + $filter->expects($this->once()) + ->method('getMust') + ->will($this->returnValue($must)); + $filter->expects($this->once()) + ->method('getShould') + ->will($this->returnValue($should)); + $filter->expects($this->once()) + ->method('getMustNot') + ->will($this->returnValue($mustNot)); + return $filter; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/MapperTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/MapperTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fad795c9f70b647a442817b4c7c745b0ecd2a813 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/MapperTest.php @@ -0,0 +1,354 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\Framework\App\Resource; +use Magento\Framework\App\Resource\Config; +use Magento\Framework\Search\Request\Query\Filter; +use Magento\Framework\Search\Request\QueryInterface; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class MapperTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Dimensions|\PHPUnit_Framework_MockObject_MockObject + */ + private $dimensionsBuilder; + /** + * @var \Magento\Framework\Search\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $request; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + private $select; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $scoreBuilder; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilderFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $scoreBuilderFactory; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match|\PHPUnit_Framework_MockObject_MockObject + */ + private $matchQueryBuilder; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Filter\Builder|\PHPUnit_Framework_MockObject_MockObject + */ + private $filterBuilder; + + /** + * @var \Magento\Framework\Search\Request\FilterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $filter; + + /** + * @var Mapper + */ + private $mapper; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + ->setMethods([]) + ->disableOriginalConstructor() + ->getMock(); + + $connectionAdapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['select']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $connectionAdapter->expects($this->any())->method('select')->will($this->returnValue($this->select)); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection']) + ->disableOriginalConstructor() + ->getMock(); + $this->resource->expects($this->any())->method('getConnection') + ->with(Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($connectionAdapter)); + + $this->scoreBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder') + ->setMethods(['clear']) + ->disableOriginalConstructor() + ->getMock(); + $this->scoreBuilderFactory = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilderFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->scoreBuilderFactory->expects($this->any())->method('create') + ->will($this->returnValue($this->scoreBuilder)); + + $this->dimensionsBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Dimensions') + ->setMethods(['build']) + ->disableOriginalConstructor() + ->getMock(); + + $this->request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + ->setMethods(['getQuery', 'getDimensions']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->matchQueryBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match') + ->setMethods(['build']) + ->disableOriginalConstructor() + ->getMock(); + + $this->filter = $this->getMockBuilder('Magento\Framework\Search\Request\FilterInterface') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->filterBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\Filter\Builder') + ->setMethods(['build']) + ->disableOriginalConstructor() + ->getMock(); + + $this->mapper = $helper->getObject( + 'Magento\Framework\Search\Adapter\Mysql\Mapper', + [ + 'resource' => $this->resource, + 'scoreBuilderFactory' => $this->scoreBuilderFactory, + 'matchQueryBuilder' => $this->matchQueryBuilder, + 'filterBuilder' => $this->filterBuilder, + 'dimensionsBuilder' => $this->dimensionsBuilder, + ] + ); + } + + public function testBuildMatchQuery() + { + $query = $this->createMatchQuery(); + + $this->request->expects($this->once()) + ->method('getDimensions') + ->will( + $this->returnValue([$this->createDimension()]) + ); + $this->dimensionsBuilder->expects($this->once()) + ->method('build') + ->will($this->returnValue('a = b')); + + $this->matchQueryBuilder->expects($this->once())->method('build') + ->with( + $this->equalTo($this->scoreBuilder), + $this->equalTo($this->select), + $this->equalTo($query), + $this->equalTo(Mapper::BOOL_MUST) + ) + ->will($this->returnValue($this->select)); + + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->select->expects($this->once())->method('from')->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('columns')->will($this->returnValue($this->select)); + + $response = $this->mapper->buildQuery($this->request); + + $this->assertEquals($this->select, $response); + } + + public function testBuildFilterQuery() + { + $this->request->expects($this->once()) + ->method('getDimensions') + ->will( + $this->returnValue([$this->createDimension()]) + ); + $this->dimensionsBuilder->expects($this->once()) + ->method('build') + ->will($this->returnValue('a = b')); + + $query = $this->createFilterQuery(); + $query->expects($this->once())->method('getReferenceType')->will($this->returnValue(Filter::REFERENCE_FILTER)); + $query->expects($this->once())->method('getReference')->will($this->returnValue($this->filter)); + + $this->select->expects($this->once())->method('from')->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('columns')->will($this->returnValue($this->select)); + + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->filterBuilder->expects($this->once())->method('build')->will($this->returnValue('(1)')); + + $response = $this->mapper->buildQuery($this->request); + + $this->assertEquals($this->select, $response); + } + + public function testBuildBoolQuery() + { + $query = $this->createBoolQuery(); + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->matchQueryBuilder->expects($this->exactly(4))->method('build') + ->will($this->returnValue($this->select)); + + $matchQuery = $this->createMatchQuery(); + $filterMatchQuery = $this->createFilterQuery(); + $filterMatchQuery->expects($this->once())->method('getReferenceType') + ->will($this->returnValue(Filter::REFERENCE_QUERY)); + $filterMatchQuery->expects($this->once())->method('getReference')->will($this->returnValue($matchQuery)); + + $filterQuery = $this->createFilterQuery(); + $filterQuery->expects($this->once())->method('getReferenceType') + ->will($this->returnValue(Filter::REFERENCE_FILTER)); + $filterQuery->expects($this->once())->method('getReference')->will($this->returnValue($this->filter)); + + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->filterBuilder->expects($this->once())->method('build')->will($this->returnValue('(1)')); + + $this->select->expects($this->once())->method('from')->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('columns')->will($this->returnValue($this->select)); + + $query->expects($this->once()) + ->method('getMust') + ->will( + $this->returnValue( + [ + $this->createMatchQuery(), + $this->createFilterQuery(), + ] + ) + ); + + $query->expects($this->once()) + ->method('getShould') + ->will( + $this->returnValue( + [ + $this->createMatchQuery(), + $filterMatchQuery, + ] + ) + ); + + $query->expects($this->once()) + ->method('getMustNot') + ->will( + $this->returnValue( + [ + $this->createMatchQuery(), + $filterQuery, + ] + ) + ); + + $response = $this->mapper->buildQuery($this->request); + + $this->assertEquals($this->select, $response); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Unknown query type 'unknownQuery' + */ + public function testGetUnknownQueryType() + { + $query = $this->getMockBuilder('Magento\Framework\Search\Request\QueryInterface') + ->setMethods(['getType']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $query->expects($this->exactly(2)) + ->method('getType') + ->will($this->returnValue('unknownQuery')); + + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->mapper->buildQuery($this->request); + } + + private function createMatchQuery() + { + $this->request->expects($this->once()) + ->method('getDimensions') + ->will( + $this->returnValue([$this->createDimension()]) + ); + $this->dimensionsBuilder->expects($this->once()) + ->method('build') + ->will($this->returnValue('a = b')); + + $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Match') + ->setMethods(['getType']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $query->expects($this->once())->method('getType') + ->will($this->returnValue(QueryInterface::TYPE_MATCH)); + return $query; + } + + /** + * @return \Magento\Framework\Search\Request\Dimension|\PHPUnit_Framework_MockObject_MockObject + */ + private function createDimension() + { + return $this->getMockBuilder('\Magento\Framework\Search\Request\Dimension') + ->disableOriginalConstructor() + ->getMock(); + } + + private function createFilterQuery() + { + $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Filter') + ->setMethods(['getType', 'getReferenceType', 'getReference']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $query->expects($this->exactly(1)) + ->method('getType') + ->will($this->returnValue(QueryInterface::TYPE_FILTER)); + return $query; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + private function createBoolQuery() + { + $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Bool') + ->setMethods(['getMust', 'getShould', 'getMustNot', 'getType']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $query->expects($this->exactly(1)) + ->method('getType') + ->will($this->returnValue(QueryInterface::TYPE_BOOL)); + return $query; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ResponseFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ResponseFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..272bc41b340702e91acf7e06e8b8bf4d4c408986 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ResponseFactoryTest.php @@ -0,0 +1,105 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\TestFramework\Helper\ObjectManager; + +class ResponseFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Adapter\Mysql\ResponseFactory + */ + private $factory; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\DocumentFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $documentFactory; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + private $objectManager; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->documentFactory = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\DocumentFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManager = $this->getMockBuilder('\Magento\Framework\ObjectManager') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->factory = $helper->getObject( + 'Magento\Framework\Search\Adapter\Mysql\ResponseFactory', + ['documentFactory' => $this->documentFactory, 'objectManager' => $this->objectManager] + ); + } + + public function testCreate() + { + $rawResponse = [ + 'documents' => [ + ['title' => 'oneTitle', 'description' => 'oneDescription'], + ['title' => 'twoTitle', 'description' => 'twoDescription'] + ], + 'aggregations' => [] + ]; + $exceptedResponse = [ + 'documents' => [ + [ + ['name' => 'title', 'value' => 'oneTitle'], + ['name' => 'description', 'value' => 'oneDescription'], + ], + [ + ['name' => 'title', 'value' => 'twoTitle'], + ['name' => 'description', 'value' => 'twoDescription'], + ] + ], + 'aggregations' => [] + ]; + + $this->documentFactory->expects($this->at(0))->method('create') + ->with($this->equalTo($exceptedResponse['documents'][0])) + ->will($this->returnValue('document1')); + $this->documentFactory->expects($this->at(1))->method('create') + ->with($exceptedResponse['documents'][1]) + ->will($this->returnValue('document2')); + + $this->objectManager->expects($this->once())->method('create') + ->with( + $this->equalTo('\Magento\Framework\Search\QueryResponse'), + $this->equalTo(['documents' => ['document1', 'document2'], 'aggregations' => null]) + ) + ->will($this->returnValue('QueryResponseObject')); + + $result = $this->factory->create($rawResponse); + $this->assertEquals('QueryResponseObject', $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..73e066efbbd1f1414cee345493988b0cb5d97669 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderTest.php @@ -0,0 +1,68 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\TestFramework\Helper\ObjectManager; + +class ScoreBuilderTest extends \PHPUnit_Framework_TestCase +{ + public function testBuild() + { + /** @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder $builder */ + $builder = (new ObjectManager($this))->getObject('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder'); + + $builder->startQuery(); // start one query + + $builder->addCondition('someCondition1', 1.1); + + $builder->startQuery(); // start two query + + $builder->addCondition('someCondition2', 1.2); + $builder->addCondition('someCondition3', 1.3); + + $builder->startQuery(); // start three query + + $builder->addCondition('someCondition4', 1.4); + $builder->addCondition('someCondition5', 1.5); + + $builder->endQuery(10.1); // end three query + + $builder->startQuery(); // start four query + + $builder->addCondition('someCondition6', 1.6); + $builder->addCondition('someCondition7', 1.7); + + $builder->endQuery(10.2); // end four query + $builder->endQuery(10.3); // start two query + $builder->endQuery(10.4); // start one query + + $result = $builder->build(); + + $expected = '((someCondition1 * 1.1 + (someCondition2 * 1.2 + someCondition3 * 1.3 + ' . + '(someCondition4 * 1.4 + someCondition5 * 1.5) * 10.1 + (someCondition6 * 1.6 + ' . + 'someCondition7 * 1.7) * 10.2) * 10.3) * 10.4) AS global_score'; + + $this->assertEquals($expected, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php index fcedf7e9e195bb26383287685c767d1b9e67d746..ae4829bb53b2d65dd6802b7435fbc10f1f8ea0aa 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php @@ -43,7 +43,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase ->getMock(); $field->expects($this->any())->method('getName')->will($this->returnValue("$count")); - $field->expects($this->any())->method('getValues')->will($this->returnValue([$count])); + $field->expects($this->any())->method('getValue')->will($this->returnValue($count)); $documentFields[] = $field; } @@ -61,7 +61,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase $count = 0; foreach ($this->document as $field) { $this->assertEquals($field->getName(), "$count"); - $this->assertEquals($field->getValues(), [$count]); + $this->assertEquals($field->getValue(), $count); $count++; } } @@ -77,6 +77,6 @@ class DocumentTest extends \PHPUnit_Framework_TestCase public function testGetField() { $field = $this->document->getField('3'); - $this->assertEquals($field->getValues(), [3]); + $this->assertEquals($field->getValue(), 3); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php index a6dbd0334e9f0eddf1c3380774a562f006c4ac94..f88a20bc67e58b3e6389e3968d42958058711a64 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php @@ -33,7 +33,7 @@ class QueryResponseTest extends \PHPUnit_Framework_TestCase private $documents = []; /** - * @var \Magento\Framework\Search\Aggregation[] + * @var \Magento\Framework\Search\Aggregation */ private $aggregations = []; @@ -55,12 +55,9 @@ class QueryResponseTest extends \PHPUnit_Framework_TestCase $this->documents[] = $document; } - for ($count = 0; $count < 3; $count++) { - $aggregation = $this->getMockBuilder('Magento\Framework\Search\Aggregation') - ->disableOriginalConstructor() - ->getMock(); - $this->aggregations[] = $aggregation; - } + $this->aggregations = $this->getMockBuilder('Magento\Framework\Search\Aggregation') + ->disableOriginalConstructor() + ->getMock(); $this->queryResponse = $helper->getObject( 'Magento\Framework\Search\QueryResponse', @@ -75,8 +72,8 @@ class QueryResponseTest extends \PHPUnit_Framework_TestCase { $count = 0; foreach ($this->queryResponse as $document) { - $this->assertEquals($document->getId(), $count); - $count++; + $this->assertEquals($document->getId(), $count); + $count++; } } @@ -88,8 +85,6 @@ class QueryResponseTest extends \PHPUnit_Framework_TestCase public function testGetAggregations() { $aggregations = $this->queryResponse->getAggregations(); - foreach ($aggregations as $aggregation) { - $this->assertInstanceOf('Magento\Framework\Search\Aggregation', $aggregation); - } + $this->assertInstanceOf('Magento\Framework\Search\Aggregation', $aggregations); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php index 651ec06f746169cc9eb2d9c7adb46907f1fd454e..3b5b018bbb4f925b793e348874de9c959efef539 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php @@ -72,12 +72,12 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase 'queries' => ':str', 'filters' => 'f', 'query' => 'q', - 'aggregation' => 'a', + 'aggregations' => 'a', 'index' => 'i', 'from' => '1', 'size' => '15', - 'demensions' => [ - 'name' => ['name' =>'', 'value' => ''] + 'dimensions' => [ + 'name' => ['name' => '', 'value' => ''] ] ]; $mappedQuery = $configData['query'] . 'Mapped'; @@ -103,7 +103,7 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase 'objectManager' => $this->objectManager, 'queries' => $bindValues[':str'], 'rootQueryName' => $configData['query'], - 'aggregation' => $configData['aggregation'], + 'aggregations' => $configData['aggregations'], 'filters' => $configData['filters'] ] ) @@ -137,7 +137,7 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase 'from' => $configData['from'], 'size' => $configData['size'], 'query' => $mappedQuery, - 'demensions' => [ + 'dimensions' => [ 'name' => $dimension ], 'buckets' => [], diff --git a/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php index 281a22b2fb13eb52207d8d75cb351da6b4a98691..ac9bdfcdd78897f54f427d4213cd4fe68f708d4c 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php @@ -49,11 +49,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase */ protected $_requestMock; - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @var \Magento\Framework\App\Filesystem */ @@ -80,15 +75,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase )->will( $this->returnValue('init.host') ); - $this->_appState = $this->getMock('\Magento\Framework\App\State', array('isInstalled'), array(), '', false, false); - $this->_appState->expects($this->atLeastOnce())->method('isInstalled')->will($this->returnValue(true)); $this->_filesystem = $this->getMock('\Magento\Framework\App\Filesystem', array(), array(), '', false, false); $this->config = new \Magento\Framework\Session\Config( $this->_configMock, $this->_stringHelperMock, $this->_requestMock, - $this->_appState, $this->_filesystem, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, @@ -332,7 +324,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->_configMock, $this->_stringHelperMock, $this->_requestMock, - $this->_appState, $this->_filesystem, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, diff --git a/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php index 0c2c5cec0c9d28b8b2ea3289c875e9c5ef42e41a..08ebd40d1ebe64652f4f714408495fa02438cd41 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php @@ -63,7 +63,7 @@ namespace Magento\Framework\Session { } return call_user_func_array('\session_regenerate_id', func_get_args()); } - + /** * Test SessionManager * diff --git a/dev/tests/unit/testsuite/Magento/Framework/Simplexml/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Framework/Simplexml/ConfigTest.php index 77a9cbd11c384f56ff5f72c2682c64395ce3e889..177d023e36d2e9b797e2645c0bec8122d8bd940a 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Simplexml/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Simplexml/ConfigTest.php @@ -59,7 +59,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->config->loadString($xml)); $this->assertXmlStringEqualsXmlString($xml, $this->config->getXmlString()); $this->setExpectedException( - 'PHPUnit_Framework_Error_Warning', + '\Exception', 'simplexml_load_string(): Entity: line 1: parser error : Start tag expected,' ); $this->assertFalse($this->config->loadString('wrong_path')); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php index 6122770c29116045707f93b7d6f6c3ab85e09f7d..475e4505682bef9fa1e30a11a75a46ab905c53f5 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php @@ -67,7 +67,13 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase { $cookieScope = $this->createCookieScope(); - $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray() + ); } /** @@ -110,7 +116,14 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase $this->assertEmpty($cookieScope->getPublicCookieMetadata()->__toArray()); $this->assertEmpty($cookieScope->getCookieMetadata()->__toArray()); - $this->assertEquals($defaultValues, $cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_PATH => 'default path', + SensitiveCookieMetadata::KEY_DOMAIN => 'default domain', + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray()); } /** @@ -134,7 +147,13 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase ] ); - $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray() + ); $this->assertEmpty($cookieScope->getCookieMetadata()->__toArray()); $this->assertEquals($defaultValues, $cookieScope->getPublicCookieMetadata()->__toArray()); } @@ -185,7 +204,15 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase $this->assertEmpty($cookieScope->getPublicCookieMetadata($this->createPublicMetadata())->__toArray()); $this->assertEmpty($cookieScope->getCookieMetadata($this->createCookieMetadata())->__toArray()); - $this->assertEquals($overrideValues, $cookieScope->getSensitiveCookieMetadata($override)->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_PATH => 'override path', + SensitiveCookieMetadata::KEY_DOMAIN => 'override domain', + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata($override)->__toArray() + ); } /** @@ -243,7 +270,10 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase $override = $this->createCookieMetadata($overrideValues); $this->assertEquals( - [], + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], $cookieScope->getSensitiveCookieMetadata($this->createSensitiveMetadata())->__toArray() ); $this->assertEquals( diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php index 9859a781e2928cc32ce702b573017c265e28c832..6ea0db484931d849e10b4a533af594ebbedc743a 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php @@ -63,7 +63,8 @@ namespace Magento\Framework\Stdlib\Cookie { class PhpCookieManagerTest extends \PHPUnit_Framework_TestCase { const COOKIE_NAME = 'cookie_name'; - const SENSITIVE_COOKIE_NAME_NO_METADATA = 'sensitive_cookie_name_no_metadata'; + const SENSITIVE_COOKIE_NAME_NO_METADATA_HTTPS = 'sensitive_cookie_name_no_metadata_https'; + const SENSITIVE_COOKIE_NAME_NO_METADATA_NOT_HTTPS = 'sensitive_cookie_name_no_metadata_not_https'; const SENSITIVE_COOKIE_NAME_NO_DOMAIN_NO_PATH = 'sensitive_cookie_name_no_domain_no_path'; const SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH = 'sensitive_cookie_name_with_domain_and_path'; const PUBLIC_COOKIE_NAME_NO_METADATA = 'public_cookie_name_no_metadata'; @@ -89,7 +90,8 @@ namespace Magento\Framework\Stdlib\Cookie { static $functionTestAssertionMapping = [ self::DELETE_COOKIE_NAME => 'self::assertDeleteCookie', self::DELETE_COOKIE_NAME_NO_METADATA => 'self::assertDeleteCookieWithNoMetadata', - self::SENSITIVE_COOKIE_NAME_NO_METADATA => 'self::assertSensitiveCookieWithNoMetaData', + self::SENSITIVE_COOKIE_NAME_NO_METADATA_HTTPS => 'self::assertSensitiveCookieWithNoMetaDataHttps', + self::SENSITIVE_COOKIE_NAME_NO_METADATA_NOT_HTTPS => 'self::assertSensitiveCookieWithNoMetaDataNotHttps', self::SENSITIVE_COOKIE_NAME_NO_DOMAIN_NO_PATH => 'self::assertSensitiveCookieNoDomainNoPath', self::SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH => 'self::assertSensitiveCookieWithDomainAndPath', self::PUBLIC_COOKIE_NAME_NO_METADATA => 'self::assertPublicCookieWithNoMetaData', @@ -113,7 +115,7 @@ namespace Magento\Framework\Stdlib\Cookie { */ protected $cookieManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Stdlib\Cookie\CookieScope + * @var \PHPUnit_Framework_MockObject_MockObject|CookieScopeInterface */ protected $scopeMock; @@ -122,13 +124,23 @@ namespace Magento\Framework\Stdlib\Cookie { */ public static $isSetCookieInvoked; + /** + * @var \Magento\Framework\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \Magento\Store\Model\Store| \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + protected function setUp() { global $mockTranslateSetCookie; $mockTranslateSetCookie = true; self::$isSetCookieInvoked = false; $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->scopeMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieScope') + $this->scopeMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieScopeInterface') ->setMethods(['getPublicCookieMetadata', 'getCookieMetadata', 'getSensitiveCookieMetadata']) ->disableOriginalConstructor() ->getMock(); @@ -136,6 +148,15 @@ namespace Magento\Framework\Stdlib\Cookie { 'Magento\Framework\Stdlib\Cookie\PhpCookieManager', ['scope' => $this->scopeMock] ); + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManagerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); } public function testGetCookie() @@ -230,12 +251,22 @@ namespace Magento\Framework\Stdlib\Cookie { } } - public function testSetSensitiveCookieNoMetadata() + /** + * @param string $cookieName + * @param bool $secure + * @dataProvider isCurrentlySecureDataProvider + */ + public function testSetSensitiveCookieNoMetadata($cookieName, $secure) { self::$isSetCookieInvoked = false; /** @var SensitiveCookieMetadata $sensitiveCookieMetadata */ $sensitiveCookieMetadata = $this->objectManager - ->getObject('Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata'); + ->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock + ] + ); $this->scopeMock->expects($this->once()) ->method('getSensitiveCookieMetadata') @@ -244,13 +275,25 @@ namespace Magento\Framework\Stdlib\Cookie { $this->returnValue($sensitiveCookieMetadata) ); + $this->storeMock->expects($this->once()) + ->method('isCurrentlySecure') + ->will($this->returnValue($secure)); + $this->cookieManager->setSensitiveCookie( - self::SENSITIVE_COOKIE_NAME_NO_METADATA, + $cookieName, 'cookie_value' ); $this->assertTrue(self::$isSetCookieInvoked); } + public function isCurrentlySecureDataProvider() + { + return [ + [self::SENSITIVE_COOKIE_NAME_NO_METADATA_HTTPS, true], + [self::SENSITIVE_COOKIE_NAME_NO_METADATA_NOT_HTTPS, false] + ]; + } + public function testSetSensitiveCookieNullDomainAndPath() { self::$isSetCookieInvoked = false; @@ -259,6 +302,7 @@ namespace Magento\Framework\Stdlib\Cookie { ->getObject( 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', [ + 'storeManager' => $this->storeManagerMock, 'metadata' => [ 'domain' => null, 'path' => null, @@ -275,6 +319,10 @@ namespace Magento\Framework\Stdlib\Cookie { $this->returnValue($sensitiveCookieMetadata) ); + $this->storeMock->expects($this->once()) + ->method('isCurrentlySecure') + ->will($this->returnValue(true)); + $this->cookieManager->setSensitiveCookie( self::SENSITIVE_COOKIE_NAME_NO_DOMAIN_NO_PATH, 'cookie_value', @@ -291,6 +339,7 @@ namespace Magento\Framework\Stdlib\Cookie { ->getObject( 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', [ + 'storeManager' => $this->storeManagerMock, 'metadata' => [ 'domain' => 'magento.url', 'path' => '/backend', @@ -304,6 +353,11 @@ namespace Magento\Framework\Stdlib\Cookie { ->will( $this->returnValue($sensitiveCookieMetadata) ); + + $this->storeMock->expects($this->once()) + ->method('isCurrentlySecure') + ->will($this->returnValue(false)); + $this->cookieManager->setSensitiveCookie( self::SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH, 'cookie_value', @@ -587,7 +641,7 @@ namespace Magento\Framework\Stdlib\Cookie { * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ - private static function assertSensitiveCookieWithNoMetaData( + private static function assertSensitiveCookieWithNoMetaDataHttps( $name, $value, $expiry, @@ -596,7 +650,7 @@ namespace Magento\Framework\Stdlib\Cookie { $secure, $httpOnly ) { - self::assertEquals(self::SENSITIVE_COOKIE_NAME_NO_METADATA, $name); + self::assertEquals(self::SENSITIVE_COOKIE_NAME_NO_METADATA_HTTPS, $name); self::assertEquals(self::COOKIE_VALUE, $value); self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); self::assertTrue($secure); @@ -605,6 +659,30 @@ namespace Magento\Framework\Stdlib\Cookie { self::assertEquals('', $path); } + /** + * Assert sensitive cookie with no meta data + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertSensitiveCookieWithNoMetaDataNotHttps( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::SENSITIVE_COOKIE_NAME_NO_METADATA_NOT_HTTPS, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); + self::assertFalse($secure); + self::assertTrue($httpOnly); + self::assertEquals('', $domain); + self::assertEquals('', $path); + } + /** * Assert sensitive cookie with no domain and path * @@ -647,7 +725,7 @@ namespace Magento\Framework\Stdlib\Cookie { self::assertEquals(self::SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH, $name); self::assertEquals(self::COOKIE_VALUE, $value); self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); - self::assertTrue($secure); + self::assertFalse($secure); self::assertTrue($httpOnly); self::assertEquals('magento.url', $domain); self::assertEquals('/backend', $path); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php index ce9c1b8e4f01d5f58bced81853fe51e5ca0531eb..4b6aafa9f8322bc8d11360b1f3b50bf90e68f700 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php @@ -31,15 +31,208 @@ use Magento\TestFramework\Helper\ObjectManager; */ class SensitiveCookieMetadataTest extends \PHPUnit_Framework_TestCase { + /** @var ObjectManager */ + private $objectManager; + /** @var SensitiveCookieMetadata */ private $sensitiveCookieMetadata; + /** @var \Magento\Framework\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject */ + private $storeManagerMock; + public function setUp() { - $objectManager = new ObjectManager($this); - $this->sensitiveCookieMetadata = $objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata' + $this->objectManager = new ObjectManager($this); + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->sensitiveCookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock, + ] + ); + } + + /** + * @param array $metadata + * @param bool $httpOnly + * @dataProvider constructorAndGetHttpOnlyTestDataProvider + */ + public function testConstructorAndGetHttpOnly($metadata, $httpOnly) + { + /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ + $object = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock, + 'metadata' => $metadata, + + ] + ); + $this->assertEquals($httpOnly, $object->getHttpOnly()); + $this->assertEquals('domain', $object->getDomain()); + $this->assertEquals('path', $object->getPath()); + } + + public function constructorAndGetHttpOnlyTestDataProvider() + { + return [ + 'with httpOnly' => [ + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + false, + ], + 'without httpOnly' => [ + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + true, + ], + ]; + } + + /** + * @param bool $isCurrentlySecure + * @param array $metadata + * @param bool $expected + * @param int $callNum + * @dataProvider getSecureDataProvider + */ + public function testGetSecure($isCurrentlySecure, $metadata, $expected, $callNum = 1) + { + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManagerMock->expects($this->exactly($callNum)) + ->method('getStore') + ->will($this->returnValue($storeMock)); + $storeMock->expects($this->exactly($callNum)) + ->method('isCurrentlySecure') + ->willReturn($isCurrentlySecure); + + /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ + $object = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock, + 'metadata' => $metadata, + ] ); + $this->assertEquals($expected, $object->getSecure()); + } + + public function getSecureDataProvider() + { + return [ + 'with secure' => [ + true, + [ + SensitiveCookieMetadata::KEY_SECURE => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + false, + 0, + ], + 'without secure' => [ + true, + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + true, + ], + 'without secure 2' => [ + false, + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + false, + ], + ]; + } + + /** + * @param bool $isCurrentlySecure + * @param array $metadata + * @param bool $expected + * @param int $callNum + * @dataProvider toArrayDataProvider + */ + public function testToArray($isCurrentlySecure, $metadata, $expected, $callNum = 1) + { + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManagerMock->expects($this->exactly($callNum)) + ->method('getStore') + ->will($this->returnValue($storeMock)); + $storeMock->expects($this->exactly($callNum)) + ->method('isCurrentlySecure') + ->willReturn($isCurrentlySecure); + + /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ + $object = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock, + 'metadata' => $metadata, + ] + ); + $this->assertEquals($expected, $object->__toArray()); + } + + public function toArrayDataProvider() + { + return [ + 'with secure' => [ + true, + [ + SensitiveCookieMetadata::KEY_SECURE => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + [ + SensitiveCookieMetadata::KEY_SECURE => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + SensitiveCookieMetadata::KEY_HTTP_ONLY => 1, + ], + 0, + ], + 'without secure' => [ + true, + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + [ + SensitiveCookieMetadata::KEY_SECURE => true, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + SensitiveCookieMetadata::KEY_HTTP_ONLY => 1, + ], + ], + 'without secure 2' => [ + false, + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + [ + SensitiveCookieMetadata::KEY_SECURE => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + SensitiveCookieMetadata::KEY_HTTP_ONLY => 1, + ], + ], + ]; } /** diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/RepositoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/RepositoryTest.php index 5557fbb9a3423bde46c65ffa6437446df007ee70..b93f8e87cd10b1405a23e0b842aaf5fcb1f62c36 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/RepositoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/RepositoryTest.php @@ -37,9 +37,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase private $design; /** - * @var \Magento\Framework\View\Design\Theme\Provider|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\View\Design\Theme\ListInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $themeProvider; + private $themeList; /** * @var \Magento\Framework\View\Asset\Source|\PHPUnit_Framework_MockObject_MockObject @@ -58,16 +58,14 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->themeProvider = $this->getMock( - '\Magento\Framework\View\Design\Theme\Provider', array(), array(), '', false - ); + $this->themeList = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Theme\ListInterface'); $this->source = $this->getMock( 'Magento\Framework\View\Asset\Source', array('getFile', 'getContent'), array(), '', false ); $this->baseUrl = $this->getMockForAbstractClass('Magento\Framework\UrlInterface'); $this->design = $this->getMockForAbstractClass('Magento\Framework\View\DesignInterface'); $this->theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); - $this->object = new Repository($this->baseUrl, $this->design, $this->themeProvider, $this->source); + $this->object = new Repository($this->baseUrl, $this->design, $this->themeList, $this->source); } /** @@ -77,9 +75,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase public function testUpdateDesignParamsWrongTheme() { $params = array('area' => 'area', 'theme' => 'nonexistent_theme'); - $this->themeProvider->expects($this->once()) - ->method('getThemeModel') - ->with('nonexistent_theme', 'area') + $this->themeList->expects($this->once()) + ->method('getThemeByFullPath') + ->with('area/nonexistent_theme') ->will($this->returnValue(null)); $this->object->updateDesignParams($params); } @@ -303,8 +301,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ->method('getThemePath') ->with($this->theme) ->will($this->returnValue('theme')); - $this->themeProvider->expects($this->any())->method('getThemeModel')->will($this->returnValue($this->theme)); - + $this->themeList->expects($this->any())->method('getThemeByFullPath')->will($this->returnValue($this->theme)); } /** diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php index 9de5079188ebed403f4029234c51f44c17548016..96d75f9928cd415c971cbe4090bc77fdb7841b88 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php @@ -87,10 +87,10 @@ class SourceTest extends \PHPUnit_Framework_TestCase ); $this->theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); - $themeProvider = $this->getMock('Magento\Framework\View\Design\Theme\Provider', array(), array(), '', false); - $themeProvider->expects($this->any()) - ->method('getThemeModel') - ->with('magento_theme', 'frontend') + $themeList = $this->getMockForAbstractClass('Magento\Framework\View\Design\Theme\ListInterface'); + $themeList->expects($this->any()) + ->method('getThemeByFullPath') + ->with('frontend/magento_theme') ->will($this->returnValue($this->theme)); $this->initFilesystem(); @@ -100,7 +100,7 @@ class SourceTest extends \PHPUnit_Framework_TestCase $this->filesystem, $this->preProcessorPool, $this->viewFileResolution, - $themeProvider + $themeList ); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/PhpTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/PhpTest.php index 5ff334888c3b7d08598474c6bf5a95f063048f9a..dead68e22fce420219ed6591b72909d6e69e4de4 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/PhpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/PhpTest.php @@ -73,11 +73,7 @@ class PhpTest extends \PHPUnit_Framework_TestCase * Test the render() function with a nonexistent filename. * * Expect an exception if the specified file does not exist. - * We should really expect a generic \Exception, but PHPUnit will fail - * with: "You must not expect the generic exception class". This has been fixed in more recent versions of - * PHPUnit, but until all build agents get updated with PHPUnit 3.7.20, the workaround is - * to specify \PHPUnit_Framework_Error_Warning - * @expectedException \PHPUnit_Framework_Error_Warning + * @expectedException \Exception * @expectedExceptionMessage include(This_is_not_a_file): failed to open stream: No such file or directory */ public function testRenderException() diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php index df56cbcaaa06d0739d4025c74faded5636f35be5..b8715e4191ad375825cb49e9a87baf4a7b00bfc6 100644 --- a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php @@ -87,7 +87,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->giftMessageManagerMock = $this->getMock('\Magento\GiftMessage\Model\GiftMessageManager', [], [], '', false); $this->helperMock = $this->getMock('\Magento\GiftMessage\Helper\Message', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAddTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAddTest.php index 92d2ca223a75583be1a70a4323d97d1d9e179462..83606c52a13f0095063a7e6ff37ca115bc9fa041 100644 --- a/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAddTest.php +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAddTest.php @@ -71,14 +71,14 @@ class MassAddTest extends \PHPUnit_Framework_TestCase ->setMethods(array('getId', '__sleep', '__wakeup'))->getMock(); $store->expects($this->exactly(2))->method('getId')->will($this->returnValue(1)); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store)); $this->controllerArguments['context']->getObjectManager() ->expects($this->at(0))->method('get')->with('Magento\GoogleShopping\Model\Flag') ->will($this->returnValue($this->flag)); $this->controllerArguments['context']->getObjectManager() - ->expects($this->at(1))->method('get')->with('Magento\Store\Model\StoreManagerInterface') + ->expects($this->at(1))->method('get')->with('Magento\Framework\StoreManagerInterface') ->will($this->returnValue($storeManager)); $this->controller = $this->objectManagerHelper->getObject( diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ConfigTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3e1d9743dd984258ff2710a14fa34406778807f6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ConfigTest.php @@ -0,0 +1,73 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\GoogleShopping\Model; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + /** + * @var \Magento\GoogleShopping\Model\Config + */ + protected $model; + + public function setUp() + { + $this->scopeConfig = $this->getMock( + 'Magento\Framework\App\Config\ScopeConfigInterface', + ['getValue', 'isSetFlag'], + [], + '', + false + ); + $this->model = (new ObjectManagerHelper($this))->getObject( + 'Magento\GoogleShopping\Model\Config', + [ + 'scopeConfig' => $this->scopeConfig, + ] + ); + } + + public function testGetAccountPassword() + { + $storeId = 1; + $configPasswordKey = 'password'; + $password = 'foopass'; + $this->scopeConfig + ->expects($this->once()) + ->method('getValue') + ->with( + 'google/googleshopping/' . $configPasswordKey, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + )->will($this->returnValue($password)); + $this->assertEquals($password, $this->model->getAccountPassword($storeId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php index abc62510be2b5ce653fd517a6f546f383320be56..a722982f41e7dac43e4030eeef150a8c776f46a4 100644 --- a/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php @@ -46,7 +46,7 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Notification\NotifierInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $notificationInterface; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerInterface; /** @var \Magento\Framework\Logger|\PHPUnit_Framework_MockObject_MockObject */ @@ -67,7 +67,7 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase $this->itemFactory = $this->getMock('Magento\GoogleShopping\Model\ItemFactory'); $this->productFactory = $this->getMock('Magento\Catalog\Model\ProductFactory'); $this->notificationInterface = $this->getMock('Magento\Framework\Notification\NotifierInterface'); - $this->storeManagerInterface = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerInterface = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->logger = $this->getMock('Magento\Framework\Logger', [], [], '', false); $this->googleShoppingHelper = $this->getMock('Magento\GoogleShopping\Helper\Data', [], [], '', false); $this->googleShoppingCategoryHelper = $this->getMock('Magento\GoogleShopping\Helper\Category'); diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php index 925c51ffed6f83c0f9d8812bb92412849240ece2..42f80ad1fea8103106c91f9d8aa6837026b47511 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php @@ -56,7 +56,7 @@ class GroupedTest extends \PHPUnit_Framework_TestCase $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $this->coreHelperMock = $this->getMock('\Magento\Core\Helper\Data', array(), array(), '', false); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', + '\Magento\Framework\StoreManagerInterface', array(), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php index b8a69ad321732619bc82e42cbfb2d3e5a2407970..460e8728ba74b7bb696e788e23cbaa1cb59a4401 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php @@ -62,7 +62,7 @@ class CatalogPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->commonPriceMock = $this->getMock( 'Magento\Catalog\Model\Product\CatalogPrice', array(), diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php index 1957cb012fab551c4dda3d7d0b428e22cf2a97c1..3de604ce7bf63ae8ad3c6b52ecdbc65f64ed3120 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php @@ -67,7 +67,7 @@ class EavAbstractTest extends \PHPUnit_Framework_TestCase protected $_resourceHelper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; diff --git a/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php index e08e7aa591c328a0b6d6e5486489a56ea83b5a75..a799d189971b068ea7d68f83bdff07a3bc46f9cb 100644 --- a/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php +++ b/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php @@ -33,7 +33,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Index\Model\IndexerFactory */ - protected $_indexFactoryMock; + protected $_indexFactory; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -43,35 +43,14 @@ class IndexerTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_responseMock; + protected $_response; protected function setUp() { - $this->_filesystem = - $this->getMock('Magento\Framework\App\Filesystem', array('getDirectoryWrite'), array(), '', false); - $directoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', array(), array(), '', false); - $directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); - $this->_filesystem->expects( - $this->once() - )->method( - 'getDirectoryWrite' - )->will( - $this->returnValue($directoryMock) - ); - $this->_indexFactoryMock = $this->getMock( - 'Magento\Index\Model\IndexerFactory', - array('create'), - array(), - '', - false - ); - $this->_responseMock = $this->getMock('Magento\Framework\App\Console\Response', array(), array(), '', false); - $this->_entryPoint = new \Magento\Index\App\Indexer( - 'reportDir', - $this->_filesystem, - $this->_indexFactoryMock, - $this->_responseMock - ); + $this->_filesystem = $this->getMock('Magento\Framework\App\Filesystem', ['getDirectoryWrite'], [], '', false); + $this->_indexFactory = $this->getMock('Magento\Index\Model\IndexerFactory', ['create'], [], '', false); + $this->_response = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); + $this->_entryPoint = new Indexer('reportDir', $this->_filesystem, $this->_indexFactory, $this->_response); } /** @@ -80,16 +59,19 @@ class IndexerTest extends \PHPUnit_Framework_TestCase */ public function testLaunch($value) { + $dir = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); + $this->_filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir)); $process = $this->getMock( 'Magento\Index\Model\Process', - array('getIndexer', 'reindexEverything', '__wakeup'), - array(), + ['getIndexer', 'reindexEverything', '__wakeup'], + [], '', false ); - $indexer = $this->getMock('Magento\Index\Model\Indexer', array('getProcessesCollection'), array(), '', false); + $indexer = $this->getMock('Magento\Index\Model\Indexer', array('getProcessesCollection'), [], '', false); $indexerInterface = $this->getMock('Magento\Index\Model\IndexerInterface'); - $this->_indexFactoryMock->expects($this->once())->method('create')->will($this->returnValue($indexer)); + $this->_indexFactory->expects($this->once())->method('create')->will($this->returnValue($indexer)); $indexer->expects($this->once())->method('getProcessesCollection')->will($this->returnValue(array($process))); $process->expects($this->any())->method('getIndexer')->will($this->returnValue($indexerInterface)); @@ -100,7 +82,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase $indexerInterface->expects($this->once())->method('isVisible')->will($this->returnValue(false)); $process->expects($this->never())->method('reindexEverything'); } - $this->assertEquals($this->_responseMock, $this->_entryPoint->launch()); + $this->assertEquals($this->_response, $this->_entryPoint->launch()); } /** @@ -108,6 +90,12 @@ class IndexerTest extends \PHPUnit_Framework_TestCase */ public function executeDataProvider() { - return array(array(true), array(false)); + return [[true], [false]]; + } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $this->assertFalse($this->_entryPoint->catchException($bootstrap, new \Exception)); } } diff --git a/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php index 37ae7a11824a900cef9b44aab64de157a9df9bec..033629a976ae49979640dd233dbe6ad879697955 100644 --- a/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php +++ b/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php @@ -73,4 +73,10 @@ class ShellTest extends \PHPUnit_Framework_TestCase { return array(array(true), array(false)); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', array(), array(), '', false); + $this->assertFalse($this->_entryPoint->catchException($bootstrap, new \Exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php index 01b557b0eddedc3ac6a0508a4431c3be5d27209f..1a6df7fa72acc1496cd2b91aa4e5a7019f7989f7 100644 --- a/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php +++ b/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php @@ -33,38 +33,32 @@ class IndexerTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\Processor */ - protected $processorMock; + protected $processor; /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Filesystem */ - protected $filesystemMock; + protected $filesystem; protected function setUp() { - $this->filesystemMock = $this->getMock( - 'Magento\Framework\Filesystem', - array('getDirectoryWrite'), - array(), - '', - false - ); - $directoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', array(), array(), '', false); - $directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); - $this->filesystemMock->expects( - $this->once() - )->method( - 'getDirectoryWrite' - )->will( - $this->returnValue($directoryMock) - ); - $this->processorMock = $this->getMock('Magento\Indexer\Model\Processor', array(), array(), '', false); - $this->entryPoint = new \Magento\Indexer\App\Indexer('reportDir', $this->filesystemMock, $this->processorMock); + $this->filesystem = $this->getMock('Magento\Framework\Filesystem', ['getDirectoryWrite'], [], '', false); + $this->processor = $this->getMock('Magento\Indexer\Model\Processor', [], [], '', false); + $this->entryPoint = new Indexer('reportDir', $this->filesystem, $this->processor); } public function testExecute() { - $this->processorMock->expects($this->once())->method('reindexAll'); + $dir = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); + $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir)); + $this->processor->expects($this->once())->method('reindexAll'); $this->assertEquals('0', $this->entryPoint->launch()); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $this->assertFalse($this->entryPoint->catchException($bootstrap, new \Exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php index f0fb2505ed590628d108a2a1c527bcaad01befb5..655bf3a6d9f6b05ac68d73ee5ea95708f9895fef 100644 --- a/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php +++ b/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php @@ -78,4 +78,10 @@ class ShellTest extends \PHPUnit_Framework_TestCase { return array(array(true), array(false)); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', array(), array(), '', false); + $this->assertFalse($this->entryPoint->catchException($bootstrap, new \Exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php b/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php deleted file mode 100644 index 937a39034c73ebe5b5b717c3ade12c8f04498db9..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\App\Action\Plugin; - -class DirTest extends \PHPUnit_Framework_TestCase -{ - /** - * Dir plugin - * - * @var \Magento\Install\App\Action\Plugin\Dir - */ - protected $plugin; - - /** - * App state mock - * - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\State - */ - protected $appStateMock; - - /** - * Var directory - * - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Filesystem\Directory\Write - */ - protected $varDirectory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $requestMock; - - protected function setUp() - { - $this->appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $filesystem = - $this->getMock('Magento\Framework\App\Filesystem', array('getDirectoryWrite'), array(), '', false); - $this->varDirectory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', - array('read', 'isDirectory', 'delete'), - array(), - '', - false - ); - $filesystem->expects( - $this->once() - )->method( - 'getDirectoryWrite' - )->with( - \Magento\Framework\App\Filesystem::VAR_DIR - )->will( - $this->returnValue($this->varDirectory) - ); - $logger = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); - $this->subjectMock = $this->getMock('Magento\Install\Controller\Index\Index', array(), array(), '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->plugin = new \Magento\Install\App\Action\Plugin\Dir($this->appStateMock, $filesystem, $logger); - } - - /** - * Test when app is installed - */ - public function testBeforeDispatchWhenAppIsInstalled() - { - $directories = array('dir1', 'dir2'); - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->varDirectory->expects($this->once())->method('read')->will($this->returnValue($directories)); - $this->varDirectory->expects( - $this->exactly(count($directories)) - )->method( - 'isDirectory' - )->will( - $this->returnValue(true) - ); - $this->varDirectory->expects($this->exactly(count($directories)))->method('delete'); - $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock); - } - - /** - * Test when app is not installed - */ - public function testBeforeDispatchWhenAppIsNotInstalled() - { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->varDirectory->expects($this->never())->method('read'); - $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php deleted file mode 100644 index 941c1c06449a03163d0afd8afd507a98ef563035..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\App\Action\Plugin; - -class InstallTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Install\App\Action\Plugin\Install - */ - protected $_plugin; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_response; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_urlMock; - - /** - * @var \Closure - */ - protected $closureMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $requestMock; - - protected function setUp() - { - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->_response = - $this->getMock('Magento\Framework\App\ResponseInterface', array('setRedirect', 'sendResponse')); - $this->_urlMock = $this->getMock('Magento\Framework\Url', array(), array(), '', false); - $this->closureMock = function () { - return 'ExpectedValue'; - }; - $this->subjectMock = $this->getMock('Magento\Framework\App\Action\Action', array(), array(), '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->_plugin = new \Magento\Install\App\Action\Plugin\Install( - $this->_appStateMock, - $this->_response, - $this->_urlMock, - $this->getMock('Magento\Framework\App\ActionFlag', array(), array(), '', false) - ); - } - - public function testAroundDispatchWhenApplicationIsNotInstalled() - { - $url = 'http://example.com'; - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_urlMock->expects($this->once())->method('getUrl')->with('install')->will($this->returnValue($url)); - $this->_response->expects($this->once())->method('setRedirect')->with($url); - $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock); - } - - public function testAroundDispatchWhenApplicationIsInstalled() - { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - - $this->assertEquals( - 'ExpectedValue', - $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php b/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php deleted file mode 100644 index 7514f8136931f1e399cb10ad9e5b481fcca96399..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php +++ /dev/null @@ -1,276 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\App; - -class ConsoleTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Install\App\Console - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Install\Model\Installer\Console - */ - protected $_installerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Filesystem\DirectoryList\Verification - */ - protected $_dirVerifierMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Install\App\Output - */ - protected $_outputMock; - - /** \PHPUnit_Framework_MockObject_MockObject|\Magento\Install\Model\Installer\ConsoleFactory */ - protected $_instFactoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configLoaderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_objectManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_responseMock; - - protected function setUp() - { - $this->_instFactoryMock = $this->getMock( - '\Magento\Install\Model\Installer\ConsoleFactory', - array('create'), - array(), - '', - false - ); - $this->_installerMock = $this->getMock('Magento\Install\Model\Installer\Console', array(), array(), '', false); - $this->_dirVerifierMock = $this->getMock( - 'Magento\Framework\App\Filesystem\DirectoryList\Verification', - array(), - array(), - '', - false - ); - $this->_outputMock = $this->getMock('Magento\Install\App\Output', array(), array(), '', false); - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->_configLoaderMock = $this->getMockBuilder( - 'Magento\Framework\App\ObjectManager\ConfigLoader' - )->disableOriginalConstructor()->getMock(); - $this->_instFactoryMock->expects( - $this->any() - )->method( - 'create' - )->will( - $this->returnValue($this->_installerMock) - ); - - $this->_configLoaderMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'install' - )->will( - $this->returnValue(array('di' => 'config')) - ); - - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); - $this->_objectManagerMock->expects($this->once())->method('configure')->with(array('di' => 'config')); - } - - protected function _createModel($params = array()) - { - $directory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Read', - array('isExist', 'getRelativePath'), - array(), - '', - false - ); - $filesystem = $this->getMock( - 'Magento\Framework\App\Filesystem', - array('getDirectoryRead', '__wakeup'), - array(), - '', - false - ); - $filesystem->expects( - $this->once() - )->method( - 'getDirectoryRead' - )->with( - \Magento\Framework\App\Filesystem::ROOT_DIR - )->will( - $this->returnValue($directory) - ); - if (isset($params['config'])) { - $directory->expects( - $this->once() - )->method( - 'getRelativePath' - )->with( - $params['config'] - )->will( - $this->returnValue($params['config']) - ); - $directory->expects( - $this->once() - )->method( - 'isExist' - )->with( - $params['config'] - )->will( - $this->returnValue(true) - ); - } - $this->_responseMock = $this->getMock('Magento\Framework\App\Console\Response', array(), array(), '', false); - return new \Magento\Install\App\Console( - $this->_instFactoryMock, - $this->_outputMock, - $this->_appStateMock, - $this->_configLoaderMock, - $this->_objectManagerMock, - $filesystem, - $this->_responseMock, - $params - ); - } - - /** - * @param string $param - * @param string $method - * @param string $testValue - * @dataProvider executeShowsRequestedDataProvider - */ - public function testLaunchShowsRequestedData($param, $method, $testValue) - { - $model = $this->_createModel(array($param => true)); - $this->_installerMock->expects($this->once())->method($method)->will($this->returnValue($testValue)); - $this->_outputMock->expects($this->once())->method('readableOutput')->with($testValue); - $this->_outputMock->expects( - $this->once() - )->method( - 'prepareArray' - )->with( - $testValue - )->will( - $this->returnArgument(0) - ); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function executeShowsRequestedDataProvider() - { - return array( - array('show_locales', 'getAvailableLocales', array('locales')), - array('show_currencies', 'getAvailableCurrencies', array('currencies')), - array('show_timezones', 'getAvailableTimezones', array('timezones')) - ); - } - - public function testLaunchShowsInstallOptions() - { - $required = array('required params'); - $optional = array('optional params'); - - $model = $this->_createModel(array('show_install_options' => true)); - $this->_installerMock->expects( - $this->once() - )->method( - 'getRequiredParams' - )->will( - $this->returnValue($required) - ); - $this->_installerMock->expects( - $this->once() - )->method( - 'getOptionalParams' - )->will( - $this->returnValue($optional) - ); - $this->_outputMock->expects($this->exactly(2))->method('alignArrayKeys'); - $this->_outputMock->expects($this->at(1))->method('alignArrayKeys')->with($required); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testInstallReportsSuccessMessage() - { - $model = $this->_createModel(array()); - $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('successfully')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testInstallReportsEncryptionKey() - { - $model = $this->_createModel(array()); - $this->_installerMock->expects($this->once())->method('install')->will($this->returnValue('enc_key')); - $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('enc_key')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testUninstallReportsSuccess() - { - $model = $this->_createModel(array('uninstall' => true)); - $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(true)); - $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('Uninstalled')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testUninstallReportsIgnoreIfApplicationIsNotInstalled() - { - $model = $this->_createModel(array('uninstall' => true)); - $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(false)); - $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('non-installed')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testExecuteReportsErrors() - { - $model = $this->_createModel(array('uninstall' => true)); - $this->_installerMock->expects($this->once())->method('hasErrors')->will($this->returnValue(true)); - $this->_installerMock->expects($this->once())->method('getErrors')->will($this->returnValue(array('error1'))); - $this->_outputMock->expects($this->once())->method('error')->with($this->stringContains('error1')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testExecuteLoadsExtraConfig() - { - $model = $this->_createModel(array('config' => realpath(__DIR__ . '/_files/config.php'))); - $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(true)); - $this->assertEquals($this->_responseMock, $model->launch()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Controller/Wizard/LocaleTest.php b/dev/tests/unit/testsuite/Magento/Install/Controller/Wizard/LocaleTest.php deleted file mode 100644 index f456fcc56f757d30dd3a59170e1863d7c81049ab..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Controller/Wizard/LocaleTest.php +++ /dev/null @@ -1,301 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Test class for \Magento\Install\Block\Wizard - */ -namespace Magento\Install\Controller\Wizard; - -/** - * Class WizardTest - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class LocaleTest extends \PHPUnit_Framework_TestCase -{ - /** - * Locale to test - */ - const LOCALE = 'xx_XX'; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $_objectManager; - - /** - * @var \Magento\Install\Block\Locale - */ - protected $_block; - - /** - * @var \Magento\Framework\App\ViewInterface - */ - protected $_viewMock; - - /** - * @var \Magento\Install\Model\Installer - */ - protected $_installerMock; - - /** - * @var \Magento\Framework\View\LayoutInterface - */ - protected $_layoutMock; - - /** - * @var \Magento\Install\Controller\Wizard - */ - protected $_controller; - - /** - * @var \Magento\Framework\App\Action\Context - */ - protected $_contextMock; - - /** - * @var \Magento\Install\Model\Wizard - */ - protected $_wizardMock; - - /** - * @var \Magento\Framework\Session\Generic - */ - protected $_sessionMock; - - /** - * @var \Magento\Framework\App\RequestInterface - */ - protected $_requestMock; - - /** - * @var \Magento\Framework\App\ResponseInterface - */ - protected $_responseMock; - - /** - * @var \Magento\Framework\App\ActionFlag - */ - protected $_actionFlagMock; - - /** - * @var \Magento\Framework\View\Element\Template\Context - */ - protected $_blockContextMock; - - /** - * Set up before test - * - * @return void - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function setUp() - { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $this->_installerMock = $this->getMock( - '\Magento\Install\Model\Installer', - array('isApplicationInstalled'), - array(), - '', - false - ); - $this->_installerMock->expects($this->any())->method('isApplicationInstalled')->will($this->returnValue(true)); - - - $this->_blockMock = $this->getMock('\Magento\Install\Block\Locale', array(), array(), '', false); - - - - $this->_layoutMock = $this->getMock( - '\Magento\Framework\View\Layout', - array('getBlock', 'initMessages', 'addBlock'), - array(), - '', - false - ); - - $this->_layoutMock->expects( - $this->any() - )->method( - 'initMessages' - )->withAnyParameters()->will( - $this->returnValue(true) - ); - $this->_layoutMock->expects( - $this->any() - )->method( - 'addBlock' - )->withAnyParameters()->will( - $this->returnValue(true) - ); - - - $this->_viewMock = $this->getMockForAbstractClass( - '\Magento\Framework\App\ViewInterface', - array(), - '', - false, - false, - true, - array('getLayout') - ); - $this->_viewMock->expects( - $this->any() - )->method( - 'getLayout' - )->withAnyParameters()->will( - $this->returnValue($this->_layoutMock) - ); - - $this->_requestMock = $this->_getClearMock('\Magento\Framework\App\RequestInterface'); - $this->_responseMock = $this->_getClearMock('\Magento\Framework\App\ResponseInterface'); - $this->_actionFlagMock = $this->_getClearMock('\Magento\Framework\App\ActionFlag'); - - $this->_contextMock = $this->getMock( - '\Magento\Framework\App\Action\Context', - array('getView', 'getRequest', 'getResponse', 'getActionFlag'), - array(), - '', - false - ); - $this->_contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->_viewMock)); - $this->_contextMock->expects( - $this->any() - )->method( - 'getRequest' - )->will( - $this->returnValue($this->_requestMock) - ); - $this->_contextMock->expects( - $this->any() - )->method( - 'getResponse' - )->will( - $this->returnValue($this->_responseMock) - ); - $this->_contextMock->expects( - $this->any() - )->method( - 'getActionFlag' - )->will( - $this->returnValue($this->_actionFlagMock) - ); - - - $this->_blockContextMock = $this->getMock( - '\Magento\Framework\View\Element\Template\Context', - array(), - array(), - '', - false - ); - - - - $this->_wizardMock = $this->getMock( - '\Magento\Install\Model\Wizard', - array('getStepByRequest'), - array(), - '', - false - ); - $this->_wizardMock->expects( - $this->any() - )->method( - 'getStepByRequest' - )->withAnyParameters()->will( - $this->returnValue(false) - ); - - $this->_sessionMock = $this->getMock( - '\Magento\Framework\Session\Generic', - array('getLocale'), - array(), - '', - false - ); - $this->_sessionMock->expects($this->any())->method('getLocale')->will($this->returnValue(self::LOCALE)); - - $this->_block = $this->_objectManager->getObject( - 'Magento\Install\Block\Locale', - array( - 'context' => $this->_blockContextMock, - 'installer' => $this->_installerMock, - 'installWizard' => $this->_wizardMock, - 'session' => $this->_sessionMock, - 'data' => array() - ) - ); - - $this->_layoutMock->expects( - $this->any() - )->method( - 'getBlock' - )->with( - 'install.locale' - )->will( - $this->returnValue($this->_block) - ); - - $this->_controller = $this->_objectManager->getObject( - 'Magento\Install\Controller\Wizard\Locale', - array( - 'context' => $this->_contextMock, - 'configScope' => $this->_getClearMock('Magento\Framework\Config\Scope'), - 'installer' => $this->_getClearMock('Magento\Install\Model\Installer'), - 'wizard' => $this->_wizardMock, - 'session' => $this->_sessionMock, - 'dbUpdater' => $this->_getClearMock('Magento\Framework\Module\UpdaterInterface'), - 'storeManager' => $this->_getClearMock('Magento\Store\Model\StoreManagerInterface'), - 'appState' => $this->_getClearMock('Magento\Framework\App\State') - ) - ); - } - - /** - * Get clear mock - * - * @param string $className - * - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function _getClearMock($className) - { - return $this->getMock($className, array(), array(), '', false); - } - - /** - * Test setting locale from session - */ - public function testExecute() - { - $this->_controller->execute(); - $this->assertEquals( - $this->_block->getLocaleCode(), - self::LOCALE, - 'Failed asserting that locale is set from session' - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConfigTest.php deleted file mode 100644 index 5142ba2a297c71a06e39470914352c25dfc5b256..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConfigTest.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Model\Installer; - -class ConfigTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected $_tmpConfigFile = 'local.xml'; - - /** - * @var \Magento\Install\Model\Installer\Config - */ - protected $_model; - - /** - * @var \Magento\Framework\App\Filesystem|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_filesystemMock; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_directoryMock; - - /** - * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_messageManager; - - protected function setUp() - { - $this->_directoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', - array(), - array(), - '', - false - ); - - $this->_filesystemMock = $this->getMock('Magento\Framework\App\Filesystem', array(), array(), '', false); - $this->_filesystemMock->expects( - $this->any() - )->method( - 'getPath' - )->with( - \Magento\Framework\App\Filesystem::CONFIG_DIR - )->will( - $this->returnValue(TESTS_TEMP_DIR) - ); - $this->_filesystemMock->expects( - $this->any() - )->method( - 'getDirectoryWrite' - )->will( - $this->returnValue($this->_directoryMock) - ); - - $this->_messageManager = $this->getMock( - '\Magento\Framework\Message\ManagerInterface', - array(), - array(), - '', - false - ); - $this->_model = new \Magento\Install\Model\Installer\Config( - $this->getMock('Magento\Install\Model\Installer', array(), array(), '', false), - $this->getMock('Magento\Framework\App\RequestInterface', array(), array(), '', false), - $this->_filesystemMock, - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), - $this->_messageManager - ); - } - - protected function tearDown() - { - $this->_model = null; - } - - public function testReplaceTmpInstallDate() - { - $datePlaceholder = \Magento\Install\Model\Installer\Config::TMP_INSTALL_DATE_VALUE; - $fixtureConfigData = "<date>{$datePlaceholder}</date>"; - $expectedConfigData = '<date>Sat, 19 Jan 2013 18:50:39 -0800</date>'; - - $this->_directoryMock->expects( - $this->once() - )->method( - 'readFile' - )->with( - $this->equalTo($this->_tmpConfigFile) - )->will( - $this->returnValue($fixtureConfigData) - ); - $this->_directoryMock->expects( - $this->once() - )->method( - 'writeFile' - )->with( - $this->equalTo($this->_tmpConfigFile), - $this->equalTo($expectedConfigData) - )->will( - $this->returnValue($fixtureConfigData) - ); - - $this->_model->replaceTmpInstallDate('Sat, 19 Jan 2013 18:50:39 -0800'); - } - - public function testReplaceTmpEncryptKey() - { - $keyPlaceholder = \Magento\Install\Model\Installer\Config::TMP_ENCRYPT_KEY_VALUE; - $fixtureConfigData = "<key>{$keyPlaceholder}</key>"; - $expectedConfigData = '<key>3c7cf2e909fd5e2268a6e1539ae3c835</key>'; - - $this->_directoryMock->expects( - $this->once() - )->method( - 'readFile' - )->with( - $this->equalTo($this->_tmpConfigFile) - )->will( - $this->returnValue($fixtureConfigData) - ); - $this->_directoryMock->expects( - $this->once() - )->method( - 'writeFile' - )->with( - $this->equalTo($this->_tmpConfigFile), - $this->equalTo($expectedConfigData) - )->will( - $this->returnValue($fixtureConfigData) - ); - - $this->_model->replaceTmpEncryptKey('3c7cf2e909fd5e2268a6e1539ae3c835'); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConsoleTest.php b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConsoleTest.php deleted file mode 100644 index fb13b45e3d5da30ab8992de578b51d1542a967a0..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConsoleTest.php +++ /dev/null @@ -1,229 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Model\Installer; - -class ConsoleTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Install\Model\Installer\Console - */ - protected $model; - - /** - * @var \Magento\Framework\App\Filesystem|\PHPUnit_Framework_MockObject_MockObject - */ - protected $filesystemMock; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write|\PHPUnit_Framework_MockObject_MockObject - */ - protected $directoryMock; - - protected $defaultRenderer; - - protected function setUp() - { - $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); - } - - /** - * {inheritdoc} - */ - protected function tearDown() - { - $this->model = null; - \Magento\Framework\Phrase::setRenderer($this->defaultRenderer); - } - - /** - * Test uninstall() - */ - public function testUninstall() - { - $this->model = $this->getModelMock(); - - $this->directoryMock->expects($this->exactly(2)) - ->method('delete')->with($this->logicalOr($this->equalTo(TESTS_TEMP_DIR), $this->equalTo('local.xml'))) - ->will($this->returnValue(true)); - - $this->assertTrue($this->model->uninstall()); - - } - - /** - * Test uninstall() when error is triggered - */ - public function testUninstallWithError() - { - $this->model = $this->getModelMock(); - - $this->directoryMock->expects($this->exactly(2)) - ->method('delete')->with($this->logicalOr($this->equalTo(TESTS_TEMP_DIR), $this->equalTo('local.xml'))) - ->will( - $this->throwException( - new \Magento\Framework\Filesystem\FilesystemException(sprintf( - 'The file "%s" cannot be deleted %s', - TESTS_TEMP_DIR, - "Warning" - )) - ) - ); - $expectedString = str_repeat(sprintf('Please delete the file manually : "%s" ' . "\n", TESTS_TEMP_DIR), 2); - - $this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->will( - $this->returnValue($this->directoryMock) - ); - $this->expectOutputString($expectedString); - $result = $this->model->uninstall(); - - $this->assertTrue($result); - - } - - /** - * @param array $items - * @param array $expectedResult - * @dataProvider checkServerDataProvider - */ - public function testCheckServer($items, $expectedResult) - { - // 1. Create mocks - /** @var \Magento\Install\Model\Installer\Data|\PHPUnit_Framework_MockObject_MockObject $installerData */ - list($this->model, $installerData) = $this->getMocks($items); - - // 2. Set expectations - for ($i = 0; $i < count($items); $i++) { - $text = $expectedResult[$i]; - $installerData->expects($this->at($i))->method('addError')->with($text); - } - - // 3. Run tested method - $this->model->checkServer(); - } - - /** - * @return array - */ - public function checkServerDataProvider() - { - $messageA = $this->getMockBuilder('SomeClass')->setMethods(['toString'])->getMock(); - $messageA->expects($this->any())->method('toString')->will($this->returnValue('textA')); - - $messageB = $this->getMockBuilder('SomeClass')->setMethods(['toString'])->getMock(); - $messageB->expects($this->any())->method('toString')->will($this->returnValue('textB')); - - return [ - [[$messageA, $messageB], ['textA', 'textB']], - [[$messageB, $messageA], ['textB', 'textA']], - ]; - } - - protected function getModelMock() - { - $dbModelName = 'Magento\Install\Model\Installer\Db\Mysql4'; - $this->directoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); - $this->directoryMock->expects( - $this->once() - )->method('read')->will($this->returnValue([TESTS_TEMP_DIR])); - - $this->directoryMock->expects( - $this->any() - )->method('isDirectory')->will($this->returnValue(true)); - - $this->filesystemMock = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); - $this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->with()->will( - $this->returnValue($this->directoryMock) - ); - /** - * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject - */ - $appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - - $dbModelMock = $this->getMock($dbModelName, [], [], '', false); - $dbModelMock->expects($this->any())->method('cleanUpDatabase')->will($this->returnValue($this)); - /** - * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject - */ - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager', [], [], '', false); - $objectManagerMock->expects($this->any())->method('get')->with($dbModelName)->will( - $this->returnValue($dbModelMock) - ); - - return new \Magento\Install\Model\Installer\Console( - $this->getMock('Magento\Install\Model\Installer', [], [], '', false), - $this->getMock('Magento\Framework\App\Resource\Config', [], [], '', false), - $this->getMock('Magento\Framework\Module\UpdaterInterface', [], [], '', false), - $this->filesystemMock, - $this->getMock('Magento\Install\Model\Installer\Data', [], [], '', false), - $appStateMock, - $this->getMock('Magento\Framework\Locale\ListsInterface', [], [], '', false), - $objectManagerMock - ); - } - - /** - * @param array $items - * @return array - */ - protected function getMocks($items) - { - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - - $installerData = $this->getMockBuilder('Magento\Install\Model\Installer\Data') - ->disableOriginalConstructor() - ->setMethods(['addError']) - ->getMock(); - - $phraseRenderer = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface') - ->disableOriginalConstructor() - ->getMock(); - - $messageCollection = $this->getMockBuilder('SomeClass') - ->setMethods(['getItems']) - ->getMock(); - - $messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') - ->disableOriginalConstructor() - ->getMock(); - - $objectManager = $this->getMockBuilder('Magento\Framework\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - - $messageCollection->expects($this->any())->method('getItems')->will($this->returnValue($items)); - $messageManager->expects($this->any())->method('getMessages')->will($this->returnValue($messageCollection)); - $objectManager->expects($this->any())->method('get')->will($this->returnValueMap([ - ['Magento\Framework\Phrase\RendererInterface', $phraseRenderer], - ['Magento\Framework\Message\ManagerInterface', $messageManager], - ])); - - $consoleInstaller = $helper->getObject('Magento\Install\Model\Installer\Console', [ - 'objectManager' => $objectManager, - 'installerData' => $installerData, - ]); - - return [$consoleInstaller, $installerData]; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php deleted file mode 100644 index 5356c81910261ec83d3eecbb363863984cc24d1c..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Model\Installer\Db; - -class Mysql4Test extends \PHPUnit_Framework_TestCase -{ - /** - * Test possible ways of declaring InnoDB engine by MySQL - * - * @dataProvider possibleEngines - * @param array $supportedEngines - * @param $expectedResult - * @return void - */ - public function testSupportEngine(array $supportedEngines, $expectedResult) - { - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); - $connectionMock->expects($this->once())->method('fetchPairs')->will($this->returnValue($supportedEngines)); - - $adapterFactory = $this->getMock( - 'Magento\Framework\Model\Resource\Type\Db\Pdo\MysqlFactory', - array('create'), - array(), - '', - false - ); - $adapterMock = $this->getMock( - 'Magento\Framework\Model\Resource\Type\Db\Pdo\Mysql', - array('getConnection'), - array(), - '', - false - ); - $adapterMock->expects($this->once())->method('getConnection')->will($this->returnValue($connectionMock)); - $adapterFactory->expects($this->once())->method('create')->will($this->returnValue($adapterMock)); - - $localConfig = - $this->getMockBuilder('\Magento\Framework\App\Arguments')->disableOriginalConstructor()->getMock(); - - $installer = new \Magento\Install\Model\Installer\Db\Mysql4($adapterFactory, $localConfig); - $this->assertEquals($expectedResult, $installer->supportEngine()); - } - - /** - * Data provider for returned engines from mysql and expectations. - * @return array - */ - public function possibleEngines() - { - return array( - array(array('InnoDB' => 'DEFAULT'), true), - array(array('InnoDB' => 'YES'), true), - array(array('wrongEngine' => '123'), false) - ); - } - - /** - * @dataProvider getRequiredExtensionsDataProvider - * - * @param $config - * @param $dbExtensions - * @param $expectedResult - */ - public function testGetRequiredExtensions($config, $dbExtensions, $expectedResult) - { - $adapterFactory = $this->getMock( - 'Magento\Framework\Model\Resource\Type\Db\Pdo\MysqlFactory', - array('create'), - array(), - '', - false - ); - $localConfig = - $this->getMockBuilder('\Magento\Framework\App\Arguments')->disableOriginalConstructor()->getMock(); - $installer = new \Magento\Install\Model\Installer\Db\Mysql4($adapterFactory, $localConfig, $dbExtensions); - $installer->setConfig($config); - $this->assertEquals($expectedResult, $installer->getRequiredExtensions()); - } - - /** - * Data provider for testGetRequiredExtensions - * - * @return array - */ - public function getRequiredExtensionsDataProvider() - { - return array( - 'wrong model' => array(array('db_model' => 'mysql66'), array('mysql' => array('pdo_test1')), array()), - 'full extensions' => array( - array('db_model' => 'mysql'), - array('mysql' => array('pdo' => 'pdo_ext1', 'pdo_ext2', 'pdo2' => 'pdo_ext3')), - array('pdo' => 'pdo_ext1', 'pdo_ext2', 'pdo2' => 'pdo_ext3') - ), - 'empty extensions' => array( - array('db_model' => 'mysql'), - array('mysql' => array(), 'mysql2' => array('pdo_ext1', 'pdo_ext2')), - array() - ) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php b/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php deleted file mode 100644 index d198583f8b17660147ae0c96dfeb035901d8144f..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Model; - -class InstallerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Install\Model\Installer - */ - protected $_model; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $_objectManager; - - /** - * Application chache model - * - * @var \Magento\Framework\App\CacheInterface - */ - protected $_cache; - - /** - * Application config model - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_config; - - /** - * @var \Magento\Framework\App\Cache\StateInterface - */ - protected $_cacheState; - - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @var \Magento\Framework\App\Cache\TypeListInterface - */ - protected $_cacheTypeList; - - /** - * @var \Magento\Install\Model\Installer\Config - */ - protected $_installerConfig; - - /** - * Set up before test - */ - public function setUp() - { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_cache = $this->getMock('\Magento\Framework\App\CacheInterface', array(), array(), '', false); - $this->_config = - $this->getMock('\Magento\Framework\App\Config\ReinitableConfigInterface', array(), array(), '', false); - $this->_cacheState = $this->getMock('\Magento\Framework\App\Cache\StateInterface', array(), array(), '', false); - $this->_cacheTypeList = - $this->getMock('\Magento\Framework\App\Cache\TypeListInterface', array(), array(), '', false); - $this->_appState = $this->getMock('\Magento\Framework\App\State', array(), array(), '', false); - $this->_installerConfig = $this->getMock( - '\Magento\Install\Model\Installer\Config', - array(), - array(), - '', - false - ); - - $this->_model = $this->_objectManager->getObject( - 'Magento\Install\Model\Installer', - array( - 'cache' => $this->_cache, - 'config' => $this->_config, - 'cacheState' => $this->_cacheState, - 'cacheTypeList' => $this->_cacheTypeList, - 'appState' => $this->_appState, - 'installerConfig' => $this->_installerConfig - ) - ); - } - - public function testFinish() - { - $cacheTypeListArray = array('one', 'two'); - - $this->_cache->expects($this->once())->method('clean'); - - $this->_config->expects($this->once())->method('reinit'); - - $this->_cacheState->expects($this->once())->method('persist'); - $this->_cacheState->expects($this->exactly(count($cacheTypeListArray)))->method('setEnabled'); - - $this->_cacheTypeList->expects( - $this->once() - )->method( - 'getTypes' - )->will( - $this->returnValue($cacheTypeListArray) - ); - - $this->_appState->expects($this->once())->method('setInstallDate')->with($this->greaterThanOrEqual(date('r'))); - - $this->_installerConfig->expects( - $this->once() - )->method( - 'replaceTmpInstallDate' - )->with( - $this->greaterThanOrEqual(date('r')) - ); - - $this->assertSame($this->_model, $this->_model->finish()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Integration/Helper/Oauth/ConsumerTest.php b/dev/tests/unit/testsuite/Magento/Integration/Helper/Oauth/ConsumerTest.php index e5c33c55864f3695ba07670660260e0ddea20b31..1fb606b462cf0b6a28bbcb0b12455d7646cae738 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Helper/Oauth/ConsumerTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Helper/Oauth/ConsumerTest.php @@ -25,7 +25,7 @@ namespace Magento\Integration\Helper\Oauth; class ConsumerTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManagerMock; /** @var \Magento\Integration\Model\Oauth\Consumer\Factory */ @@ -80,7 +80,7 @@ class ConsumerTest extends \PHPUnit_Framework_TestCase $this->_tokenFactory->expects($this->any())->method('create')->will($this->returnValue($this->_tokenMock)); $this->_storeManagerMock = $this->getMockBuilder( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->getMockForAbstractClass(); $this->_storeMock = $this->getMockBuilder( 'Magento\Store\Model\Store' diff --git a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php index 32ac2a834077644587a4bd088ebb75297f993eaa..e592aeee44bfcfbeb8e75c8f7f668266d2475f7a 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php @@ -1,6 +1,6 @@ <?php /** - * Test for \Magento\Integration\Service\V1\TokenService + * Test for \Magento\Integration\Service\V1\AdminTokenService * * Magento * @@ -31,7 +31,7 @@ use Magento\Integration\Model\Oauth\Token; class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase { - /** \Magento\Integration\Service\V1\TokenService */ + /** \Magento\Integration\Service\V1\AdminTokenService */ protected $_tokenService; /** \Magento\Integration\Model\Oauth\Token\Factory|\PHPUnit_Framework_MockObject_MockObject */ @@ -46,9 +46,10 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase /** \Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $_tokenModelCollectionFactoryMock; - /** - * @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject - */ + /** @var \Magento\Integration\Helper\Validator|\PHPUnit_Framework_MockObject_MockObject */ + protected $validatorHelperMock; + + /** @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject */ private $_tokenMock; protected function setUp() @@ -62,11 +63,6 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->_customerAccountServiceMock = $this - ->getMockBuilder('Magento\Customer\Service\V1\CustomerAccountServiceInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->_tokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') ->disableOriginalConstructor() ->setMethods(['getToken', 'loadByAdminId', 'setRevoked', 'save', '__wakeup'])->getMock(); @@ -74,8 +70,8 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase $this->_tokenModelCollectionMock = $this->getMockBuilder( 'Magento\Integration\Model\Resource\Oauth\Token\Collection' )->disableOriginalConstructor()->setMethods( - ['addFilterByAdminId', 'getSize', '__wakeup', '_beforeLoad', '_afterLoad', 'getIterator'] - )->getMock(); + ['addFilterByAdminId', 'getSize', '__wakeup', '_beforeLoad', '_afterLoad', 'getIterator'] + )->getMock(); $this->_tokenModelCollectionFactoryMock = $this->getMockBuilder( 'Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory' @@ -85,11 +81,15 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase ->method('create') ->will($this->returnValue($this->_tokenModelCollectionMock)); - $this->_tokenService = new \Magento\Integration\Service\V1\TokenService( + $this->validatorHelperMock = $this->getMockBuilder( + 'Magento\Integration\Helper\Validator' + )->disableOriginalConstructor()->getMock(); + + $this->_tokenService = new \Magento\Integration\Service\V1\AdminTokenService( $this->_tokenModelFactoryMock, $this->_userModelMock, - $this->_customerAccountServiceMock, - $this->_tokenModelCollectionFactoryMock + $this->_tokenModelCollectionFactoryMock, + $this->validatorHelperMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php similarity index 89% rename from dev/tests/unit/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php rename to dev/tests/unit/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php index 3c381a05d0ca4378675f54309cbc2f1aa675c509..47e28378949ab9d1865e124b70a310bf8a08e9f5 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php @@ -1,6 +1,6 @@ <?php /** - * Test for \Magento\Integration\Service\V1\TokenService + * Test for \Magento\Integration\Service\V1\CustomerTokenService * * Magento * @@ -29,17 +29,14 @@ namespace Magento\Integration\Service\V1; use Magento\Integration\Model\Integration; use Magento\Integration\Model\Oauth\Token; -class TokenServiceTest extends \PHPUnit_Framework_TestCase +class CustomerTokenServiceTest extends \PHPUnit_Framework_TestCase { - /** \Magento\Integration\Service\V1\TokenService */ + /** \Magento\Integration\Service\V1\CustomerTokenService */ protected $_tokenService; /** \Magento\Integration\Model\Oauth\Token\Factory|\PHPUnit_Framework_MockObject_MockObject */ protected $_tokenModelFactoryMock; - /** \Magento\User\Model\User|\PHPUnit_Framework_MockObject_MockObject */ - protected $_userModelMock; - /** \Magento\Customer\Service\V1\CustomerAccountServiceInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_customerAccountServiceMock; @@ -49,9 +46,10 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase /** \Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $_tokenModelCollectionFactoryMock; - /** - * @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject - */ + /** @var \Magento\Integration\Helper\Validator|\PHPUnit_Framework_MockObject_MockObject */ + protected $validatorHelperMock; + + /** @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject */ private $_tokenMock; protected function setUp() @@ -61,10 +59,6 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->_userModelMock = $this->getMockBuilder('Magento\User\Model\User') - ->disableOriginalConstructor() - ->getMock(); - $this->_customerAccountServiceMock = $this ->getMockBuilder('Magento\Customer\Service\V1\CustomerAccountServiceInterface') ->disableOriginalConstructor() @@ -88,11 +82,15 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase ->method('create') ->will($this->returnValue($this->_tokenModelCollectionMock)); - $this->_tokenService = new \Magento\Integration\Service\V1\TokenService( + $this->validatorHelperMock = $this->getMockBuilder( + 'Magento\Integration\Helper\Validator' + )->disableOriginalConstructor()->getMock(); + + $this->_tokenService = new \Magento\Integration\Service\V1\CustomerTokenService( $this->_tokenModelFactoryMock, - $this->_userModelMock, $this->_customerAccountServiceMock, - $this->_tokenModelCollectionFactoryMock + $this->_tokenModelCollectionFactoryMock, + $this->validatorHelperMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php index 199ccae56c8187bac22399b0e49c7951d4fd6430..ededc36d2adc3778d682bd17c4a47420a4d9d69d 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php @@ -108,7 +108,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase ); $this->_service = new \Magento\Integration\Service\V1\Oauth( - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), + $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false), $this->_consumerFactory, $this->_tokenFactoryMock, $this->getMock('Magento\Integration\Helper\Oauth\Data', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php index da687ffb30d52bf7c451455601feb4e80c20e7a2..509d48f3ad24182baa99467c102955b217bd5e4b 100644 --- a/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php +++ b/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php @@ -68,4 +68,10 @@ class ShellTest extends \PHPUnit_Framework_TestCase $shellMock->expects($this->once())->method('run'); $this->assertEquals($this->_responseMock, $this->_model->launch()); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', array(), array(), '', false); + $this->assertFalse($this->_model->catchException($bootstrap, new \Exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php b/dev/tests/unit/testsuite/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8baa45099899e6a11e215471c632739b62263a16 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php @@ -0,0 +1,184 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class StatusTest + * @package Magento\Log\Block\Adminhtml\Edit\Tab\View + */ +class StatusTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status + */ + protected $block; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $logFactory; + + /** + * @var \Magento\Log\Model\Customer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerLog; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDate; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + protected function setUp() + { + $log = $this->getMock('Magento\Log\Model\Log', ['getOnlineMinutesInterval'], [], '', false); + $log->expects($this->any())->method('getOnlineMinutesInterval')->will($this->returnValue(1)); + + $this->customerLog = $this->getMockBuilder('Magento\Log\Model\Customer')->disableOriginalConstructor() + ->setMethods(['getLoginAt', 'getLoginAtTimestamp', 'loadByCustomer', 'getLogoutAt', 'getLastVisitAt']) + ->getMock(); + $this->customerLog->expects($this->any())->method('loadByCustomer')->will($this->returnSelf()); + + $this->logFactory = $this->getMockBuilder('Magento\Log\Model\CustomerFactory')->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->logFactory->expects($this->any())->method('create')->will($this->returnValue($this->customerLog)); + + $dateTime = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime')->setMethods(['now']) + ->disableOriginalConstructor() + ->getMock(); + $dateTime->expects($this->any())->method('now')->will($this->returnCallback(function () { + return date('Y-m-d H:i:s'); + })); + + $customer = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\Customer') + ->setMethods(['getId', 'getStoreId']) + ->disableOriginalConstructor()->getMock(); + $customer->expects($this->any())->method('getId')->will($this->returnValue(1)); + $customer->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); + + $customerData = array('account' => ['id' => 1, 'store_id' => 1]); + $customerBuilder = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\CustomerBuilder') + ->setMethods(['populateWithArray', 'create']) + ->disableOriginalConstructor() + ->getMock(); + $customerBuilder->expects($this->any())->method('populateWithArray') + ->will($this->returnSelf()); + $customerBuilder->expects($this->any())->method('create') + ->will($this->returnValue($customer)); + + $backendSession = $this->getMockBuilder('\Magento\Backend\Model\Session') + ->setMethods(['getCustomerData'])->disableOriginalConstructor()->getMock(); + $backendSession->expects($this->any())->method('getCustomerData')->will($this->returnValue($customerData)); + + $this->localeDate = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Timezone') + ->setMethods(['scopeDate', 'formatDate', 'getDefaultTimezonePath']) + ->disableOriginalConstructor()->getMock(); + $this->localeDate->expects($this->any())->method('getDefaultTimezonePath') + ->will($this->returnValue('path/to/default/timezone')); + + $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config') + ->setMethods(['getValue']) + ->disableOriginalConstructor()->getMock(); + + $objectManagerHelper = new ObjectManagerHelper($this); + $this->block = $objectManagerHelper->getObject( + 'Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status', + [ + 'logFactory' => $this->logFactory, + 'localeDate' => $this->localeDate, + 'scopeConfig' => $this->scopeConfig, + 'modelLog' => $log, + 'dateTime' => $dateTime, + 'customerBuilder' => $customerBuilder, + 'backendSession' => $backendSession + ] + ); + } + + public function testGetCustomerLog() + { + $this->logFactory->expects($this->once())->method('create')->will($this->returnValue($this->customerLog)); + $this->assertSame($this->customerLog, $this->block->getCustomerLog()); + } + + public function testGetCurrentStatusOffline() + { + $date = date('Y-m-d H:i:s'); + $this->customerLog->expects($this->any())->method('getLogoutAt')->will($this->returnValue($date)); + $this->assertEquals('Offline', $this->block->getCurrentStatus()); + } + + public function testGetCurrentStatusOnline() + { + $date = date('Y-m-d H:i:s'); + $this->customerLog->expects($this->any())->method('getLogoutAt')->will($this->returnValue(0)); + $this->customerLog->expects($this->any())->method('getLastVisitAt')->will($this->returnValue($date)); + $this->assertEquals('Online', $this->block->getCurrentStatus()); + } + + public function testGetLastLoginDate() + { + $date = date('Y-m-d H:i:s'); + $this->customerLog->expects($this->any())->method('getLoginAt')->will($this->returnValue($date)); + $this->localeDate->expects($this->once())->method('formatDate')->will($this->returnValue($date)); + $this->assertEquals($date, $this->block->getLastLoginDate()); + } + + public function testAfterGetLastLoginDateNever() + { + $this->assertEquals('Never', $this->block->getLastLoginDate()); + } + + public function testGetStoreLastLoginDate() + { + $date = date('Y-m-d H:i:s'); + $time = strtotime($date); + + $this->localeDate->expects($this->once())->method('scopeDate')->will($this->returnValue($date)); + $this->localeDate->expects($this->once())->method('formatDate')->will($this->returnValue($date)); + + $this->customerLog->expects($this->any())->method('getLoginAtTimestamp')->will($this->returnValue($time)); + $this->assertEquals($date, $this->block->getStoreLastLoginDate()); + } + + public function testGetStoreLastLoginDateNever() + { + $this->assertEquals('Never', $this->block->getStoreLastLoginDate()); + } + + public function testGetStoreLastLoginDateTimezone() + { + $this->scopeConfig->expects($this->once())->method('getValue') + ->with('path/to/default/timezone', 'store', 1) + ->will($this->returnValue('America/Los_Angeles')); + $this->block->getStoreLastLoginDateTimezone(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Log/Model/LogTest.php b/dev/tests/unit/testsuite/Magento/Log/Model/LogTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f16c957f892ca013826dce06966b5348b4405d77 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Log/Model/LogTest.php @@ -0,0 +1,102 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Log\Model; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class LogTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Log\Model\Log + */ + protected $log; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + protected function setUp() + { + $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $resource = $this->getMockBuilder('Magento\Customer\Model\Resource\Visitor') + ->setMethods(['clean', 'getIdFieldName']) + ->disableOriginalConstructor() + ->getMock(); + $resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id')); + $resource->expects($this->any())->method('clean')->will($this->returnSelf()); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $arguments = $this->objectManagerHelper->getConstructArguments( + 'Magento\Log\Model\Log', + [ + 'registry' => $this->registry, + 'scopeConfig' => $this->scopeConfig, + 'resource' => $resource + ] + ); + $this->log = $this->objectManagerHelper->getObject('Magento\Log\Model\Log', $arguments); + } + + public function testGetLogCleanTime() + { + $this->scopeConfig->expects($this->once())->method('getValue') + ->with(Log::XML_LOG_CLEAN_DAYS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ->will($this->returnValue(30)); + $this->assertEquals(2592000, $this->log->getLogCleanTime()); + } + + public function testClean() + { + $this->assertSame($this->log, $this->log->clean()); + } + + public function testGetOnlineMinutesInterval() + { + $this->scopeConfig->expects($this->once())->method('getValue') + ->with( + 'customer/online_customers/online_minutes_interval', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->will($this->returnValue(10)); + + $this->assertEquals(10, $this->log->getOnlineMinutesInterval()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Log/Model/VisitorTest.php b/dev/tests/unit/testsuite/Magento/Log/Model/VisitorTest.php index f3831db35cdc076585c7612ba5b5d662f12742b2..3f5f3360230e4f95deba6cc5b7412d540801d0be 100644 --- a/dev/tests/unit/testsuite/Magento/Log/Model/VisitorTest.php +++ b/dev/tests/unit/testsuite/Magento/Log/Model/VisitorTest.php @@ -21,49 +21,151 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + namespace Magento\Log\Model; +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + class VisitorTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Log\Model\Visitor */ - protected $_model; + protected $visitor; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Framework\Session\SessionManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionManagerInterface; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerInterface; + + /** + * @var \Magento\Framework\HTTP\Header|\PHPUnit_Framework_MockObject_MockObject + */ + protected $header; + + /** + * @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress|\PHPUnit_Framework_MockObject_MockObject + */ + protected $remoteAddress; + + /** + * @var \Magento\Framework\HTTP\PhpEnvironment\ServerAddress|\PHPUnit_Framework_MockObject_MockObject + */ + protected $serverAddress; + + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTime; + + public function setUp() + { + $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->sessionManagerInterface = $this->getMock('Magento\Framework\Session\SessionManagerInterface'); + $this->storeManagerInterface = $this->getMock('Magento\Framework\StoreManagerInterface'); + $this->header = $this->getMock('Magento\Framework\HTTP\Header', [], [], '', false); + $this->remoteAddress = $this->getMock('Magento\Framework\HTTP\PhpEnvironment\RemoteAddress', [], [], '', false); + $this->serverAddress = $this->getMock('Magento\Framework\HTTP\PhpEnvironment\ServerAddress', [], [], '', false); + $this->dateTime = $this->getMock('Magento\Framework\Stdlib\DateTime'); + + $store = $this->getMock('\Magento\Store\Model\Store', [], [], '', false, false); + $this->storeManagerInterface->expects($this->any())->method('getStore')->will($this->returnValue($store)); + $this->dateTime->expects($this->any())->method('now')->will($this->returnValue(time())); + + $resource = $this->getMockBuilder('Magento\Customer\Model\Resource\Visitor') + ->setMethods([ + 'beginTransaction', + '__sleep', + '__wakeup', + 'getIdFieldName', + 'save', + 'addCommitCallback', + 'commit' + ])->disableOriginalConstructor()->getMock(); + $resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id')); + $resource->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); - protected function setUp() + $objectManagerHelper = new ObjectManagerHelper($this); + $arguments = $objectManagerHelper->getConstructArguments( + 'Magento\Log\Model\Visitor', + [ + 'registry' => $this->registry, + 'session' => $this->sessionManagerInterface, + 'storeManager' => $this->storeManagerInterface, + 'httpHeader' => $this->header, + 'remoteAddress' => $this->remoteAddress, + 'serverAddress' => $this->serverAddress, + 'dateTime' => $this->dateTime, + 'resource' => $resource + ] + ); + + $this->visitor = $objectManagerHelper->getObject('Magento\Log\Model\Visitor', $arguments); + } + + public function testInitServerData() { - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_model = $helper->getObject('Magento\Log\Model\Visitor'); + $data = array( + 'server_addr', 'remote_addr', 'http_secure', 'http_host', 'http_user_agent', + 'http_accept_language', 'http_accept_charset', 'request_uri', 'http_referer' + ); + $result = array_diff($data, array_keys($this->visitor->initServerData()->getData())); + $this->assertEmpty($result); } - public function testBindCustomerLogin() + public function testGetUrl() { - $customer = new \Magento\Framework\Object(['id' => '1']); - $observer = new \Magento\Framework\Object([ - 'event' => new \Magento\Framework\Object(['customer' => $customer]) + $this->visitor->setData([ + 'http_secure' => false, + 'http_host' => 'magento.com', + 'request_uri' => '/?some=query' ]); + $this->assertEquals('http://magento.com/?some=query', $this->visitor->getUrl()); + } - $this->_model->bindCustomerLogin($observer); - $this->assertTrue($this->_model->getDoCustomerLogin()); - $this->assertEquals($customer->getId(), $this->_model->getCustomerId()); + public function testGetFirstVisitAt() + { + $time = time(); + $this->assertEquals($time, $this->visitor->getFirstVisitAt()); + } - $this->_model->unsetData(); - $this->_model->setCustomerId('2'); - $this->_model->bindCustomerLogin($observer); - $this->assertNull($this->_model->getDoCustomerLogin()); - $this->assertEquals('2', $this->_model->getCustomerId()); + public function testGetLastVisitAt() + { + $time = time(); + $this->dateTime->expects($this->once())->method('now')->will($this->returnValue($time)); + $this->assertEquals($time, $this->visitor->getLastVisitAt()); } - public function testBindCustomerLogout() + public function testLogNewVisitor() { - $observer = new \Magento\Framework\Object(); + $visitor = $this->getMockBuilder('Magento\Customer\Model\Visitor') + ->disableOriginalConstructor()->getMock(); + $visitor->expects($this->once())->method('setData')->will($this->returnSelf()); + $visitor->expects($this->once())->method('getData')->will($this->returnValue([])); + $event = new \Magento\Framework\Object(['visitor' => $visitor]); + $observer = new \Magento\Framework\Object(['event' => $event]); + $this->assertSame($this->visitor, $this->visitor->logNewVisitor($observer)); + } - $this->_model->setCustomerId('1'); - $this->_model->bindCustomerLogout($observer); - $this->assertTrue($this->_model->getDoCustomerLogout()); + public function testLogVisitorActivity() + { + $visitor = $this->getMockBuilder('Magento\Customer\Model\Visitor') + ->disableOriginalConstructor()->getMock(); + $visitor->expects($this->once())->method('setData')->will($this->returnSelf()); + $visitor->expects($this->once())->method('getData')->will($this->returnValue(['visitor_id' => 1])); - $this->_model->unsetData(); - $this->_model->bindCustomerLogout($observer); - $this->assertNull($this->_model->getDoCustomerLogout()); + $event = new \Magento\Framework\Object(['visitor' => $visitor]); + $observer = new \Magento\Framework\Object(['event' => $event]); + $this->assertSame($this->visitor, $this->visitor->logVisitorActivity($observer)); } } diff --git a/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php b/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php index 50edbe9aa7c8cafcf0f1458b0e68f6f819ebd0af..baa5925050e0ff630bb62ea890791934220410de 100644 --- a/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php +++ b/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php @@ -36,7 +36,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase $sourceString = 'Ë£'; // Test protected method via reflection - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $localeResolver = $this->getMock('\Magento\Framework\Locale\ResolverInterface', array(), array(), '', false); $urlBuilder = $this->getMock('Magento\Framework\UrlInterface', array(), array(), '', false); $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php index dff4e4e7ef8b6c027b585ee26018cd61a6276c7a..af1a460790902701e809a48d37867c7296f7a0b8 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php @@ -138,6 +138,10 @@ class MessageBoxTest extends \PHPUnit_Framework_TestCase ->method('setPath') ->with('/') ->will($this->returnValue($this->publicCookieMetadataMock)); + $this->publicCookieMetadataMock->expects(($this->exactly($numOfCalls))) + ->method('setHttpOnly') + ->with(false) + ->will($this->returnValue($this->publicCookieMetadataMock)); $this->cookieManagerMock->expects($this->exactly($numOfCalls)) ->method('setPublicCookie') ->with( diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php index 03085b85ebe91b3f3a5d3dd39c991fff07fdc46b..d85615fdb7d9d9e930007268ae0f626e6c9742d3 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php @@ -40,7 +40,7 @@ class FreeTest extends \PHPUnit_Framework_TestCase $paymentData = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); $logAdapterFactory = $this->getMock('Magento\Framework\Logger\AdapterFactory', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); $this->methodFree = new \Magento\Payment\Model\Method\Free( $eventManager, diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php index e8d5e987d61a5c5f6c23aff5473fe8a81a114f48..dfe08cdc4e65f1d7cf2450cddc3f0a424cc8c556 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php @@ -27,28 +27,95 @@ namespace Magento\Paypal\Model\Express; class CheckoutTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Paypal\Model\Express\Checkout + * @var \Magento\Paypal\Model\Express\Checkout | \Magento\Paypal\Model\Express\Checkout */ - protected $_checkoutModel; + protected $checkoutModel; /** * @var \Magento\TestFramework\Helper\ObjectManager */ - protected $_objectManager; + protected $objectManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject | \'Magento\Sales\Model\Quote */ - protected $_quoteMock; + protected $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Sales\Model\Service\Quote + */ + protected $serviceQuote; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Sales\Model\Service\QuoteFactory + */ + protected $quoteFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $customerAccountServiceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Customer\Service\V1\Data\AddressBuilderFactory + */ + protected $addressBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Framework\Object\Copy + */ + protected $objectCopyServiceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Customer\Model\Session + */ + protected $customerSessionMock; protected function setUp() { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); + $this->serviceQuote = $this->getMock('\Magento\Sales\Model\Service\Quote', [], [], '', false); + $this->quoteFactoryMock = $this->getMock( + '\Magento\Sales\Model\Service\QuoteFactory', + ['create'], + [], + '', + false + ); + $this->customerAccountServiceMock = $this->getMock( + '\Magento\Customer\Service\V1\CustomerAccountServiceInterface', + [], + [], + '', + false + ); + $this->addressBuilderFactoryMock = $this->getMockBuilder( + '\Magento\Customer\Service\V1\Data\AddressBuilderFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->objectCopyServiceMock = $this->getMockBuilder('\Magento\Framework\Object\Copy') + ->disableOriginalConstructor() + ->getMock(); + $this->customerSessionMock = $this->getMockBuilder('\Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->getMock(); $paypalConfigMock = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); - $this->_quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); - $this->_checkoutModel = $this->_objectManager->getObject( + $this->checkoutModel = $this->objectManager->getObject( 'Magento\Paypal\Model\Express\Checkout', - ['params' => ['quote' => $this->_quoteMock, 'config' => $paypalConfigMock]] + [ + 'params' => [ + 'quote' => $this->quoteMock, + 'config' => $paypalConfigMock, + 'session' => $this->customerSessionMock + ], + 'customerAccountService' => $this->customerAccountServiceMock, + 'serviceQuoteFactory' => $this->quoteFactoryMock, + 'addressBuilderFactory' => $this->addressBuilderFactoryMock, + 'objectCopyService' => $this->objectCopyServiceMock + ] ); parent::setUp(); } @@ -57,9 +124,9 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Customer\Service\V1\Data\Customer $customerDataMock */ $customerDataMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); - $this->_quoteMock->expects($this->once())->method('assignCustomer')->with($customerDataMock); + $this->quoteMock->expects($this->once())->method('assignCustomer')->with($customerDataMock); $customerDataMock->expects($this->once())->method('getId'); - $this->_checkoutModel->setCustomerData($customerDataMock); + $this->checkoutModel->setCustomerData($customerDataMock); } public function testSetCustomerWithAddressChange() @@ -68,11 +135,85 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase $customerDataMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); /** @var \Magento\Sales\Model\Quote\Address $customerDataMock */ $quoteAddressMock = $this->getMock('Magento\Sales\Model\Quote\Address', [], [], '', false); - $this->_quoteMock + $this->quoteMock ->expects($this->once()) ->method('assignCustomerWithAddressChange') ->with($customerDataMock, $quoteAddressMock, $quoteAddressMock); $customerDataMock->expects($this->once())->method('getId'); - $this->_checkoutModel->setCustomerWithAddressChange($customerDataMock, $quoteAddressMock, $quoteAddressMock); + $this->checkoutModel->setCustomerWithAddressChange($customerDataMock, $quoteAddressMock, $quoteAddressMock); + } + + public function testPrepareNewCustomerQuote() + { + $this->quoteMock->expects($this->any()) + ->method('getCheckoutMethod') + ->willReturn(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER); + $this->quoteMock->expects($this->once()) + ->method('setCustomerData') + ->willReturnSelf(); + + $this->quoteFactoryMock->expects($this->once()) + ->method('create') + ->withAnyParameters() + ->willReturn($this->serviceQuote); + + $this->objectCopyServiceMock->expects($this->once()) + ->method('getDataFromFieldset') + ->withAnyParameters() + ->willReturn([]); + + $this->customerSessionMock->expects($this->once()) + ->method('regenerateId'); + + $addressDataBuilderMock = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\AddressBuilder') + ->disableOriginalConstructor() + ->getMock(); + $this->addressBuilderFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($addressDataBuilderMock); + $addressDataBuilderMock->expects($this->any()) + ->method('populate') + ->withAnyParameters() + ->willReturnSelf(); + $addressDataBuilderMock->expects($this->any()) + ->method('setDefaultShipping') + ->withAnyParameters() + ->willReturnSelf(); + $addressDataBuilderMock->expects($this->any()) + ->method('setDefaultBilling') + ->withAnyParameters() + ->willReturnSelf(); + + $addressDataMock = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\Address') + ->disableOriginalConstructor() + ->getMock(); + $addressDataBuilderMock->expects($this->any()) + ->method('create') + ->willReturn($addressDataMock); + + $addressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); + $this->quoteMock->expects($this->any()) + ->method('getBillingAddress') + ->willReturn($addressMock); + $this->quoteMock->expects($this->any()) + ->method('getShippingAddress') + ->willReturn($addressMock); + $addressMock->expects($this->any()) + ->method('exportCustomerAddressData') + ->willReturn( + $this->getMockBuilder('\Magento\Customer\Service\V1\Data\Address')->disableOriginalConstructor() + ->getMock() + ); + + $customerDataMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $this->customerAccountServiceMock->expects($this->any()) + ->method('getCustomer') + ->willReturn($customerDataMock); + $this->quoteMock->expects($this->any()) + ->method('getCustomerData') + ->willReturn($customerDataMock); + + $this->checkoutModel->setCustomerData($customerDataMock); + $this->checkoutModel->place('token'); } } diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/PayflowlinkTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/PayflowlinkTest.php index b2eb2eba5e84d6f5f8ec14c401c31ea2ee3bd58e..12577017263fcc32155334aa5ceb063564240660 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Model/PayflowlinkTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/PayflowlinkTest.php @@ -46,7 +46,7 @@ class PayflowlinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $this->paypalConfig = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); $configFactory = $this->getMock('Magento\Paypal\Model\ConfigFactory', ['create']); diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php index 04d046fccae9e593ffc224cf2c462d2efa77e9f2..2ae45f8ba6b092d7dd6e2d6f81f069860256cb70 100644 --- a/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php @@ -150,6 +150,10 @@ class SessionTest extends \PHPUnit_Framework_TestCase ->method('setDuration') ->with($duration) ->will($this->returnSelf()); + $cookieMetadataMock->expects($this->once()) + ->method('setHttpOnly') + ->with(true) + ->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->once()) ->method('createPublicCookieMetadata') ->will($this->returnValue($cookieMetadataMock)); @@ -189,6 +193,10 @@ class SessionTest extends \PHPUnit_Framework_TestCase ->method('setDuration') ->with($cookieDuration) ->will($this->returnSelf()); + $cookieMetadataMock->expects($this->exactly($numCalls)) + ->method('setHttpOnly') + ->with(true) + ->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->exactly($numCalls)) ->method('createPublicCookieMetadata') ->will($this->returnValue($cookieMetadataMock)); diff --git a/dev/tests/unit/testsuite/Magento/RecurringPayment/Block/Payment/Related/Orders/GridTest.php b/dev/tests/unit/testsuite/Magento/RecurringPayment/Block/Payment/Related/Orders/GridTest.php index d9822720aa29d0b794abb39d74d68f3db6bdbd57..94a73d8be82a60938f51370a6d2a093ba48a41bb 100644 --- a/dev/tests/unit/testsuite/Magento/RecurringPayment/Block/Payment/Related/Orders/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/RecurringPayment/Block/Payment/Related/Orders/GridTest.php @@ -39,7 +39,7 @@ class GridTest extends \PHPUnit_Framework_TestCase protected $registry; /** - * @var \Magento\Store\Model\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; @@ -68,7 +68,7 @@ class GridTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->collection = $this->getMock('Magento\Sales\Model\Resource\Order\Collection', [], [], '', false); $this->locale = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); $this->helper = $this->getMock('Magento\Core\Helper\Data', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Review/Block/Customer/RecentTest.php b/dev/tests/unit/testsuite/Magento/Review/Block/Customer/RecentTest.php index 1447ab7a6ecf1ecb242c4d8eb1228499b95f319e..ee93f49934ad170cf7095aad8fcbe3ff3b982840 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Block/Customer/RecentTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Block/Customer/RecentTest.php @@ -45,12 +45,12 @@ class RecentTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Helper\Session\CurrentCustomer|\PHPUnit_Framework_MockObject_MockObject */ protected $currentCustomer; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; protected function setUp() { - $this->storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', array(), array(), '', false); $this->context->expects( $this->any() diff --git a/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php b/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php index c131a2f30aeb4f3b0c3edfa2f9ad1f69da33b9c8..8ad7ed218d62580a1ca81ac924e0081170c8dfef 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php @@ -153,7 +153,7 @@ class PostTest extends \PHPUnit_Framework_TestCase '\Magento\Framework\ObjectManager', array('get', 'create', 'configure'), array(), '', false ); $this->_messageManagerMock = $this->getMock('\Magento\Framework\Message\Manager', array(), array(), '', false); - $this->_storeManagerInterfaceMock = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerInterfaceMock = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $this->_storeModelMock = $this->getMock( 'Magento\Store\Model\Store', array('__wakeup', 'getId'), array(), '', false ); @@ -203,7 +203,7 @@ class PostTest extends \PHPUnit_Framework_TestCase $this->_requestMock->expects($this->once())->method('getPost') ->will($this->returnValue(array('status_id' => 1))); $this->_objectManagerMock->expects($this->at(0))->method('get') - ->with('Magento\Store\Model\StoreManagerInterface') + ->with('Magento\Framework\StoreManagerInterface') ->will($this->returnValue($this->_storeManagerInterfaceMock)); $this->_reviewFactoryMock->expects($this->once())->method('create') ->will($this->returnValue($this->_reviewModelMock)); diff --git a/dev/tests/unit/testsuite/Magento/Review/Model/ReviewTest.php b/dev/tests/unit/testsuite/Magento/Review/Model/ReviewTest.php index 7d31c946bfba5b62aed2f8132db5a9b963fc08c6..6f4beff55b6c2ebcc83a7cbf4fabff00585b2ba1 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Model/ReviewTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Model/ReviewTest.php @@ -55,7 +55,7 @@ class ReviewTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Review\Model\Review\Summary|\PHPUnit_Framework_MockObject_MockObject */ protected $summaryMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -82,7 +82,7 @@ class ReviewTest extends \PHPUnit_Framework_TestCase $this->reviewSummaryMock = $this->getMock('Magento\Review\Model\Resource\Review\Summary\CollectionFactory'); $this->summaryModMock = $this->getMock('Magento\Review\Model\Review\SummaryFactory', ['create']); $this->summaryMock = $this->getMock('Magento\Review\Model\Review\Summary', [], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->urlInterfaceMock = $this->getMock('Magento\Framework\UrlInterface'); $this->resource = $this->getMock('Magento\Review\Model\Resource\Review', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/ReviewTest.php b/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/ReviewTest.php index fe3e665b7a44906eac8da7497154de15e7d2d58e..7d92ee2e721cedfcdbc3e10eb5840ecc025558fd 100644 --- a/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/ReviewTest.php +++ b/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/ReviewTest.php @@ -46,7 +46,7 @@ class ReviewTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $reviewFactoryMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\UrlInterface */ diff --git a/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/SpecialTest.php b/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/SpecialTest.php index a459721a1fc36b8236fe55323ece6df81dc922a9..ead8fc8130c63fd5a1a8b14ed9887ff9eada07d8 100644 --- a/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/SpecialTest.php +++ b/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/SpecialTest.php @@ -97,7 +97,7 @@ class SpecialTest extends \PHPUnit_Framework_TestCase $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); $requestMock = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/ActionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/ActionFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7ccc9c55de707344b7d4186b7f4cdffd461be824 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/ActionFactoryTest.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Rule\Model; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ActionFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\ActionFactory + */ + protected $actionFactory; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + protected function setUp() + { + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->actionFactory = $this->objectManagerHelper->getObject( + 'Magento\Rule\Model\ActionFactory', + [ + 'objectManager' => $this->objectManagerMock + ] + ); + } + + public function testCreate() + { + $type = '1'; + $data = ['data2', 'data3']; + $this->objectManagerMock->expects($this->once())->method('create')->with($type, $data); + $this->actionFactory->create($type, $data); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php index 4fa1edea8b023b6914f8b26152b498c8a93d3bbf..9320cabcfb8d46e6d417c28062457be8f691cb2d 100644 --- a/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php @@ -28,13 +28,19 @@ use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; class CombineTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Rule\Model\Condition\Combine */ + /** + * @var \Magento\Rule\Model\Condition\Combine + */ protected $_combine; - /** @var ObjectManagerHelper */ + /** + * @var ObjectManagerHelper + */ protected $_objectManagerHelper; - /** @var \Magento\Rule\Model\Condition\Context|\PHPUnit_Framework_MockObject_MockObject */ + /** + * @var \Magento\Rule\Model\Condition\Context|\PHPUnit_Framework_MockObject_MockObject + */ protected $_contextMock; protected function setUp() diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c918965894158b561f72b2019cfce770dd011576 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Rule\Model; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ConditionFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\ConditionFactory + */ + protected $conditionFactory; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + protected function setUp() + { + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->conditionFactory = $this->objectManagerHelper->getObject( + 'Magento\Rule\Model\ConditionFactory', + [ + 'objectManager' => $this->objectManagerMock + ] + ); + } + + public function testCreate() + { + $type = '1'; + $data = ['data2', 'data3']; + $this->objectManagerMock->expects($this->once())->method('create')->with($type, $data); + $this->conditionFactory->create($type, $data); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ActionsTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ActionsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..25379e64341769cef4a53816888eb85822beff3e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ActionsTest.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Rule\Model\Renderer; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ActionsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\Renderer\Actions + */ + protected $actions; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Data\Form\Element\AbstractElement|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_element; + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->actions = $this->objectManagerHelper->getObject('Magento\Rule\Model\Renderer\Actions'); + $this->_element = $this->getMock( + '\Magento\Framework\Data\Form\Element\AbstractElement', + ['getRule'], + [], + '', + false + ); + } + + public function testRender() + { + $rule = $this->getMock('\Magento\Rule\Model\Rule', ['getActions', '__sleep', '__wakeup'], [], '', false); + $actions = $this->getMock('\Magento\Rule\Model\Action\Collection', ['asHtmlRecursive'], [], '', false); + + $this->_element->expects($this->any()) + ->method('getRule') + ->will($this->returnValue($rule)); + + $rule->expects($this->any()) + ->method('getActions') + ->will($this->returnValue($actions)); + + $actions->expects($this->once()) + ->method('asHtmlRecursive') + ->will($this->returnValue('action html')); + + $this->assertEquals('action html', $this->actions->render($this->_element)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ConditionsTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ConditionsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..425d5a19251882db308c99344beb5fd8be8a0f68 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ConditionsTest.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Rule\Model\Renderer; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ConditionsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\Renderer\Conditions + */ + protected $conditions; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Data\Form\Element\AbstractElement|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_element; + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->conditions = $this->objectManagerHelper->getObject('Magento\Rule\Model\Renderer\Conditions'); + $this->_element = $this->getMock( + '\Magento\Framework\Data\Form\Element\AbstractElement', + ['getRule'], + [], + '', + false + ); + } + + public function testRender() + { + $rule = $this->getMock('\Magento\Rule\Model\Rule', ['getConditions', '__sleep', '__wakeup'], [], '', false); + $conditions = $this->getMock('\Magento\Rule\Model\Condition\Combine', ['asHtmlRecursive'], [], '', false); + + $this->_element->expects($this->any()) + ->method('getRule') + ->will($this->returnValue($rule)); + + $rule->expects($this->any()) + ->method('getConditions') + ->will($this->returnValue($conditions)); + + $conditions->expects($this->once()) + ->method('asHtmlRecursive') + ->will($this->returnValue('conditions html')); + + $this->assertEquals('conditions html', $this->conditions->render($this->_element)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollectionTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollectionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..26305d5db967ae8f8b3643abc5481f759ce5af72 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollectionTest.php @@ -0,0 +1,181 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Rule\Model\Resource\Rule\Collection; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class AbstractCollectionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\Resource\Rule\Collection\AbstractCollection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $abstractCollection; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Data\Collection\EntityFactoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_entityFactoryMock; + + /** + * @var \Magento\Framework\Logger|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_loggerMock; + + /** + * @var \Magento\Framework\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_fetchStrategyMock; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_managerMock; + + /** + * @var \Magento\Framework\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_db; + + protected function setUp() + { + $this->_entityFactoryMock = $this->getMock('Magento\Framework\Data\Collection\EntityFactoryInterface'); + $this->_loggerMock = $this->getMock('Magento\Framework\Logger', [], [], '', false); + $this->_fetchStrategyMock = $this->getMock('Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); + $this->_managerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $this->_db = $this->getMockForAbstractClass( + '\Magento\Framework\Model\Resource\Db\AbstractDb', + [], + '', + false, + false, + true, + ['__sleep', '__wakeup'] + ); + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->abstractCollection = $this->getMockForAbstractClass( + '\Magento\Rule\Model\Resource\Rule\Collection\AbstractCollection', + [ + 'entityFactory' => $this->_entityFactoryMock, + 'logger' => $this->_loggerMock, + 'fetchStrategy' => $this->_fetchStrategyMock, + 'eventManager' => $this->_managerMock, + null, + $this->_db + ], + '', + false, + false, + true, + ['__sleep', '__wakeup', '_getAssociatedEntityInfo', 'getConnection', 'getSelect', 'getTable'] + ); + } + + public function testAddWebsitesToResultDataProvider() + { + return [ + [null, true], + [true, true], + [false, false] + ]; + } + + /** + * @dataProvider testAddWebsitesToResultDataProvider + */ + public function testAddWebsitesToResult($flag, $expectedResult) + { + $this->abstractCollection->addWebsitesToResult($flag); + $this->assertEquals($expectedResult, $this->abstractCollection->getFlag('add_websites_to_result')); + } + + protected function _prepareAddFilterStubs() + { + $entityInfo = []; + $entityInfo['entity_id_field'] = 'entity_id'; + $entityInfo['rule_id_field'] = 'rule_id'; + $entityInfo['associations_table'] = 'assoc_table'; + + $connection = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'); + $select = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + $collectionSelect = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + + $connection->expects($this->any()) + ->method('select') + ->will($this->returnValue($select)); + + $select->expects($this->any()) + ->method('from') + ->will($this->returnSelf()); + + $select->expects($this->any()) + ->method('where') + ->will($this->returnSelf()); + + $collectionSelect->expects($this->once()) + ->method('exists'); + + $this->abstractCollection->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($connection)); + + $this->_db->expects($this->any()) + ->method('getTable') + ->will($this->returnArgument(0)); + + $this->abstractCollection->expects($this->any()) + ->method('getSelect') + ->will($this->returnValue($collectionSelect)); + + $this->abstractCollection->expects($this->any()) + ->method('_getAssociatedEntityInfo') + ->will($this->returnValue($entityInfo)); + } + + public function testAddWebsiteFilter() + { + $this->_prepareAddFilterStubs(); + $website = $this->getMock('\Magento\Store\Model\Website', ['getId', '__sleep', '__wakeup'], [], '', false); + + $website->expects($this->any()) + ->method('getId') + ->will($this->returnValue(1)); + + $this->assertInstanceOf( + '\Magento\Rule\Model\Resource\Rule\Collection\AbstractCollection', + $this->abstractCollection->addWebsiteFilter($website) + ); + } + + public function testAddFieldToFilter() + { + $this->_prepareAddFilterStubs(); + $this->abstractCollection->addFieldToFilter('website_ids', []); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/RuleTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/RuleTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9c1ba6b8341f13993d2b2874e228f99159af726f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/RuleTest.php @@ -0,0 +1,125 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Rule\Model; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class RuleTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\Rule + */ + protected $rule; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + /** + * @var \Magento\Framework\Data\FormFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $formFactoryMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $timezoneMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $combineFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $collectionFactoryMock; + + protected function setUp() + { + $this->contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); + $this->registryMock = $this->getMock('Magento\Framework\Registry'); + $this->formFactoryMock = $this->getMock('Magento\Framework\Data\FormFactory', [], [], '', false); + $this->timezoneMock = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); + $this->combineFactoryMock = $this->getMock( + 'Magento\Rule\Model\Condition\CombineFactory', + ['create'], + [], + '', + false + ); + $this->collectionFactoryMock = $this->getMock( + 'Magento\Rule\Model\Action\CollectionFactory', + ['create'], + [], + '', + false + ); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->rule = $this->objectManagerHelper->getObject( + 'Magento\Rule\Model\Rule', + [ + 'context' => $this->contextMock, + 'registry' => $this->registryMock, + 'formFactory' => $this->formFactoryMock, + 'localeDate' => $this->timezoneMock, + 'conditionsFactory' => $this->combineFactoryMock, + 'actionsFactory' => $this->collectionFactoryMock + ] + ); + } + + public function testGetConditionsInstance() + { + $this->combineFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue( + $this->getMock('\Magento\Rule\Model\Condition\Combine', [], [], '', false) + )); + $this->assertInstanceOf('\Magento\Rule\Model\Condition\Combine', $this->rule->getConditionsInstance()); + } + + public function testGetActionsInstance() + { + $this->collectionFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue( + $this->getMock('\Magento\Rule\Model\Action\Collection', [], [], '', false) + )); + $this->assertInstanceOf('\Magento\Rule\Model\Action\Collection', $this->rule->getActionsInstance()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php index 824d7c00769594a49aa52e18a3e946889a7d1cd6..e894cf00b6b025b33ab015a82127ae29979949f6 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php @@ -33,7 +33,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase protected $contextMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; @@ -62,7 +62,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Helper\Context') ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMock(); $this->salesConfigMock = $this->getMockBuilder('Magento\Sales\Model\Config') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php index 433b70301f7653fe42cd6a3007b02c1f1491b48b..dbfe647e681742d1720d5d24c6c16e5039a2c539 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php @@ -55,7 +55,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php index ebf3e20e2defb2f936b6f65b9b19a6bb547136b4..4e58251dc9206cf39874b585bd50beafddb2e197 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php @@ -44,7 +44,7 @@ class GuestTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $scopeConfigInterfaceMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerInterfaceMock; /** @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */ @@ -75,13 +75,13 @@ class GuestTest extends \PHPUnit_Framework_TestCase { $this->appContextHelperMock = $this->getMock('Magento\Framework\App\Helper\Context', [], [], '', false); $this->scopeConfigInterfaceMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->storeManagerInterfaceMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerInterfaceMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); $this->registryMock = $this->getMock('Magento\Framework\Registry'); $this->sessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager', [], [], '', false); + $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false); $this->cookieMetadataFactoryMock = $this->getMock( - '\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', [], [], '', @@ -153,13 +153,31 @@ class GuestTest extends \PHPUnit_Framework_TestCase $orderMock->expects($this->once())->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); $protectedCode = 'protectedCode'; $orderMock->expects($this->once())->method('getProtectCode')->will($this->returnValue($protectedCode)); - $metaData = new \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata(); + $metaDataMock = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [], + [], + '', + false + ); + $metaDataMock->expects($this->once()) + ->method('setPath') + ->with(Guest::COOKIE_PATH) + ->will($this->returnSelf()); + $metaDataMock->expects($this->once()) + ->method('setDuration') + ->with(Guest::COOKIE_LIFETIME) + ->will($this->returnSelf()); + $metaDataMock->expects($this->once()) + ->method('setHttpOnly') + ->with(true) + ->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->once()) ->method('createPublicCookieMetadata') - ->will($this->returnValue($metaData)); + ->will($this->returnValue($metaDataMock)); $this->cookieManagerMock->expects($this->once()) ->method('setPublicCookie') - ->with(Guest::COOKIE_NAME, $this->anything(), $metaData); + ->with(Guest::COOKIE_NAME, $this->anything(), $metaDataMock); $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); $this->assertTrue($this->guest->loadValidOrder($requestMock, $responseMock)); } @@ -186,13 +204,31 @@ class GuestTest extends \PHPUnit_Framework_TestCase $orderMock->expects($this->once())->method('loadByIncrementId')->with($incrementId); $orderMock->expects($this->exactly(1))->method('getId')->will($this->returnValue($incrementId)); $orderMock->expects($this->once())->method('getProtectCode')->will($this->returnValue($protectedCode)); - $metaData = new \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata(); + $metaDataMock = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [], + [], + '', + false + ); + $metaDataMock->expects($this->once()) + ->method('setPath') + ->with(Guest::COOKIE_PATH) + ->will($this->returnSelf()); + $metaDataMock->expects($this->once()) + ->method('setDuration') + ->with(Guest::COOKIE_LIFETIME) + ->will($this->returnSelf()); + $metaDataMock->expects($this->once()) + ->method('setHttpOnly') + ->with(true) + ->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->once()) ->method('createPublicCookieMetadata') - ->will($this->returnValue($metaData)); + ->will($this->returnValue($metaDataMock)); $this->cookieManagerMock->expects($this->once()) ->method('setPublicCookie') - ->with(Guest::COOKIE_NAME, $this->anything(), $metaData); + ->with(Guest::COOKIE_NAME, $this->anything(), $metaDataMock); $requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/ReorderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/ReorderTest.php index 67c17e48bb5a676809ab37995de383cce2d08dc9..a7c77fcac8ef2b01aa17452d7a57b40c4c8a0aac 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/ReorderTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/ReorderTest.php @@ -65,7 +65,7 @@ class ReorderTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Install/Controller/Wizard/Download.php b/dev/tests/unit/testsuite/Magento/Sales/Model/AbstractModelTest.php similarity index 60% rename from app/code/Magento/Install/Controller/Wizard/Download.php rename to dev/tests/unit/testsuite/Magento/Sales/Model/AbstractModelTest.php index 377c77f9600a537599e3a4a8d474b0f272a14359..af39f91adfe1a6aac4d953c90d4272b0a3ec7092 100644 --- a/app/code/Magento/Install/Controller/Wizard/Download.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/AbstractModelTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,25 +21,31 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; +namespace Magento\Sales\Model; -class Download extends \Magento\Install\Controller\Wizard +/** + * Class AbstractModelTest + */ +class AbstractModelTest extends \PHPUnit_Framework_TestCase { /** - * Download page action - * - * @return void + * @var \Magento\Sales\Model\Order */ - public function execute() + protected $model; + + public function setUp() { - $this->_checkIfInstalled(); - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->model = $objectManager->getObject('Magento\Sales\Model\Order'); + } - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - $this->_view->getLayout()->addBlock('Magento\Install\Block\Download', 'install.download', 'content'); + public function testGetEventPrefix() + { + $this->assertEquals('sales_order', $this->model->getEventPrefix()); + } - $this->_view->renderLayout(); + public function testGetEventObject() + { + $this->assertEquals('order', $this->model->getEventObject()); } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/IncrementTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/IncrementTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7be1ab86c28e8ac61d8c9e4f2f8cfe73db55ab66 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/IncrementTest.php @@ -0,0 +1,80 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model; + +/** + * Class IncrementTest + */ +class IncrementTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Increment + */ + protected $model; + + /** + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eavConfig; + + /** + * @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject + */ + protected $type; + + public function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->eavConfig = $this->getMock('Magento\Eav\Model\Config', ['getEntityType'], [], '', false); + $this->model = $objectManager->getObject('Magento\Sales\Model\Increment', ['eavConfig' => $this->eavConfig]); + $this->type = $this->getMock('Magento\Eav\Model\Entity\Type', ['fetchNewIncrementId'], [], '', false); + } + + public function testGetCurrentValue() + { + $this->type->expects($this->once()) + ->method('fetchNewIncrementId') + ->with(1) + ->willReturn(2); + $this->eavConfig->expects($this->once()) + ->method('getEntityType') + ->with('order') + ->willReturn($this->type); + $this->model->getNextValue(1); + $this->assertEquals(2, $this->model->getCurrentValue()); + } + + public function testNextValue() + { + $this->type->expects($this->once()) + ->method('fetchNewIncrementId') + ->with(1) + ->willReturn(2); + $this->eavConfig->expects($this->once()) + ->method('getEntityType') + ->with('order') + ->willReturn($this->type); + $this->assertEquals(2, $this->model->getNextValue(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersDataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersDataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..57c33fdc7668ccc899fae7d307466d1bfed77272 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersDataTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\AggregateSalesReportBestsellersDataTest + */ +class AggregateSalesReportBestsellersDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeResolverMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\BestsellersFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $bestsellersFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\AggregateSalesReportBestsellersData + */ + protected $observer; + + protected function setUp() + { + $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->bestsellersFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\BestsellersFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AggregateSalesReportBestsellersData( + $this->localeResolverMock, + $this->localeDateMock, + $this->bestsellersFactoryMock + ); + } + + + public function testExecute() + { + $date = $this->setupAggregate(); + $bestsellersMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Bestsellers') + ->disableOriginalConstructor() + ->getMock(); + $bestsellersMock->expects($this->once()) + ->method('aggregate') + ->with($date); + $this->bestsellersFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($bestsellersMock)); + $this->observer->execute(); + } + + /** + * Set up aggregate + * + * @return \Magento\Framework\Stdlib\DateTime\DateInterface + */ + protected function setupAggregate() + { + $date = $this->getMock('Magento\Framework\Stdlib\DateTime\Date', ['emulate', 'revert'], [], '', false); + $this->localeResolverMock->expects($this->once()) + ->method('emulate') + ->with(0); + $this->localeResolverMock->expects($this->once()) + ->method('revert'); + $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') + ->disableOriginalConstructor() + ->getMock(); + $dateMock->expects($this->once()) + ->method('subHour') + ->with(25) + ->will($this->returnValue($date)); + $this->localeDateMock->expects($this->once()) + ->method('date') + ->will($this->returnValue($dateMock)); + return $date; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedDataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedDataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..cb05422bb010d3771eb1809aee6b69ec25fa8c09 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedDataTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\AggregateSalesReportInvoicedDataTest + */ +class AggregateSalesReportInvoicedDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeResolverMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\InvoicedFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoicedFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\AggregateSalesReportInvoicedData + */ + protected $observer; + + protected function setUp() + { + $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->invoicedFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\InvoicedFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AggregateSalesReportInvoicedData( + $this->localeResolverMock, + $this->localeDateMock, + $this->invoicedFactoryMock + ); + } + + + public function testExecute() + { + $date = $this->setupAggregate(); + $invoicedMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Invoiced') + ->disableOriginalConstructor() + ->getMock(); + $invoicedMock->expects($this->once()) + ->method('aggregate') + ->with($date); + $this->invoicedFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($invoicedMock)); + $this->observer->execute(); + } + + /** + * Set up aggregate + * + * @return \Magento\Framework\Stdlib\DateTime\DateInterface + */ + protected function setupAggregate() + { + $date = $this->getMock('Magento\Framework\Stdlib\DateTime\Date', ['emulate', 'revert'], [], '', false); + $this->localeResolverMock->expects($this->once()) + ->method('emulate') + ->with(0); + $this->localeResolverMock->expects($this->once()) + ->method('revert'); + $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') + ->disableOriginalConstructor() + ->getMock(); + $dateMock->expects($this->once()) + ->method('subHour') + ->with(25) + ->will($this->returnValue($date)); + $this->localeDateMock->expects($this->once()) + ->method('date') + ->will($this->returnValue($dateMock)); + return $date; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportOrderDataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportOrderDataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3f5555f10b30b8aeb3d2820510078060ccdb37dd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportOrderDataTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\AggregateSalesReportOrderDataTest + */ +class AggregateSalesReportOrderDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeResolverMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\OrderFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\AggregateSalesReportOrderData + */ + protected $observer; + + protected function setUp() + { + $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\OrderFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AggregateSalesReportOrderData( + $this->localeResolverMock, + $this->localeDateMock, + $this->orderFactoryMock + ); + } + + + public function testExecute() + { + $date = $this->setupAggregate(); + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Order') + ->disableOriginalConstructor() + ->getMock(); + $orderMock->expects($this->once()) + ->method('aggregate') + ->with($date); + $this->orderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($orderMock)); + $this->observer->execute(); + } + + /** + * Set up aggregate + * + * @return \Magento\Framework\Stdlib\DateTime\DateInterface + */ + protected function setupAggregate() + { + $date = $this->getMock('Magento\Framework\Stdlib\DateTime\Date', ['emulate', 'revert'], [], '', false); + $this->localeResolverMock->expects($this->once()) + ->method('emulate') + ->with(0); + $this->localeResolverMock->expects($this->once()) + ->method('revert'); + $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') + ->disableOriginalConstructor() + ->getMock(); + $dateMock->expects($this->once()) + ->method('subHour') + ->with(25) + ->will($this->returnValue($date)); + $this->localeDateMock->expects($this->once()) + ->method('date') + ->will($this->returnValue($dateMock)); + return $date; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportRefundedDataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportRefundedDataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4e4d952327ee254a1a04ca2b06798b69fdf2326c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportRefundedDataTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\AggregateSalesReportRefundedDataTest + */ +class AggregateSalesReportRefundedDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeResolverMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\RefundedFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $refundedFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\AggregateSalesReportRefundedData + */ + protected $observer; + + protected function setUp() + { + $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->refundedFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\RefundedFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AggregateSalesReportRefundedData( + $this->localeResolverMock, + $this->localeDateMock, + $this->refundedFactoryMock + ); + } + + + public function testExecute() + { + $date = $this->setupAggregate(); + $refundedMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Refunded') + ->disableOriginalConstructor() + ->getMock(); + $refundedMock->expects($this->once()) + ->method('aggregate') + ->with($date); + $this->refundedFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($refundedMock)); + $this->observer->execute(); + } + + /** + * Set up aggregate + * + * @return \Magento\Framework\Stdlib\DateTime\DateInterface + */ + protected function setupAggregate() + { + $date = $this->getMock('Magento\Framework\Stdlib\DateTime\Date', ['emulate', 'revert'], [], '', false); + $this->localeResolverMock->expects($this->once()) + ->method('emulate') + ->with(0); + $this->localeResolverMock->expects($this->once()) + ->method('revert'); + $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') + ->disableOriginalConstructor() + ->getMock(); + $dateMock->expects($this->once()) + ->method('subHour') + ->with(25) + ->will($this->returnValue($date)); + $this->localeDateMock->expects($this->once()) + ->method('date') + ->will($this->returnValue($dateMock)); + return $date; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/CustomerQuoteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/CustomerQuoteTest.php index 72d4e4d69971aebbf40f496266915d44e707905b..a95b40b74f30a50d420b7e437e79ff2bd5e54151 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/CustomerQuoteTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/CustomerQuoteTest.php @@ -31,7 +31,7 @@ class CustomerQuoteTest extends \PHPUnit_Framework_TestCase protected $customerQuote; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -57,7 +57,7 @@ class CustomerQuoteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMock(); $this->configMock = $this->getMockBuilder('Magento\Customer\Model\Config\Share') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/CleanExpiredQuotesTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/CleanExpiredQuotesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b436927742bff7a582507bbed86e03ecb26cebfa --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/CleanExpiredQuotesTest.php @@ -0,0 +1,95 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\CleanExpiredQuotes + */ +class CleanExpiredQuotesTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Store\Model\StoresConfig|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storesConfigMock; + + /** + * @var \Magento\Sales\Model\Resource\Quote\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\CleanExpiredQuotes + */ + protected $observer; + + protected function setUp() + { + $this->storesConfigMock = $this->getMock('Magento\Store\Model\StoresConfig', [], [], '', false); + + $this->quoteFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Quote\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->observer = new CleanExpiredQuotes($this->storesConfigMock, $this->quoteFactoryMock); + } + + /** + * @param array $lifetimes + * @param array $additionalFilterFields + * @dataProvider cleanExpiredQuotesDataProvider + */ + public function testExecute($lifetimes, $additionalFilterFields) + { + $this->storesConfigMock->expects($this->once()) + ->method('getStoresConfigByPath') + ->with($this->equalTo('checkout/cart/delete_quote_after')) + ->will($this->returnValue($lifetimes)); + + $quotesMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Quote\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->quoteFactoryMock->expects($this->exactly(count($lifetimes))) + ->method('create') + ->will($this->returnValue($quotesMock)); + $quotesMock->expects($this->exactly((3 + count($additionalFilterFields)) * count($lifetimes))) + ->method('addFieldToFilter'); + if (!empty($lifetimes)) { + $quotesMock->expects($this->exactly(count($lifetimes))) + ->method('walk') + ->with('delete'); + } + $this->observer->setExpireQuotesAdditionalFilterFields($additionalFilterFields); + $this->observer->execute(); + } + + public function cleanExpiredQuotesDataProvider() + { + return [ + [[], []], + [[1 => 100, 2 => 200], []], + [[1 => 100, 2 => 200], ['field1' => 'condition1', 'field2' => 'condition2']], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderCommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderCommentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c6d91b96e0bc537a09c7b7b093d3c57a73b71a85 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderCommentTest.php @@ -0,0 +1,141 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer\Frontend\Quote; + +/** + * Tests Magento\Sales\Model\Observer\Frontend\Quote\AddVatRequestParamsOrderComment + */ +class AddVatRequestParamsOrderCommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerAddressHelperMock; + + /** + * @var AddVatRequestParamsOrderComment + */ + protected $observer; + + protected function setUp() + { + $this->customerAddressHelperMock = $this->getMockBuilder('Magento\Customer\Helper\Address') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AddVatRequestParamsOrderComment( + $this->customerAddressHelperMock + ); + } + + /** + * @param string $configAddressType + * @param string|int $vatRequestId + * @param string|int $vatRequestDate + * @param string $orderHistoryComment + * @dataProvider addVatRequestParamsOrderCommentDataProvider + */ + public function testAddVatRequestParamsOrderComment( + $configAddressType, + $vatRequestId, + $vatRequestDate, + $orderHistoryComment + ) { + $this->customerAddressHelperMock->expects($this->once()) + ->method('getTaxCalculationAddressType') + ->will($this->returnValue($configAddressType)); + + $orderAddressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + ['getVatRequestId', 'getVatRequestDate', '__wakeup'], + [], + '', + false + ); + $orderAddressMock->expects($this->any()) + ->method('getVatRequestId') + ->will($this->returnValue($vatRequestId)); + $orderAddressMock->expects($this->any()) + ->method('getVatRequestDate') + ->will($this->returnValue($vatRequestDate)); + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['getShippingAddress', '__wakeup', 'addStatusHistoryComment', 'getBillingAddress']) + ->getMock(); + $orderMock->expects($this->any()) + ->method('getShippingAddress') + ->will($this->returnValue($orderAddressMock)); + if (is_null($orderHistoryComment)) { + $orderMock->expects($this->never()) + ->method('addStatusHistoryComment'); + } else { + $orderMock->expects($this->once()) + ->method('addStatusHistoryComment') + ->with($orderHistoryComment, false); + } + $observer = $this->getMock('Magento\Framework\Event\Observer', ['getOrder'], [], '', false); + $observer->expects($this->once()) + ->method('getOrder') + ->will($this->returnValue($orderMock)); + + $this->assertNull($this->observer->execute($observer)); + } + + public function addVatRequestParamsOrderCommentDataProvider() + { + return [ + [ + \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, + 'vatRequestId', + 'vatRequestDate', + 'VAT Request Identifier: vatRequestId<br />VAT Request Date: vatRequestDate', + ], + [ + \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, + 1, + 'vatRequestDate', + null, + ], + [ + \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, + 'vatRequestId', + 1, + null, + ], + [ + null, + 'vatRequestId', + 'vatRequestDate', + null, + ], + [ + \Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING, + 'vatRequestId', + 'vatRequestDate', + null, + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupIdTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupIdTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b927acfbda0830d418357ed0d5b779ed93be6d5c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupIdTest.php @@ -0,0 +1,94 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer\Frontend\Quote; + +/** + * Tests Magento\Sales\Model\Observer\Frontend\Quote\RestoreCustomerGroupIdTest + */ +class RestoreCustomerGroupIdTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerAddressHelperMock; + + /** + * @var RestoreCustomerGroupId + */ + protected $quote; + + protected function setUp() + { + $this->customerAddressHelperMock = $this->getMockBuilder('Magento\Customer\Helper\Address') + ->disableOriginalConstructor() + ->getMock(); + + $this->quote = new RestoreCustomerGroupId( + $this->customerAddressHelperMock + ); + } + + /** + * @param string|null $configAddressType + * @dataProvider restoreCustomerGroupIdDataProvider + */ + public function testExecute($configAddressType) + { + $quoteAddress = $this->getMock( + 'Magento\Sales\Model\Quote\Address', + [ + 'getQuote', 'setCustomerGroupId', 'getPrevQuoteCustomerGroupId', + 'unsPrevQuoteCustomerGroupId', 'hasPrevQuoteCustomerGroupId' + ], + [], + '', + false + ); + $observer = $this->getMock('Magento\Framework\Event\Observer', ['getQuoteAddress'], [], '', false); + $observer->expects($this->once()) + ->method('getQuoteAddress') + ->will($this->returnValue($quoteAddress)); + + $this->customerAddressHelperMock->expects($this->once()) + ->method('getTaxCalculationAddressType') + ->will($this->returnValue($configAddressType)); + + $quoteAddress->expects($this->once())->method('hasPrevQuoteCustomerGroupId'); + $id = $quoteAddress->expects($this->any())->method('getPrevQuoteCustomerGroupId'); + $quoteAddress->expects($this->any())->method('setCustomerGroupId')->with($id); + $quoteAddress->expects($this->any())->method('getQuote'); + $quoteAddress->expects($this->any())->method('unsPrevQuoteCustomerGroupId'); + + $this->assertNull($this->quote->execute($observer)); + } + + public function restoreCustomerGroupIdDataProvider() + { + return [ + [\Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING], + [null], + [\Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/ObserverTest.php deleted file mode 100644 index 535c1d78381a79f3a13d85b493f69ccfcb821626..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/ObserverTest.php +++ /dev/null @@ -1,456 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Model; - -use Magento\Framework\Object; -use Magento\TestFramework\Helper\ObjectManager; -use Magento\Sales\Model\Quote\Address; - -/** - * Tests Magento\Sales\Model\Observer - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class ObserverTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $eventManagerMock; - - /** - * @var \Magento\Store\Model\StoresConfig|\PHPUnit_Framework_MockObject_MockObject - */ - protected $storesConfigMock; - - /** - * @var \Magento\Sales\Model\Resource\Quote\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteFactoryMock; - - /** - * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $localeResolverMock; - - /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $localeDateMock; - - /** - * @var \Magento\Sales\Model\Resource\Report\OrderFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $orderFactoryMock; - - /** - * @var \Magento\Sales\Model\Resource\Report\InvoicedFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $invoiceFactoryMock; - - /** - * @var \Magento\Sales\Model\Resource\Report\RefundedFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $refundedFactoryMock; - - /** - * @var \Magento\Sales\Model\Resource\Report\BestsellersFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $bestsellersFactoryMock; - - /** - * @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject - */ - protected $catalogDataMock; - - /** - * @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject - */ - protected $customerAddressHelperMock; - - /** - * @var \Magento\Sales\Model\Observer - */ - protected $observer; - - protected function setUp() - { - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->storesConfigMock = $this->getMockBuilder('Magento\Store\Model\StoresConfig') - ->disableOriginalConstructor() - ->getMock(); - $this->quoteFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Quote\CollectionFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\OrderFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->invoiceFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\InvoicedFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->refundedFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\RefundedFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->bestsellersFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\BestsellersFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->catalogDataMock = $this->getMockBuilder('Magento\Catalog\Helper\Data') - ->disableOriginalConstructor() - ->getMock(); - $this->customerAddressHelperMock = $this->getMockBuilder('Magento\Customer\Helper\Address') - ->disableOriginalConstructor() - ->getMock(); - $this->observer = (new ObjectManager($this)) - ->getObject( - 'Magento\Sales\Model\Observer', - [ - 'eventManager' => $this->eventManagerMock, - 'storesConfig' => $this->storesConfigMock, - 'quoteFactory' => $this->quoteFactoryMock, - 'localeDate' => $this->localeDateMock, - 'localeResolver' => $this->localeResolverMock, - 'orderFactory' => $this->orderFactoryMock, - 'invoicedFactory' => $this->invoiceFactoryMock, - 'refundedFactory' => $this->refundedFactoryMock, - 'bestsellersFactory' => $this->bestsellersFactoryMock, - 'catalogData' => $this->catalogDataMock, - 'customerAddressHelper' => $this->customerAddressHelperMock, - ] - ); - } - - /** - * @param array $lifetimes - * @param array $additionalFilterFields - * @dataProvider cleanExpiredQuotesDataProvider - */ - public function testCleanExpiredQuotes($lifetimes, $additionalFilterFields) - { - $this->eventManagerMock->expects($this->once()) - ->method('dispatch'); - $this->storesConfigMock->expects($this->once()) - ->method('getStoresConfigByPath') - ->will($this->returnValue($lifetimes)); - $quotesMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Quote\Collection') - ->disableOriginalConstructor() - ->getMock(); - $this->quoteFactoryMock->expects($this->exactly(count($lifetimes))) - ->method('create') - ->will($this->returnValue($quotesMock)); - $quotesMock->expects($this->exactly((3 + count($additionalFilterFields)) * count($lifetimes))) - ->method('addFieldToFilter'); - if (!empty($lifetimes)) { - $quotesMock->expects($this->exactly(count($lifetimes))) - ->method('walk') - ->with('delete'); - } - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->setExpireQuotesAdditionalFilterFields($additionalFilterFields); - $this->observer->cleanExpiredQuotes($schedule); - } - - public function cleanExpiredQuotesDataProvider() - { - return [ - [[], []], - [[1 => 100, 2 => 200], []], - [[1 => 100, 2 => 200], ['field1' => 'condition1', 'field2' => 'condition2']], - ]; - } - - public function testAggregateSalesReportOrderData() - { - $date = $this->setupAggregate(); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Order') - ->disableOriginalConstructor() - ->getMock(); - $orderMock->expects($this->once()) - ->method('aggregate') - ->with($date); - $this->orderFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($orderMock)); - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->aggregateSalesReportOrderData($schedule); - } - - public function testAggregateSalesReportInvoicedData() - { - $date = $this->setupAggregate(); - $invoicedMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Invoiced') - ->disableOriginalConstructor() - ->getMock(); - $invoicedMock->expects($this->once()) - ->method('aggregate') - ->with($date); - $this->invoiceFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($invoicedMock)); - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->aggregateSalesReportInvoicedData($schedule); - } - - public function testAggregateSalesReportRefundedData() - { - $date = $this->setupAggregate(); - $refundedMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Refunded') - ->disableOriginalConstructor() - ->getMock(); - $refundedMock->expects($this->once()) - ->method('aggregate') - ->with($date); - $this->refundedFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($refundedMock)); - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->aggregateSalesReportRefundedData($schedule); - } - - public function testAggregateSalesReportBestsellersData() - { - $date = $this->setupAggregate(); - $bestsellersMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Bestsellers') - ->disableOriginalConstructor() - ->getMock(); - $bestsellersMock->expects($this->once()) - ->method('aggregate') - ->with($date); - $this->bestsellersFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($bestsellersMock)); - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->aggregateSalesReportBestsellersData($schedule); - } - /** - * Set up aggregate - * - * @return \Magento\Framework\Stdlib\DateTime\DateInterface - */ - protected function setupAggregate() - { - $date = (new ObjectManager($this))->getObject('Magento\Framework\Stdlib\DateTime\Date'); - $this->localeResolverMock->expects($this->once()) - ->method('emulate') - ->with(0); - $this->localeResolverMock->expects($this->once()) - ->method('revert'); - $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') - ->disableOriginalConstructor() - ->getMock(); - $dateMock->expects($this->once()) - ->method('subHour') - ->with(25) - ->will($this->returnValue($date)); - $this->localeDateMock->expects($this->once()) - ->method('date') - ->will($this->returnValue($dateMock)); - return $date; - } - - /** - * @param bool $isMsrpEnabled - * @param bool $canApplyMsrp - * @dataProvider setQuoteCanApplyMsrpDataProvider - */ - public function testSetQuoteCanApplyMsrp($isMsrpEnabled, $canApplyMsrp) - { - $eventMock = $this->getMockBuilder('Magento\Framework\Event') - ->disableOriginalConstructor() - ->setMethods(['getQuote']) - ->getMock(); - $quoteMock = $this->getMockBuilder('Magento\Sales\Model\Quote') - ->disableOriginalConstructor() - ->setMethods(['__wakeup', 'setCanApplyMsrp', 'getAllAddresses']) - ->getMock(); - $observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') - ->disableOriginalConstructor() - ->getMock(); - $observerMock->expects($this->once()) - ->method('getEvent') - ->will($this->returnValue($eventMock)); - $eventMock->expects($this->once()) - ->method('getQuote') - ->will($this->returnValue($quoteMock)); - $this->catalogDataMock->expects($this->once()) - ->method('isMsrpEnabled') - ->will($this->returnValue($isMsrpEnabled)); - $quoteMock->expects($this->once()) - ->method('setCanApplyMsrp') - ->with($canApplyMsrp); - $addressMock1 = $this->getMockBuilder('Magento\Customer\Model\Address\AbstractAddress') - ->disableOriginalConstructor() - ->setMethods(['__wakeup']) - ->getMockForAbstractClass(); - $addressMock1->setCanApplyMsrp($canApplyMsrp); - $addressMock2 = $this->getMockBuilder('Magento\Customer\Model\Address\AbstractAddress') - ->disableOriginalConstructor() - ->setMethods(['__wakeup']) - ->getMockForAbstractClass(); - $addressMock2->setCanApplyMsrp(false); - $quoteMock->expects($this->any()) - ->method('getAllAddresses') - ->will($this->returnValue([$addressMock1, $addressMock2])); - $this->observer->setQuoteCanApplyMsrp($observerMock); - } - - public function setQuoteCanApplyMsrpDataProvider() - { - return [ - [false, false], - [true, true], - [true, false] - ]; - } - - /** - * @param string $configAddressType - * @param string|int $vatRequestId - * @param string|int $vatRequestDate - * @param string $orderHistoryComment - * @dataProvider addVatRequestParamsOrderCommentDataProvider - */ - public function testAddVatRequestParamsOrderComment( - $configAddressType, - $vatRequestId, - $vatRequestDate, - $orderHistoryComment - ) { - $this->customerAddressHelperMock->expects($this->once()) - ->method('getTaxCalculationAddressType') - ->will($this->returnValue($configAddressType)); - $objectManager = new ObjectManager($this); - $orderAddressMock = $objectManager->getObject('Magento\Sales\Model\Order\Address'); - $orderAddressMock->setVatRequestId($vatRequestId); - $orderAddressMock->setVatRequestDate($vatRequestDate); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') - ->disableOriginalConstructor() - ->getMock(); - $orderMock->expects($this->any()) - ->method('getShippingAddress') - ->will($this->returnValue($orderAddressMock)); - if (is_null($orderHistoryComment)) { - $orderMock->expects($this->never()) - ->method('addStatusHistoryComment'); - } else { - $orderMock->expects($this->once()) - ->method('addStatusHistoryComment') - ->with($orderHistoryComment, false); - } - $observer = $objectManager->getObject('Magento\Framework\Event\Observer'); - $observer->setOrder($orderMock); - $this->observer->addVatRequestParamsOrderComment($observer); - - } - - public function addVatRequestParamsOrderCommentDataProvider() - { - return [ - [ - \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, - 'vatRequestId', - 'vatRequestDate', - 'VAT Request Identifier: vatRequestId<br />VAT Request Date: vatRequestDate', - ], - [ - \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, - 1, - 'vatRequestDate', - null, - ], - [ - \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, - 'vatRequestId', - 1, - null, - ], - [ - null, - 'vatRequestId', - 'vatRequestDate', - null, - ], - [ - \Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING, - 'vatRequestId', - 'vatRequestDate', - null, - ], - ]; - } - /** - * @param string $configAddressType - * @param int $groupId - * @param int $expectedPrevGroupId - * @param int $expectedGroupId - * @dataProvider restoreQuoteCustomerGroupIdDataProvider - */ - public function testRestoreQuoteCustomerGroupId( - $configAddressType, - $groupId, - $expectedPrevGroupId, - $expectedGroupId - ) { - $quote = (new ObjectManager($this))->getObject('Magento\Sales\Model\Quote'); - $quoteAddress = (new ObjectManager($this))->getObject('Magento\Sales\Model\Quote\Address'); - $quoteAddress->setQuote($quote); - if (!empty($groupId)) { - $quoteAddress->setPrevQuoteCustomerGroupId($groupId); - } - $observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') - ->disableOriginalConstructor() - ->setMethods(['getQuoteAddress']) - ->getMock(); - $observerMock->expects($this->once()) - ->method('getQuoteAddress') - ->will($this->returnValue($quoteAddress)); - $this->customerAddressHelperMock->expects($this->once()) - ->method('getTaxCalculationAddressType') - ->will($this->returnValue($configAddressType)); - $this->observer->restoreQuoteCustomerGroupId($observerMock); - $this->assertEquals($expectedGroupId, $quote->getCustomerGroupId()); - $this->assertEquals($expectedPrevGroupId, $quoteAddress->getPrevQuoteCustomerGroupId()); - } - - public function restoreQuoteCustomerGroupIdDataProvider() - { - return [ - [\Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, 1, null, 1], - [\Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, null, null, null], - [\Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING, 1, 1, null], - ]; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php index 9839f9c0af000dd97999b0bc51956866beafc674..fc57a081e336b7ff02352794d7f7a64f1f79ce98 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php @@ -67,7 +67,7 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase false ), 'calculatorFactory' => $this->getMock('Magento\Framework\Math\CalculatorFactory', [], [], '', false), - 'storeManager' => $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false), + 'storeManager' => $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false), 'commentFactory' => $this->getMock( 'Magento\Sales\Model\Order\Creditmemo\CommentFactory', [], @@ -141,4 +141,10 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase $this->creditmemo->setGrandTotal(1); $this->assertTrue($this->creditmemo->isValidGrandTotal()); } + + public function testGetIncrementId() + { + $this->creditmemo->setIncrementId('test_increment_id'); + $this->assertEquals('test_increment_id', $this->creditmemo->getIncrementId()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php index 7271f5739cf1d75412eac7aca1d561bfc7e73045..8d970d516433f64c96c669c49ab054631fc79892 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php @@ -171,4 +171,10 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('invoice', $this->model->getEntityType()); } + + public function testGetIncrementId() + { + $this->model->setIncrementId('test_increment_id'); + $this->assertEquals('test_increment_id', $this->model->getIncrementId()); + } } diff --git a/app/code/Magento/Install/Controller/Wizard/Begin.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/ShipmentTest.php similarity index 60% rename from app/code/Magento/Install/Controller/Wizard/Begin.php rename to dev/tests/unit/testsuite/Magento/Sales/Model/Order/ShipmentTest.php index d1a03dad1d700db0e51fc9a8f6f4fae819c6800d..249669c7988e1ede00833c08f3c51537f116b1d1 100644 --- a/app/code/Magento/Install/Controller/Wizard/Begin.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/ShipmentTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,27 +21,25 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; +namespace Magento\Sales\Model\Order; -class Begin extends \Magento\Install\Controller\Wizard +class ShipmentTest extends \PHPUnit_Framework_TestCase { /** - * Begin installation action - * - * @return void + * @var \Magento\Sales\Model\Order\shipment */ - public function execute() - { - $this->_checkIfInstalled(); - - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); + protected $shipmentModel; - $this->_view->getLayout()->addBlock('Magento\Install\Block\Begin', 'install.begin', 'content'); + protected function setUp() + { + $helperManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $arguments = []; + $this->shipmentModel = $helperManager->getObject('Magento\Sales\Model\Order\shipment', $arguments); + } - $this->_view->renderLayout(); + public function testGetIncrementId() + { + $this->shipmentModel->setIncrementId('test_increment_id'); + $this->assertEquals('test_increment_id', $this->shipmentModel->getIncrementId()); } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php index d4bd6704053d9682236ed766ff8d2e83a3a1728c..2fa3a6d37f9a4f2ce990ad144fdcf183a69844dc 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php @@ -21,13 +21,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Sales\Model; /** * Test class for \Magento\Sales\Model\Order - * - * @package Magento\Sales\Model */ class OrderTest extends \PHPUnit_Framework_TestCase { @@ -46,6 +43,11 @@ class OrderTest extends \PHPUnit_Framework_TestCase */ protected $order; + /** + * @var string + */ + protected $incrementId; + protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -63,12 +65,13 @@ class OrderTest extends \PHPUnit_Framework_TestCase '', false ); - + $this->incrementId = '#00000001'; $this->order = $helper->getObject( 'Magento\Sales\Model\Order', [ 'paymentCollectionFactory' => $this->paymentCollectionFactoryMock, - 'orderItemCollectionFactory' => $this->orderItemCollectionFactoryMock + 'orderItemCollectionFactory' => $this->orderItemCollectionFactoryMock, + 'data' => ['increment_id' => $this->incrementId] ] ); } @@ -99,7 +102,6 @@ class OrderTest extends \PHPUnit_Framework_TestCase $paymentMock->expects($this->any()) ->method('canFetchTransactionInfo') ->will($this->returnValue(true)); - $this->preparePaymentMock($paymentMock); $this->order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_UNHOLD, false); $this->order->setState(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW); @@ -357,6 +359,14 @@ class OrderTest extends \PHPUnit_Framework_TestCase ]; } + /** + * test method getIncrementId() + */ + public function testGetIncrementId() + { + $this->assertEquals($this->incrementId, $this->order->getIncrementId()); + } + public function testGetEntityType() { $this->assertEquals('order', $this->order->getEntityType()); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/ProcessorTest.php index 6558883fbb5e736bd5394d99cb5cf75354b668a0..591a6416c36ca1033f58d2cd266d421de2ff1502 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/ProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/ProcessorTest.php @@ -26,7 +26,7 @@ namespace Magento\Sales\Model\Quote\Item; use \Magento\Catalog\Model\Product; use \Magento\Sales\Model\Quote\ItemFactory; use \Magento\Sales\Model\Quote\Item; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Store\Model\Store; use \Magento\Framework\App\State; use \Magento\Framework\Object; diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteRepositoryTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteRepositoryTest.php index c5dce844e9d98ccc3bb605849b8da5d9c87ad85f..3950ab01ec86b47ef17744bc7c37d1bf73a97fa5 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteRepositoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteRepositoryTest.php @@ -57,7 +57,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteFactoryMock = $this->getMock('\Magento\Sales\Model\QuoteFactory', ['create'], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->quoteMock = $this->getMock('\Magento\Sales\Model\Quote', ['load', 'getIsActive', 'getId', '__wakeup'], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/AttributeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2740edef88b9fd85246dd7d28b39cf8f57d55460 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/AttributeTest.php @@ -0,0 +1,170 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource; + +/** + * Class AttributeTest + */ +class AttributeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + protected $attribute; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + /** + * @var \Magento\Sales\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject + */ + protected $modelMock; + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId', 'getEventPrefix', 'getEventObject'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['describeTable', 'insert', 'lastInsertId', 'beginTransaction', 'rollback', 'commit'], + [], + '', + false + ); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('insert'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + $this->attribute = new \Magento\Sales\Model\Resource\Attribute( + $this->appResourceMock, + $this->eventManagerMock + ); + } + + /** + * @throws \Exception + */ + public function testSave() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->modelMock->expects($this->any()) + ->method('getEventPrefix') + ->will($this->returnValue('event_prefix')); + $this->modelMock->expects($this->any()) + ->method('getEventObject') + ->will($this->returnValue('event_object')); + $this->eventManagerMock->expects($this->at(0)) + ->method('dispatch') + ->with('event_prefix_save_attribute_before', [ + 'event_object' => $this->attribute, + 'object' => $this->modelMock, + 'attribute' => ['attribute'] + ]); + $this->eventManagerMock->expects($this->at(1)) + ->method('dispatch') + ->with('event_prefix_save_attribute_after', [ + 'event_object' => $this->attribute, + 'object' => $this->modelMock, + 'attribute' => ['attribute'] + ]); + $this->adapterMock->expects($this->once()) + ->method('beginTransaction'); + $this->adapterMock->expects($this->once()) + ->method('commit'); + $this->assertEquals($this->attribute, $this->attribute->saveAttribute($this->modelMock, 'attribute')); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Expected Exception + * @throws \Exception + */ + public function testSaveFailed() + { + $this->modelMock->expects($this->any()) + ->method('getEventPrefix') + ->will($this->returnValue('event_prefix')); + $this->modelMock->expects($this->any()) + ->method('getEventObject') + ->will($this->returnValue('event_object')); + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $exception = new \Exception('Expected Exception'); + $this->modelMock->expects($this->any()) + ->method('getId') + ->will($this->throwException($exception )); + $this->adapterMock->expects($this->once()) + ->method('beginTransaction'); + $this->adapterMock->expects($this->once()) + ->method('rollback'); + $this->eventManagerMock->expects($this->once()) + ->method('dispatch') + ->with( + 'event_prefix_save_attribute_before', + [ + 'event_object' => $this->attribute, + 'object' => $this->modelMock, + 'attribute' => ['attribute'] + ] + ); + $this->attribute->saveAttribute($this->modelMock, 'attribute'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/GridPoolTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/GridPoolTest.php new file mode 100644 index 0000000000000000000000000000000000000000..650848560f16b503618963b345f5a4816d31203e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/GridPoolTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource; + +/** + * Class GridPoolTest + */ +class GridPoolTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\GridPool + */ + protected $gridPool; + /** + * @var \Magento\Sales\Model\Resource\Order\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderGridMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Invoice\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceGridMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Shipment\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentGridMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Creditmemo\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoGridMock; + /** + * @var \Zend_Db_Statement_Interface + */ + protected $statementMock; + + /** + * Prepare mock objects + */ + public function setUp() + { + $this->orderGridMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Grid', [], [], '', false + ); + $this->invoiceGridMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Invoice\Grid', [], [], '', false + ); + $this->shipmentGridMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Shipment\Grid', [], [], '', false + ); + $this->creditmemoGridMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Creditmemo\Grid', [], [], '', false + ); + $this->statementMock = $this->getMockForAbstractClass('Zend_Db_Statement_Interface'); + $this->gridPool = new \Magento\Sales\Model\Resource\GridPool( + $this->orderGridMock, $this->invoiceGridMock, $this->shipmentGridMock, $this->creditmemoGridMock + ); + } + + /** + * Test method refreshByOrderId() + */ + public function testRefreshByOrderId() + { + $orderId = 1; + $this->orderGridMock->expects($this->once()) + ->method('refresh') + ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) + ->will($this->returnValue($this->statementMock)); + $this->invoiceGridMock->expects($this->once()) + ->method('refresh') + ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) + ->will($this->returnValue($this->statementMock)); + $this->shipmentGridMock->expects($this->once()) + ->method('refresh') + ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) + ->will($this->returnValue($this->statementMock)); + $this->creditmemoGridMock->expects($this->once()) + ->method('refresh') + ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) + ->will($this->returnValue($this->statementMock)); + $this->assertEquals($this->gridPool, $this->gridPool->refreshByOrderId($orderId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php index f7e827e77ad9292e6f367a99a870a898054b609f..9f671e07b896933ed8e3ab879fb07a38fd5af531 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php @@ -54,13 +54,15 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected $validatorMock; /** - * Set up + * @var \Magento\Sales\Model\Resource\GridPool|\PHPUnit_Framework_MockObject_MockObject */ + protected $gridPoolMock; + public function setUp() { $this->addressMock = $this->getMock( 'Magento\Sales\Model\Order\Address', - [], + ['__wakeup', 'getOrderId', 'hasDataChanges'], [], '', false @@ -86,6 +88,13 @@ class AddressTest extends \PHPUnit_Framework_TestCase '', false ); + $this->gridPoolMock = $this->getMock( + 'Magento\Sales\Model\Resource\GridPool', + ['refreshByOrderId'], + [], + '', + false + ); $this->appResourceMock->expects($this->any()) ->method('getConnection') ->will($this->returnValue($this->adapterMock)); @@ -101,7 +110,8 @@ class AddressTest extends \PHPUnit_Framework_TestCase 'Magento\Sales\Model\Resource\Order\Address', [ 'resource' => $this->appResourceMock, - 'validator' => $this->validatorMock + 'validator' => $this->validatorMock, + 'gridPool' => $this->gridPoolMock ] ); } @@ -115,6 +125,17 @@ class AddressTest extends \PHPUnit_Framework_TestCase ->method('validate') ->with($this->equalTo($this->addressMock)) ->will($this->returnValue([])); + $this->addressMock->expects($this->once()) + ->method('hasDataChanges') + ->will($this->returnValue(true)); + $this->addressMock->expects($this->exactly(2)) + ->method('getOrderId') + ->will($this->returnValue(2)); + $this->gridPoolMock->expects($this->once()) + ->method('refreshByOrderId') + ->with($this->equalTo(2)) + ->will($this->returnSelf()); + $this->addressResource->save($this->addressMock); $this->assertTrue(true); } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php new file mode 100644 index 0000000000000000000000000000000000000000..de530ce459e0cf67deccd43ca8f1a975c53804a7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php @@ -0,0 +1,169 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Creditmemo; + +/** + * Class GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Creditmemo\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $grid; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statementMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['select', 'query', 'insertFromSelect', 'delete'], + [], + '', + false + ); + $this->selectMock = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->statementMock = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false, + false, + true, + [] + ); + $this->grid = new \Magento\Sales\Model\Resource\Order\Creditmemo\Grid( + $this->appResourceMock + ); + } + + /** + * Test refresh method + */ + public function testRefresh() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_creditmemo_grid')); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->selectMock->expects($this->once()) + ->method('from') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('join') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('joinLeft') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('columns') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('where') + ->with('fi.field = ?', 1, null) + ->will($this->returnSelf()); + $this->adapterMock->expects($this->once()) + ->method('query') + ->with('sql-query') + ->will($this->returnValue($this->statementMock)); + $this->adapterMock->expects($this->once()) + ->method('insertFromSelect') + ->with($this->selectMock, 'sales_flat_creditmemo_grid', [], 1) + ->will($this->returnValue('sql-query')); + $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); + } + + /** + * Test purge method + */ + public function testPurge() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_creditmemo_grid')); + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with('sales_flat_creditmemo_grid', ['fi.field = ?' => 1]) + ->will($this->returnValue(1)); + $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php new file mode 100644 index 0000000000000000000000000000000000000000..cc1f2f4b5583e6e227fbd41d6885e5e17cf7dc41 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php @@ -0,0 +1,166 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order; + +/** + * Class GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $grid; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statementMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['select', 'query', 'insertFromSelect', 'delete'], + [], + '', + false + ); + $this->selectMock = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->statementMock = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false, + false, + true, + [] + ); + $this->grid = new \Magento\Sales\Model\Resource\Order\Grid( + $this->appResourceMock + ); + } + + /** + * Test refresh method + */ + public function testRefresh() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_order_grid')); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->selectMock->expects($this->once()) + ->method('from') + ->will($this->returnSelf()); + $this->selectMock->expects($this->exactly(2)) + ->method('joinLeft') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('columns') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('where') + ->with('fi.field = ?', 1, null) + ->will($this->returnSelf()); + $this->adapterMock->expects($this->once()) + ->method('query') + ->with('sql-query') + ->will($this->returnValue($this->statementMock)); + $this->adapterMock->expects($this->once()) + ->method('insertFromSelect') + ->with($this->selectMock, 'sales_flat_order_grid', [], 1) + ->will($this->returnValue('sql-query')); + $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); + } + + /** + * Test purge method + */ + public function testPurge() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_order_grid')); + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with('sales_flat_order_grid', ['fi.field = ?' => 1]) + ->will($this->returnValue(1)); + $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/AddressTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/AddressTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b91634f1cc8efa51ddbfc3d597d4c4fa259a4e1f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/AddressTest.php @@ -0,0 +1,189 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Handler; + +/** + * Class AddressTest + */ +class AddressTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Handler\Address + */ + protected $address; + /** + * @var \Magento\Sales\Model\Resource\Order\Address\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressCollectionMock; + /** + * @var \Magento\Sales\Model\Resource\Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + protected $attributeMock; + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + /** + * @var \Magento\Sales\Model\Order\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressMock; + + public function setUp() + { + $this->attributeMock = $this->getMock( + 'Magento\Sales\Model\Resource\Attribute', + [], + [], + '', + false + ); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [ + '__wakeup', + 'getAddressesCollection', + 'save', + 'getBillingAddress', + 'getShippingAddress', + 'hasBillingAddressId', + 'getBillingAddressId', + 'setBillingAddressId', + 'unsBillingAddressId', + 'hasShippingAddressId', + 'getShippingAddressId', + 'setShippingAddressId', + 'unsShippingAddressId' + ], + [], + '', + false + ); + $this->addressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + [], + [], + '', + false + ); + $this->addressCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Address\Collection', + [], + [], + '', + false + ); + $this->address = new \Magento\Sales\Model\Resource\Order\Handler\Address( + $this->attributeMock + ); + } + + /** + * Test process method with billing_address + */ + public function testProcessBillingAddress() + { + $this->orderMock->expects($this->exactly(2)) + ->method('getAddressesCollection') + ->will($this->returnValue($this->addressCollectionMock)); + $this->addressCollectionMock->expects($this->once()) + ->method('save') + ->will($this->returnSelf()); + $this->orderMock->expects($this->once()) + ->method('getBillingAddress') + ->will($this->returnValue($this->addressMock)); + $this->addressMock->expects($this->exactly(2)) + ->method('getId') + ->will($this->returnValue(2)); + $this->orderMock->expects($this->once()) + ->method('getBillingAddressId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('setBillingAddressId') + ->will($this->returnSelf()); + $this->orderMock->expects($this->once()) + ->method('getShippingAddress') + ->will($this->returnValue(null)); + $this->attributeMock->expects($this->once()) + ->method('saveAttribute') + ->with($this->orderMock, ['billing_address_id']) + ->will($this->returnSelf()); + $this->assertEquals($this->address, $this->address->process($this->orderMock)); + } + + /** + * Test process method with shipping_address + */ + public function testProcessShippingAddress() + { + $this->orderMock->expects($this->exactly(2)) + ->method('getAddressesCollection') + ->will($this->returnValue($this->addressCollectionMock)); + $this->addressCollectionMock->expects($this->once()) + ->method('save') + ->will($this->returnSelf()); + $this->orderMock->expects($this->once()) + ->method('getBillingAddress') + ->will($this->returnValue(null)); + $this->orderMock->expects($this->once()) + ->method('getShippingAddress') + ->will($this->returnValue($this->addressMock)); + $this->addressMock->expects($this->exactly(2)) + ->method('getId') + ->will($this->returnValue(2)); + $this->orderMock->expects($this->once()) + ->method('setShippingAddressId') + ->will($this->returnSelf()); + $this->attributeMock->expects($this->once()) + ->method('saveAttribute') + ->with($this->orderMock, ['shipping_address_id']) + ->will($this->returnSelf()); + $this->assertEquals($this->address, $this->address->process($this->orderMock)); + } + + /** + * Test method removeEmptyAddresses + */ + public function testRemoveEmptyAddresses() + { + $this->orderMock->expects($this->once()) + ->method('hasBillingAddressId') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getBillingAddressId') + ->will($this->returnValue(null)); + $this->orderMock->expects($this->once()) + ->method('unsBillingAddressId') + ->will($this->returnSelf()); + $this->orderMock->expects($this->once()) + ->method('hasShippingAddressId') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getShippingAddressId') + ->will($this->returnValue(null)); + $this->orderMock->expects($this->once()) + ->method('unsShippingAddressId') + ->will($this->returnSelf()); + $this->assertEquals($this->address, $this->address->removeEmptyAddresses($this->orderMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/StateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/StateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..513ca8998fb0905c681c8aefb902b8edc79c5419 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/StateTest.php @@ -0,0 +1,223 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Handler; + +use Magento\Sales\Model\Order; + +/** + * Class StateTest + */ +class StateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Handler\State + */ + protected $state; + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + public function setUp() + { + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [ + '__wakeup', + 'getId', + 'hasCustomerNoteNotify', + 'getCustomerNoteNotify', + 'isCanceled', + 'canUnhold', + 'canInvoice', + 'canShip', + 'getBaseGrandTotal', + 'canCreditmemo', + 'getState', + 'setState', + 'getTotalRefunded', + 'hasForcedCanCreditmemo', + 'getIsInProcess' + ], + [], + '', + false + ); + $this->addressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + [], + [], + '', + false + ); + $this->addressCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Address\Collection', + [], + [], + '', + false + ); + $this->state = new \Magento\Sales\Model\Resource\Order\Handler\State(); + } + + /** + * test check order - order without id + */ + public function testCheckOrderEmpty() + { + $this->orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(null)); + $this->assertEquals($this->orderMock, $this->state->check($this->orderMock)); + } + + /** + * test check order - set state complete + */ + public function testCheckSetStateComplete() + { + $this->orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('hasCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('isCanceled') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canUnhold') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canInvoice') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canShip') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->will($this->returnValue(100)); + $this->orderMock->expects($this->once()) + ->method('canCreditmemo') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->exactly(2)) + ->method('getState') + ->will($this->returnValue(Order::STATE_PROCESSING)); + $this->orderMock->expects($this->once()) + ->method('setState') + ->with(Order::STATE_COMPLETE, true, '', true) + ->will($this->returnSelf()); + $this->assertEquals($this->state, $this->state->check($this->orderMock)); + } + + /** + * test check order - set state closed + */ + public function testCheckSetStateClosed() + { + $this->orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('hasCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('isCanceled') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canUnhold') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canInvoice') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canShip') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->will($this->returnValue(100)); + $this->orderMock->expects($this->once()) + ->method('canCreditmemo') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->exactly(2)) + ->method('getTotalRefunded') + ->will($this->returnValue(null)); + $this->orderMock->expects($this->once()) + ->method('hasForcedCanCreditmemo') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->exactly(2)) + ->method('getState') + ->will($this->returnValue(Order::STATE_PROCESSING)); + $this->orderMock->expects($this->once()) + ->method('setState') + ->with(Order::STATE_CLOSED, true, '', true) + ->will($this->returnSelf()); + $this->assertEquals($this->state, $this->state->check($this->orderMock)); + } + + /** + * test check order - set state processing + */ + public function testCheckSetStateProcessing() + { + $this->orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('hasCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('isCanceled') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canUnhold') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canInvoice') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canShip') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getState') + ->will($this->returnValue(Order::STATE_NEW)); + $this->orderMock->expects($this->once()) + ->method('getIsInProcess') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('setState') + ->with(Order::STATE_PROCESSING, true, '', true) + ->will($this->returnSelf()); + $this->assertEquals($this->state, $this->state->check($this->orderMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f769982945d2de2e017e48448e6ca880c2b59c41 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php @@ -0,0 +1,169 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Invoice; + +/** + * Class GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Invoice\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $grid; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statementMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['select', 'query', 'insertFromSelect', 'delete'], + [], + '', + false + ); + $this->selectMock = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->statementMock = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false, + false, + true, + [] + ); + $this->grid = new \Magento\Sales\Model\Resource\Order\Invoice\Grid( + $this->appResourceMock + ); + } + + /** + * Test refresh method + */ + public function testRefresh() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_invoice_grid')); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->selectMock->expects($this->once()) + ->method('from') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('join') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('joinLeft') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('columns') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('where') + ->with('fi.field = ?', 1, null) + ->will($this->returnSelf()); + $this->adapterMock->expects($this->once()) + ->method('query') + ->with('sql-query') + ->will($this->returnValue($this->statementMock)); + $this->adapterMock->expects($this->once()) + ->method('insertFromSelect') + ->with($this->selectMock, 'sales_flat_invoice_grid', [], 1) + ->will($this->returnValue('sql-query')); + $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); + } + + /** + * Test purge method + */ + public function testPurge() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_invoice_grid')); + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with('sales_flat_invoice_grid', ['fi.field = ?' => 1]) + ->will($this->returnValue(1)); + $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bcc51895cf15728fc8449c3e8b4bdc1f15c0f28c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php @@ -0,0 +1,169 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Shipment; + +/** + * Class GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Shipment\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $grid; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statementMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['select', 'query', 'insertFromSelect', 'delete'], + [], + '', + false + ); + $this->selectMock = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->statementMock = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false, + false, + true, + [] + ); + $this->grid = new \Magento\Sales\Model\Resource\Order\Shipment\Grid( + $this->appResourceMock + ); + } + + /** + * Test refresh method + */ + public function testRefresh() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_shipment_grid')); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->selectMock->expects($this->once()) + ->method('from') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('join') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('joinLeft') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('columns') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('where') + ->with('fi.field = ?', 1, null) + ->will($this->returnSelf()); + $this->adapterMock->expects($this->once()) + ->method('query') + ->with('sql-query') + ->will($this->returnValue($this->statementMock)); + $this->adapterMock->expects($this->once()) + ->method('insertFromSelect') + ->with($this->selectMock, 'sales_flat_shipment_grid', [], 1) + ->will($this->returnValue('sql-query')); + $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); + } + + /** + * Test purge method + */ + public function testPurge() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_shipment_grid')); + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with('sales_flat_shipment_grid', ['fi.field = ?' => 1]) + ->will($this->returnValue(1)); + $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..974cf66e58e9d17e9c8ac87bd13712b13c159ca2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php @@ -0,0 +1,215 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource; + +/** + * Class OrderTest + * + * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class OrderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order + */ + protected $resource; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTimeMock; + /** + * @var \Magento\Sales\Model\Resource\Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + protected $attributeMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Handler\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressHandlerMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Handler\State|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stateHandlerMock; + /** + * @var \Magento\Sales\Model\Increment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $salesIncrementMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $gridAggregatorMock; + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + /** + * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + /** + * @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeGroupMock; + /** + * \Magento\Sales\Model\Website|\PHPUnit_Framework_MockObject_MockObject + */ + protected $websiteMock; + /** + * @var \Magento\Customer\Model\Customer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Item\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderItemCollectionMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Payment\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderPaymentCollectionMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Status\History\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderStatusHistoryCollectionMock; + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * Mock class dependencies + */ + public function setUp() + { + $this->resourceMock = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); + $this->dateTimeMock = $this->getMock('Magento\Framework\Stdlib\DateTime', [], [], '', false); + $this->attributeMock = $this->getMock('Magento\Sales\Model\Resource\Attribute', [], [], '', false); + $this->addressHandlerMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Handler\Address', + [], + [], + '', + false + ); + $this->stateHandlerMock = $this->getMock('Magento\Sales\Model\Resource\Order\Handler\State', [], [], '', false); + $this->salesIncrementMock = $this->getMock('Magento\Sales\Model\Increment', [], [], '', false); + $this->gridAggregatorMock = $this->getMock('Magento\Sales\Model\Resource\Order\Grid', [], [], '', false); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [ + '__wakeup', 'getId', 'getStore', 'getGroup', 'getName', 'setStoreName', 'setTotalItemCount', 'setData', + 'getCustomerId', 'getCustomer', 'setCustomerId', 'getItemsCollection', 'getPaymentsCollection', + 'getStatusHistoryCollection', 'getRelatedObjects', 'save' + ], + [], + '', + false + ); + $this->storeMock = $this->getMock('Magento\Store\Model\Store', ['__wakeup'], [], '', false); + $this->storeGroupMock = $this->getMock('Magento\Store\Model\Group', ['__wakeup'], [], '', false); + $this->websiteMock = $this->getMock('Magento\Sales\Model\Website', ['__wakeup'], [], '', false); + $this->customerMock = $this->getMock('Magento\Customer\Model\Customer', ['__wakeup'], [], '', false); + $this->orderItemCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Item\Collection', + [], + [], + '', + false + ); + $this->orderPaymentCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Payment\Collection', + [], + [], + '', + false + ); + $this->orderStatusHistoryCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\Collection', + [], + [], + '', + false + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + [ + 'describeTable', + 'insert', + 'lastInsertId', + 'beginTransaction', + 'rollback', + 'commit', + 'quoteInto', + 'update' + ], + [], + '', + false + ); + + $this->resource = new Order( + $this->resourceMock, + $this->dateTimeMock, + $this->attributeMock, + $this->salesIncrementMock, + $this->addressHandlerMock, + $this->stateHandlerMock, + $this->gridAggregatorMock + ); + } + + public function testSave() + { + $this->resourceMock->expects($this->any()) + ->method('getConnection') + ->willReturn($this->adapterMock); + $this->adapterMock->expects($this->any()) + ->method('quoteInto'); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('update'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + $this->addressHandlerMock->expects($this->once()) + ->method('removeEmptyAddresses') + ->with($this->equalTo($this->orderMock)) + ->will($this->returnSelf()); + $this->stateHandlerMock->expects($this->once()) + ->method('check') + ->with($this->equalTo($this->orderMock)) + ->will($this->returnSelf()); + $this->orderMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('getRelatedObjects') + ->willReturn([]); + $this->resource->save($this->orderMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/TransactionMapperTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/TransactionMapperTest.php index 39d37780a8ce16e6a80f6ca6a32903c8fab6987d..3edf5c380501214ecd4f18656b0d8d247d52faa2 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/TransactionMapperTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/TransactionMapperTest.php @@ -64,7 +64,22 @@ class TransactionMapperTest extends \PHPUnit_Framework_TestCase ); $this->transactionBuilderMock = $this->getMock( 'Magento\Sales\Service\V1\Data\TransactionBuilder', - ['populateWithArray', 'setAdditionalInformation', 'setIncrementId', 'setChildTransactions', 'create'], + [ + 'setTransactionId', + 'setParentId', + 'setOrderId', + 'setTxnId', + 'setPaymentId', + 'setParentTxnId', + 'setTxnType', + 'setIsClosed', + 'setCreatedAt', + 'setMethod', + 'setAdditionalInformation', + 'setIncrementId', + 'setChildTransactions', + 'create' + ], [], '', false @@ -183,15 +198,23 @@ class TransactionMapperTest extends \PHPUnit_Framework_TestCase */ public function testExtractDto($lazy) { - list($id, $data) = [1, []]; + $id = 1; $transactionModelMock = $this->getMockBuilder('Magento\Sales\Model\Order\Payment\Transaction') ->disableOriginalConstructor()->setMethods([])->getMock(); $transactionDtoMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Transaction') ->disableOriginalConstructor()->setMethods([])->getMock(); $this->prepareTransactionOrder($transactionModelMock, $id); - $transactionModelMock->expects($this->once())->method('getData')->will($this->returnValue($data)); - $this->transactionBuilderMock->expects($this->once())->method('populateWithArray')->with($data); + $this->transactionBuilderMock->expects($this->once())->method('setTransactionId'); + $this->transactionBuilderMock->expects($this->once())->method('setParentId'); + $this->transactionBuilderMock->expects($this->once())->method('setOrderId'); + $this->transactionBuilderMock->expects($this->once())->method('setTxnId'); + $this->transactionBuilderMock->expects($this->once())->method('setPaymentId'); + $this->transactionBuilderMock->expects($this->once())->method('setParentTxnId'); + $this->transactionBuilderMock->expects($this->once())->method('setTxnType'); + $this->transactionBuilderMock->expects($this->once())->method('setIsClosed'); + $this->transactionBuilderMock->expects($this->once())->method('setCreatedAt'); + $this->transactionBuilderMock->expects($this->once())->method('setMethod'); $transactionModelMock->expects($this->once())->method('getAdditionalInformation')->will($this->returnValue([])); $this->transactionBuilderMock->expects($this->once())->method('setAdditionalInformation')->with([]); $this->transactionBuilderMock->expects($this->once())->method('setIncrementId')->with($id); diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php index 7be3f123aaa4b6c7bf51bf349471076c221db248..ea2fe33f3c9ff762df67f7aba80fd3475fb04233 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php @@ -70,7 +70,8 @@ class DiscountTest extends \PHPUnit_Framework_TestCase 'sortItemsByPriority', 'setSkipActionsValidation', 'process', - 'processShippingAmount' + 'processShippingAmount', + 'canApplyDiscount' ] ) ->getMock(); @@ -147,6 +148,10 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->method('getParentItemId') ->willReturn(true); + $this->validatorMock->expects($this->any()) + ->method('canApplyDiscount') + ->willReturn(true); + $this->validatorMock->expects($this->any()) ->method('sortItemsByPriority') ->willReturnArgument(0); @@ -217,6 +222,10 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->method('getChildren') ->willReturn([$child]); + $this->validatorMock->expects($this->any()) + ->method('canApplyDiscount') + ->willReturn(true); + $this->validatorMock->expects($this->any()) ->method('sortItemsByPriority') ->willReturnArgument(0); @@ -271,6 +280,10 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->method('getHasChildren') ->willReturn(false); + $this->validatorMock->expects($this->any()) + ->method('canApplyDiscount') + ->willReturn(true); + $this->validatorMock->expects($this->any()) ->method('sortItemsByPriority') ->willReturnArgument(0); diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Validator/PoolTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Validator/PoolTest.php new file mode 100644 index 0000000000000000000000000000000000000000..eaeb3a8fab7dff20f80d9a8dacb4620c3f9f55fd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Validator/PoolTest.php @@ -0,0 +1,53 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\SalesRule\Model\Validator; + +/** + * Test Class PoolTest + */ +class PoolTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\SalesRule\Model\Validator\Pool; + */ + protected $pool; + + /** + * @var array + */ + protected $validators = []; + + public function setUp() + { + $this->validators = ['discount' => ['validator1', 'validator2']]; + $this->pool = new Pool($this->validators); + } + + public function testGetValidators() + { + $this->assertContains($this->validators['discount'][0], $this->pool->getValidators('discount')); + $this->assertEquals([], $this->pool->getValidators('fake')); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php index b5cf5ffdeaae081fc9149ade1cea8c86a69ce175..80651335dd6defc62f7fe60e91250a780b2086b7 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php @@ -23,31 +23,107 @@ */ namespace Magento\SalesRule\Model; +/** + * Class ValidatorTest + * @@SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ValidatorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $helper; + + /** + * @var \Magento\SalesRule\Model\Validator */ protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Sales\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $item; + + /** + * @var \Magento\SalesRule\Model\RulesApplier|\PHPUnit_Framework_MockObject_MockObject + */ + protected $rulesApplier; + + /** + * @var \Magento\SalesRule\Model\Validator\Pool|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validators; + + /** + * @var \Magento\SalesRule\Model\Utility|\PHPUnit_Framework_MockObject_MockObject + */ + protected $utility; + + /** + * @var \Magento\SalesRule\Model\Resource\Rule\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $ruleCollection; + + /** + * @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $catalogData; + + /** + * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $utilityMock; + protected $messageManager; protected function setUp() { - // @TODO Re-write test according to standards of writing test (e.g do not mock tested class) - $this->model = $this->getMock( - 'Magento\SalesRule\Model\Validator', - array('_getRules', '_getItemOriginalPrice', '_getItemBaseOriginalPrice', '__wakeup'), - array(), + $this->helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->rulesApplier = $this->getMock( + 'Magento\SalesRule\Model\RulesApplier', + ['setAppliedRuleIds', 'applyRules', 'addDiscountDescription', '__wakeup'], + [], '', false ); - $this->model->expects($this->any())->method('_getRules')->will($this->returnValue(array())); - $this->model->expects($this->any())->method('_getItemOriginalPrice')->will($this->returnValue(1)); - $this->model->expects($this->any())->method('_getItemBaseOriginalPrice')->will($this->returnValue(1)); + + /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */ + $this->item = $this->getMock('Magento\Sales\Model\Quote\Item', ['__wakeup'], [], '', false); + + $context = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); + $registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->catalogData = $this->getMock('Magento\Catalog\Helper\Data', [], [], '', false); + $this->utility = $this->getMock('Magento\SalesRule\Model\Utility', [], [], '', false); + $this->validators = $this->getMock('Magento\SalesRule\Model\Validator\Pool', ['getValidators'], [], '', false); + $this->messageManager = $this->getMock('\Magento\Framework\Message\Manager', [], [], '', false); + $this->ruleCollection = $this->getMockBuilder('Magento\SalesRule\Model\Resource\Rule\Collection') + ->disableOriginalConstructor() + ->getMock(); + $ruleCollectionFactoryMock = $this->prepareRuleCollectionMock($this->ruleCollection); + + /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ + $this->model = $this->helper->getObject( + 'Magento\SalesRule\Model\Validator', + [ + 'context' => $context, + 'registry' => $registry, + 'collectionFactory' => $ruleCollectionFactoryMock, + 'catalogData' => $this->catalogData, + 'utility' => $this->utility, + 'rulesApplier' => $this->rulesApplier, + 'validators' => $this->validators, + 'messageManager' => $this->messageManager + ] + ); + $this->model->setWebsiteId(1); + $this->model->setCustomerGroupId(2); + $this->model->setCouponCode('code'); + $this->ruleCollection->expects($this->at(0)) + ->method('setValidationFilter') + ->with( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ) + ->willReturnSelf(); } /** @@ -58,8 +134,8 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $fixturePath = __DIR__ . '/_files/'; $itemDownloadable = $this->getMock( 'Magento\Sales\Model\Quote\Item', - array('getAddress', '__wakeup'), - array(), + ['getAddress', '__wakeup'], + [], '', false ); @@ -67,15 +143,15 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $itemSimple = $this->getMock( 'Magento\Sales\Model\Quote\Item', - array('getAddress', '__wakeup'), - array(), + ['getAddress', '__wakeup'], + [], '', false ); $itemSimple->expects($this->any())->method('getAddress')->will($this->returnValue(new \stdClass())); /** @var $quote \Magento\Sales\Model\Quote */ - $quote = $this->getMock('Magento\Sales\Model\Quote', array('hasNominalItems', '__wakeup'), array(), '', false); + $quote = $this->getMock('Magento\Sales\Model\Quote', ['hasNominalItems', '__wakeup'], [], '', false); $quote->expects($this->any())->method('hasNominalItems')->will($this->returnValue(false)); $itemData = include $fixturePath . 'quote_item_downloadable.php'; @@ -91,7 +167,36 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase public function testCanApplyRules() { + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); $item = $this->getQuoteItemMock(); + $rule = $this->getMock( + 'Magento\SalesRule\Model\Rule', + [], + [], + '', + false + ); + $actionsCollection = $this->getMock('Magento\Rule\Model\Action\Collection', ['validate'], [], '', false); + $actionsCollection->expects($this->any()) + ->method('validate') + ->with($item) + ->willReturn(true); + $rule->expects($this->any()) + ->method('getActions') + ->willReturn($actionsCollection); + $iterator = new \ArrayIterator([$rule]); + $this->ruleCollection->expects($this->any()) + ->method('getIterator') + ->willReturn($iterator); + + $this->utility->expects($this->any()) + ->method('canProcessRule') + ->with($rule, $this->anything()) + ->willReturn(true); $quote = $item->getQuote(); $quote->setItemsQty(2); @@ -109,71 +214,41 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase { $negativePrice = -1; - // 1. Get mocks - /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ - $validator = $this->getMock( - 'Magento\SalesRule\Model\Validator', - array('__wakeup'), - array(), - '', - false - ); - $rulesApplier = $this->getMock( - 'Magento\SalesRule\Model\Validator\RulesApplier', - ['applyRules', '__wakeup'], - [], - '', - false - ); - - /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock('Magento\Sales\Model\Quote\Item', array('__wakeup'), array(), '', false); - - // 2. Set fixtures - $item->setDiscountCalculationPrice($negativePrice); - $item->setData('calculation_price', $negativePrice); + $this->item->setDiscountCalculationPrice($negativePrice); + $this->item->setData('calculation_price', $negativePrice); - // 3. Set expectations - $rulesApplier->expects($this->never())->method('applyRules'); + $this->rulesApplier->expects($this->never())->method('applyRules'); - // 4. Run tested method - $validator->process($item); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); + $this->model->process($this->item); } public function testProcessWhenItemPriceIsNegativeDiscountsAreZeroed() { $negativePrice = -1; $nonZeroDiscount = 123; - - // 1. Get mocks - /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ - $validator = $this->getMock( - 'Magento\SalesRule\Model\Validator', - array('__wakeup'), - array(), - '', - false + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() ); - /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock('Magento\Sales\Model\Quote\Item', array('__wakeup'), array(), '', false); - - // 2. Set fixtures - $item->setDiscountCalculationPrice($negativePrice); - $item->setData('calculation_price', $negativePrice); + $this->item->setDiscountCalculationPrice($negativePrice); + $this->item->setData('calculation_price', $negativePrice); - // Discounts that could be set before running tested method - $item->setDiscountAmount($nonZeroDiscount); - $item->setBaseDiscountAmount($nonZeroDiscount); - $item->setDiscountPercent($nonZeroDiscount); + $this->item->setDiscountAmount($nonZeroDiscount); + $this->item->setBaseDiscountAmount($nonZeroDiscount); + $this->item->setDiscountPercent($nonZeroDiscount); - // 3. Run tested method - $validator->process($item); + $this->model->process($this->item); - // 4. Check expected result - $this->assertEquals(0, $item->getDiscountAmount()); - $this->assertEquals(0, $item->getBaseDiscountAmount()); - $this->assertEquals(0, $item->getDiscountPercent()); + $this->assertEquals(0, $this->item->getDiscountAmount()); + $this->assertEquals(0, $this->item->getBaseDiscountAmount()); + $this->assertEquals(0, $this->item->getDiscountPercent()); } public function testApplyRulesThatAppliedRuleIdsAreCollected() @@ -181,167 +256,160 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $positivePrice = 1; $ruleId1 = 123; $ruleId2 = 234; - $expectedRuleIds = array($ruleId1 => $ruleId1, $ruleId2 => $ruleId2); - - // 1. Get mocks - $rulesApplier = $this->getMock( - 'Magento\SalesRule\Model\RulesApplier', - ['applyRules', 'setAppliedRuleIds'], - [], - '', - false - ); - $context = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $collectionFactory = $this->getMock( - 'Magento\SalesRule\Model\Resource\Rule\CollectionFactory', - [], - [], - '', - false + $expectedRuleIds = [$ruleId1 => $ruleId1, $ruleId2 => $ruleId2]; + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() ); - $catalogData = $this->getMock('Magento\Catalog\Helper\Data', [], [], '', false); - $utility = $this->getMock('Magento\SalesRule\Model\Utility', [], [], '', false); - /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ - $validator = $this->getMock( - 'Magento\SalesRule\Model\Validator', - ['_getRules', '_canProcessRule', '__wakeup'], - [ - 'context' => $context, - 'registry' => $registry, - 'collectionFactory' => $collectionFactory, - 'catalogData' => $catalogData, - 'utility' => $utility, - 'rulesApplier' => $rulesApplier - ], - '', - true - ); + $this->item->setDiscountCalculationPrice($positivePrice); + $this->item->setData('calculation_price', $positivePrice); + $this->model->setSkipActionsValidation(true); - /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock('Magento\Sales\Model\Quote\Item', array('getAddress', '__wakeup'), array(), '', false); - /** @var \Magento\SalesRule\Model\Rule|\PHPUnit_Framework_MockObject_MockObject $rule */ - $rule = $this->getMock('Magento\SalesRule\Model\Rule', array('__wakeup'), array(), '', false); - $rule->setRuleId($ruleId1); - /** @var \Magento\SalesRule\Model\Rule|\PHPUnit_Framework_MockObject_MockObject $rule2 */ - $rule2 = $this->getMock('Magento\SalesRule\Model\Rule', array('__wakeup'), array(), '', false); - $rule2->setRuleId($ruleId2); - $rules = array($rule, $rule2); - $validator->expects($this->any())->method('_getRules')->will($this->returnValue($rules)); - - // 2. Set fixtures, provide tested code isolation - $item->setDiscountCalculationPrice($positivePrice); - $item->setData('calculation_price', $positivePrice); - $validator->setSkipActionsValidation(true); - - // 3. Set expectations - $rulesApplier->expects($this->once()) + $this->rulesApplier->expects($this->once()) ->method('applyRules') ->with( - $this->equalTo($item), - $this->equalTo($rules), + $this->equalTo($this->item), + $this->equalTo($this->ruleCollection), $this->anything(), $this->anything() ) ->will($this->returnValue($expectedRuleIds)); - $rulesApplier->expects($this->once())->method('setAppliedRuleIds')->with($this->anything(), $expectedRuleIds); + $this->rulesApplier->expects($this->once()) + ->method('setAppliedRuleIds') + ->with( + $this->anything(), + $expectedRuleIds + ); - // 4. Run tested method again - $validator->process($item); + $this->model->process($this->item); } - /** - * @param $expectedMergedRuleIds - * @param \Magento\Sales\Model\Quote\Address|\Magento\Sales\Model\Quote $object - * @return $this - */ - protected function assertObjectHasRuleIdsSet($expectedMergedRuleIds, $object) + public function testInit() { - $array = explode(',', $object->getAppliedRuleIds()); - sort($array); - $this->assertEquals($expectedMergedRuleIds, join(',', $array)); - - return $this; + $this->assertInstanceOf( + 'Magento\SalesRule\Model\Validator', + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ) + ); } - protected function getValidator() + public function testCanApplyDiscount() { - // 1. Get mocks - /** @var \Magento\SalesRule\Model\Rule\Action\Discount\DiscountInterface $calculator */ - $calculator = $this->getMockBuilder( - 'Magento\SalesRule\Model\Rule\Action\Discount\DiscountInterface' - )->setMethods( - array('fixQuantity', 'calculate') - )->getMock(); - - $discountData = $this->getMockBuilder('Magento\SalesRule\Model\Rule\Action\Discount\Data')->getMock(); - - /** @var \Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory */ - $calculatorFactory = $this->getMockBuilder( - 'Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory' - )->disableOriginalConstructor()->setMethods( - array('create') - )->getMock(); - - $calculator->expects($this->any())->method('fixQuantity'); - $calculator->expects($this->any())->method('calculate')->will($this->returnValue($discountData)); - $calculatorFactory->expects($this->any())->method('create')->will($this->returnValue($calculator)); - - $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $args = $objectManagerHelper->getConstructArguments( - 'Magento\SalesRule\Model\Validator', - array('calculatorFactory' => $calculatorFactory) + $validator = $this->getMockBuilder('Magento\Framework\Validator\AbstractValidator') + ->setMethods(['isValid']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->validators->expects($this->any()) + ->method('getValidators') + ->with('discount') + ->willReturn([$validator]); + $validator->expects($this->any()) + ->method('isValid') + ->with($this->item) + ->willReturn(false); + + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() ); + $this->assertFalse($this->model->canApplyDiscount($this->item)); + } - /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ - $validator = $this->getMockBuilder( - 'Magento\SalesRule\Model\Validator' - )->setMethods( - array( - 'getDiscountData', - 'setDiscountData', - '_addDiscountDescription', - '_maintainAddressCouponCode', - '_getItemQty', - '_canProcessRule', - 'setAppliedRuleIds', - '_getRules', - '__wakeup' - ) - )->setConstructorArgs( - $args - )->getMock(); - - $rule = $this->getMockBuilder( - 'Magento\SalesRule\Model\Rule' - )->disableOriginalConstructor()->setMethods( - array() - )->getMock(); - $validator->expects($this->any())->method('_getRules')->will($this->returnValue(array($rule))); - + public function testInitTotalsCanApplyDiscount() + { + $address = $this->getMock('Magento\Sales\Model\Quote\Address', [], [], '', false); + $rule = $this->getMock( + 'Magento\SalesRule\Model\Rule', + ['getSimpleAction', 'getActions', 'getId'], + [], + '', + false + ); + $item1 = $this->getMockForAbstractClass( + 'Magento\Sales\Model\Quote\Item\AbstractItem', + [], + '', + false, + true, + true, + ['__clone', 'getDiscountCalculationPrice', 'getBaseDiscountCalculationPrice', 'getCalculationPrice'] + ); + $item2 = clone $item1; + $items = [$item1, $item2]; - return $validator; + $rule->expects($this->any()) + ->method('getSimpleAction') + ->willReturn(\Magento\SalesRule\Model\Rule::CART_FIXED_ACTION); + $iterator = new \ArrayIterator([$rule]); + $this->ruleCollection->expects($this->once())->method('getIterator')->willReturn($iterator); + $validator = $this->getMockBuilder('Magento\Framework\Validator\AbstractValidator') + ->setMethods(['isValid']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->validators->expects($this->atLeastOnce())->method('getValidators')->with('discount') + ->willReturn([$validator]); + $validator->expects($this->at(0))->method('isValid')->with($item1)->willReturn(false); + $validator->expects($this->at(1))->method('isValid')->with($item2)->willReturn(true); + + $item1->expects($this->any())->method('getParentItemId')->willReturn(false); + $item1->expects($this->never())->method('getDiscountCalculationPrice'); + $item1->expects($this->never())->method('getBaseDiscountCalculationPrice'); + $item2->expects($this->any())->method('getParentItemId')->willReturn(false); + $item2->expects($this->any())->method('getDiscountCalculationPrice')->willReturn(50); + $item2->expects($this->once())->method('getBaseDiscountCalculationPrice')->willReturn(50); + $this->utility->expects($this->once())->method('getItemQty')->willReturn(1); + $this->utility->expects($this->any())->method('canProcessRule')->willReturn(true); + + $actionsCollection = $this->getMock('Magento\Rule\Model\Action\Collection', ['validate'], [], '', false); + $actionsCollection->expects($this->at(0))->method('validate')->with($item1)->willReturn(true); + $actionsCollection->expects($this->at(1))->method('validate')->with($item2)->willReturn(true); + $rule->expects($this->any())->method('getActions')->willReturn($actionsCollection); + $rule->expects($this->any())->method('getId')->willReturn(1); + + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); + $this->model->initTotals($items, $address); + $this->assertArrayHasKey('items_price', $this->model->getRuleItemTotalsInfo($rule->getId())); + $this->assertArrayHasKey('base_items_price', $this->model->getRuleItemTotalsInfo($rule->getId())); + $this->assertArrayHasKey('items_count', $this->model->getRuleItemTotalsInfo($rule->getId())); + $this->assertEquals(1, $this->model->getRuleItemTotalsInfo($rule->getId())['items_count']); } - public function testInit() + public function testInitTotalsNoItems() { - $websiteId = 1; - $customerGroupId = 2; - $couponCode = 'code'; + $address = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); + $this->item->expects($this->never()) + ->method('getParentItemId'); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); + $this->model->initTotals([], $address); + } - $ruleCollection = $this->getMockBuilder('Magento\SalesRule\Model\Resource\Rule\Collection') - ->disableOriginalConstructor() - ->getMock(); - $ruleCollection->expects($this->once()) - ->method('setValidationFilter') - ->with($websiteId, $customerGroupId, $couponCode) - ->will($this->returnSelf()); - $ruleCollection->expects($this->once()) + /** + * @param $ruleCollection + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function prepareRuleCollectionMock($ruleCollection) + { + $this->ruleCollection->expects($this->once()) ->method('addFieldToFilter') ->with('is_active', 1) ->will($this->returnSelf()); - $ruleCollection->expects($this->once()) + $this->ruleCollection->expects($this->once()) ->method('load') ->will($this->returnSelf()); @@ -352,53 +420,44 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $ruleCollectionFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($ruleCollection)); - - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $model = $helper->getObject( - 'Magento\SalesRule\Model\Validator', - [ - 'collectionFactory' => $ruleCollectionFactoryMock - ] - ); - - $this->assertInstanceOf( - 'Magento\SalesRule\Model\Validator', - $model->init($websiteId, $customerGroupId, $couponCode) - ); + return $ruleCollectionFactoryMock; } public function testProcessShippingAmountNoRules() { - $websiteId = 1; - $customerGroupId = 1; - $code = 'test'; - $iterator = new \ArrayIterator([]); - $model = $this->getModel($iterator); - $model->init($websiteId, $customerGroupId, $code); + $this->ruleCollection->expects($this->any()) + ->method('getIterator') + ->willReturn($iterator); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); $this->assertInstanceOf( 'Magento\SalesRule\Model\Validator', - $model->processShippingAmount($this->getAddressMock()) + $this->model->processShippingAmount($this->getAddressMock()) ); } public function testProcessShippingAmountProcessDisabled() { - $websiteId = 1; - $customerGroupId = 1; - $code = 'test'; - $ruleMock = $this->getMockBuilder('Magento\SalesRule\Model\Rule') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $iterator = new \ArrayIterator([$ruleMock]); - - $model = $this->getModel($iterator); - $model->init($websiteId, $customerGroupId, $code); + $this->ruleCollection->expects($this->any()) + ->method('getIterator') + ->willReturn($iterator); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); $this->assertInstanceOf( 'Magento\SalesRule\Model\Validator', - $model->processShippingAmount($this->getAddressMock()) + $this->model->processShippingAmount($this->getAddressMock()) ); } @@ -408,9 +467,6 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase */ public function testProcessShippingAmountActions($action) { - $websiteId = 1; - $customerGroupId = 1; - $code = 'test'; $discountAmount = 50; $ruleMock = $this->getMockBuilder('Magento\SalesRule\Model\Rule') @@ -428,17 +484,22 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase ->willReturn($action); $iterator = new \ArrayIterator([$ruleMock]); + $this->ruleCollection->expects($this->any()) + ->method('getIterator') + ->willReturn($iterator); - $model = $this->getModel($iterator); - - $this->utilityMock->expects($this->any()) + $this->utility->expects($this->any()) ->method('canProcessRule') ->willReturn(true); - $model->init($websiteId, $customerGroupId, $code); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); $this->assertInstanceOf( 'Magento\SalesRule\Model\Validator', - $model->processShippingAmount($this->getAddressMock(5)) + $this->model->processShippingAmount($this->getAddressMock(5)) ); } @@ -487,60 +548,9 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase return $addressMock; } - protected function getModel($collectionIterator = null) - { - $this->utilityMock = $this->getMockBuilder('Magento\SalesRule\Model\Utility') - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - $rulesApplierMock = $this->getMockBuilder('Magento\SalesRule\Model\RulesApplier') - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - - $collectionMock = $this->getMockBuilder('Magento\SalesRule\Model\Resource\Rule\Collection') - ->disableOriginalConstructor() - ->setMethods(['setValidationFilter', 'addFieldToFilter', 'load', 'getIterator']) - ->getMock(); - $collectionMock->expects($this->any()) - ->method('setValidationFilter') - ->willReturnSelf(); - $collectionMock->expects($this->any()) - ->method('addFieldToFilter') - ->willReturnSelf(); - $collectionMock->expects($this->any()) - ->method('load') - ->willReturnSelf(); - $collectionMock->expects($this->any()) - ->method('getIterator') - ->willReturn($collectionIterator); - - $collectionFactoryMock = $this->getMockBuilder('Magento\SalesRule\Model\Resource\Rule\CollectionFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $collectionFactoryMock->expects($this->any()) - ->method('create') - ->willReturn($collectionMock); - - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - return $helper->getObject( - 'Magento\SalesRule\Model\Validator', - [ - 'utility' => $this->utilityMock, - 'rulesApplier' => $rulesApplierMock, - 'collectionFactory' => $collectionFactoryMock - ] - ); - } - public function testReset() { - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $utilityMock = $this->getMockBuilder('Magento\SalesRule\Model\Utility') - ->disableOriginalConstructor() - ->getMock(); - $utilityMock->expects($this->once()) + $this->utility->expects($this->once()) ->method('resetRoundingDeltas'); $quoteMock = $this->getMockBuilder('Magento\Sales\Model\Quote') ->disableOriginalConstructor() @@ -551,14 +561,11 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $addressMock->expects($this->once()) ->method('getQuote') ->willReturn($quoteMock); - - /** @var \Magento\SalesRule\Model\Validator $model */ - $model = $helper->getObject( - 'Magento\SalesRule\Model\Validator', - [ - 'utility' => $utilityMock - ] + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() ); - $this->assertInstanceOf('\Magento\SalesRule\Model\Validator', $model->reset($addressMock)); + $this->assertInstanceOf('\Magento\SalesRule\Model\Validator', $this->model->reset($addressMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/Sendfriend/Block/Plugin/Catalog/Product/ViewTest.php b/dev/tests/unit/testsuite/Magento/Sendfriend/Block/Plugin/Catalog/Product/ViewTest.php new file mode 100644 index 0000000000000000000000000000000000000000..320d7a8c616f53f4ef9e2d2eccf4743839ac0441 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sendfriend/Block/Plugin/Catalog/Product/ViewTest.php @@ -0,0 +1,85 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sendfriend\Block\Plugin\Catalog\Product; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Sendfriend\Block\Plugin\Catalog\Product\View */ + protected $view; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** @var \Magento\Sendfriend\Model\Sendfriend|\PHPUnit_Framework_MockObject_MockObject */ + protected $sendfriendModel; + + /** @var \Magento\Catalog\Block\Product\View|\PHPUnit_Framework_MockObject_MockObject */ + protected $productView; + + + protected function setUp() + { + $this->sendfriendModel = $this->getMock( + 'Magento\Sendfriend\Model\Sendfriend', + array('__wakeup', 'canEmailToFriend'), + array(), + '', + false + ); + $this->productView = $this->getMock('Magento\Catalog\Block\Product\View', array(), array(), '', false); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->view = $this->objectManagerHelper->getObject( + 'Magento\Sendfriend\Block\Plugin\Catalog\Product\View', + [ + 'sendfriend' => $this->sendfriendModel + ] + ); + + } + + /** + * @dataProvider afterCanEmailToFriendDataSet + * @param bool $result + * @param string $callSendfriend + */ + public function testAfterCanEmailToFriend($result, $callSendfriend) + { + $this->sendfriendModel->expects($this->$callSendfriend())->method('canEmailToFriend') + ->will($this->returnValue(true)); + + $this->assertTrue($this->view->afterCanEmailToFriend($this->productView, $result)); + } + + public function afterCanEmailToFriendDataSet() + { + return array( + array(true, 'never'), + array(false, 'once') + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php b/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php index 0cfbe11413dbf37b81c7da4ab26cff219c98a8c0..60c58bc33bccd7704dbe47ca7933aa67a35a35fa 100644 --- a/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php +++ b/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php @@ -89,7 +89,7 @@ class SendfriendTest extends \PHPUnit_Framework_TestCase ); $this->cookieManagerMock->expects($this->once())->method('getCookie')->with($cookieName); - $this->cookieManagerMock->expects($this->once())->method('setPublicCookie'); + $this->cookieManagerMock->expects($this->once())->method('setSensitiveCookie'); $sendFriendClass = new \ReflectionClass('Magento\Sendfriend\Model\Sendfriend'); $method = $sendFriendClass->getMethod('_sentCountByCookies'); $method->setAccessible(true); diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php index 365e06d976eb34d6eb1121dd041a4fa81decaa8f..94ede48caef8c2732c1093ccf12cc1c0d1ad7c4f 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php @@ -85,11 +85,6 @@ class ContextTest extends \PHPUnit_Framework_TestCase */ protected $requestMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cookieManagerMock; - /** * Set up */ @@ -103,8 +98,7 @@ class ContextTest extends \PHPUnit_Framework_TestCase ['getParam'], [], '', false); $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', ['getWebsite', '__wakeup'], [], '', false); - $this->storeMock = $this->getMock('Magento\Store\Model\Store', - ['__wakeup', 'getDefaultCurrency'], [], '', false); + $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $this->currencyMock = $this->getMock('Magento\Directory\Model\Currency', ['getCode', '__wakeup'], [], '', false); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', @@ -112,15 +106,13 @@ class ContextTest extends \PHPUnit_Framework_TestCase $this->closureMock = function () { return 'ExpectedValue'; }; - $this->cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager'); $this->subjectMock = $this->getMock('Magento\Framework\App\Action\Action', [], [], '', false); $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); $this->plugin = new \Magento\Store\App\Action\Plugin\Context( $this->sessionMock, $this->httpContextMock, $this->httpRequestMock, - $this->storeManagerMock, - $this->cookieManagerMock + $this->storeManagerMock ); } @@ -138,6 +130,9 @@ class ContextTest extends \PHPUnit_Framework_TestCase $this->storeMock->expects($this->once()) ->method('getDefaultCurrency') ->will($this->returnValue($this->currencyMock)); + $this->storeMock->expects($this->once()) + ->method('getStoreCodeFromCookie') + ->will($this->returnValue('storeCookie')); $this->currencyMock->expects($this->once()) ->method('getCode') ->will($this->returnValue('UAH')); @@ -150,11 +145,6 @@ class ContextTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo('___store')) ->will($this->returnValue('default')); - $this->cookieManagerMock->expects($this->once()) - ->method('getCookie') - ->with($this->equalTo(\Magento\Store\Model\Store::COOKIE_NAME)) - ->will($this->returnValue(null)); - $this->httpContextMock->expects($this->atLeastOnce()) ->method('setValue') ->will($this->returnValueMap([ diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/StoreCheckTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/StoreCheckTest.php index f01031eaf557ef406c4b5e44ae607293c81e3d47..49b3b7c614516bbb86bf2547cfb64c111083415a 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/StoreCheckTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/StoreCheckTest.php @@ -50,11 +50,6 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $appStateMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -62,7 +57,7 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_storeMock = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->_storeManagerMock->expects( $this->any() @@ -76,18 +71,16 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase return 'Expected'; }; $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->_plugin = new \Magento\Store\App\Action\Plugin\StoreCheck($this->_storeManagerMock, $this->appStateMock); + $this->_plugin = new \Magento\Store\App\Action\Plugin\StoreCheck($this->_storeManagerMock); } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException * @expectedExceptionMessage Current store is not active. */ - public function testAroundDispatchWhenStoreNotActiveAppInstalled() + public function testAroundDispatchWhenStoreNotActive() { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_storeMock->expects($this->any())->method('getIsActive')->will($this->returnValue(false)); $this->assertEquals( 'Expected', @@ -95,9 +88,8 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase ); } - public function testAroundDispatchWhenStoreIsActiveAppInstalled() + public function testAroundDispatchWhenStoreIsActive() { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_storeMock->expects($this->any())->method('getIsActive')->will($this->returnValue(true)); $this->assertEquals( 'Expected', @@ -105,23 +97,4 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase ); } - public function testAroundDispatchWhenStoreNotActiveAppNotInstalled() - { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_storeMock->expects($this->never())->method('getIsActive'); - $this->assertEquals( - 'Expected', - $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) - ); - } - - public function testAroundDispatchWhenStoreIsActiveAppNotInstalled() - { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_storeMock->expects($this->never())->method('getIsActive'); - $this->assertEquals( - 'Expected', - $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) - ); - } } diff --git a/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandlerTest.php b/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandlerTest.php deleted file mode 100644 index 6a742aa424136983b7f785f16892796d90456a37..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandlerTest.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Store\App\FrontController\Plugin; - -class DispatchExceptionHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_filesystemMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - /** - * @var \Closure - */ - protected $closureMock; - - protected function setUp() - { - $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManager', array(), array(), '', false); - $this->_filesystemMock = $this->getMock('\Magento\Framework\App\Filesystem', array(), array(), '', false); - $this->closureMock = function () { - return 'Expected'; - }; - $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); - $this->_model = new DispatchExceptionHandler($this->_storeManagerMock, $this->_filesystemMock); - } - - public function testAroundDispatch() - { - $requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->assertEquals( - 'Expected', - $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $requestMock) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php b/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php index 4b6c9f833ee6cdd2c7672e3d2763e67cf1274d7d..c094b7a07a16d746630c88af030b3cd3158200ab 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php @@ -35,11 +35,6 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase */ protected $_storeManagerMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -78,33 +73,19 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase return 'Expected'; }; $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManager', array(), array(), '', false); - $this->_appStateMock = $this->getMock('\Magento\Framework\App\State', array(), array(), '', false); $this->_urlMock = $this->getMock('\Magento\Framework\Url', array(), array(), '', false); $this->_scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); $this->_model = new \Magento\Store\App\FrontController\Plugin\RequestPreprocessor( $this->_storeManagerMock, - $this->_appStateMock, $this->_urlMock, $this->_scopeConfigMock, $this->getMock('\Magento\Framework\App\ResponseFactory', array(), array(), '', false) ); } - public function testAroundDispatchIfNotInstalled() - { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); - $this->_scopeConfigMock->expects($this->never())->method('getValue'); - $this->assertEquals( - 'Expected', - $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->_requestMock) - ); - } - - public function testAroundDispatchIfInstalledAndRedirectCodeNotExist() + public function testAroundDispatchIfRedirectCodeNotExist() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); $this->_scopeConfigMock->expects($this->once())->method('getValue')->with('web/url/redirect_to_base'); $this->_requestMock->expects($this->never())->method('getRequestUri'); @@ -114,9 +95,8 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase ); } - public function testAroundDispatchIfInstalledAndRedirectCodeExist() + public function testAroundDispatchIfRedirectCodeExist() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); $this->_scopeConfigMock->expects( $this->once() @@ -144,7 +124,6 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase public function testAroundDispatchIfBaseUrlNotExists() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); $this->_scopeConfigMock->expects( $this->once() diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php index 52048dd9f3b5e26b4122e3b8d46094026a06f44b..5b5cc6185d458f719755e55c206dcd873ea9b8cf 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php @@ -76,7 +76,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase 'getCookie' ) ); - $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->_urlCoderMock = $this->getMock( '\Magento\Framework\Encryption\UrlCoder', array(), diff --git a/dev/tests/unit/testsuite/Magento/Store/Block/SwitchTest.php b/dev/tests/unit/testsuite/Magento/Store/Block/SwitchTest.php index 9d0447f17fa439da14386a2f57d205493eee6dd5..8ecbdca177c499622e5b711b957c2dfc350ba8c3 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Block/SwitchTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Block/SwitchTest.php @@ -42,7 +42,7 @@ class SwitchTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_block = $helper->getObject( diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/Config/Reader/StoreTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/Config/Reader/StoreTest.php index b471118fa3d9c0c074a4b2f1e5e4ae1d5d9774bf..f763f4dd951fd497b0989aae31a3885061a6a541 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/Config/Reader/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/Config/Reader/StoreTest.php @@ -58,7 +58,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_scopePullMock = $this->getMock('Magento\Framework\App\Config\ScopePool', [], [], '', false); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_initialConfigMock = $this->getMock('Magento\Framework\App\Config\Initial', [], [], '', false); $this->_collectionFactory = $this->getMock( 'Magento\Store\Model\Resource\Config\Collection\ScopedFactory', diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/StoreTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/StoreTest.php index 0f99532854377ce2eeef6a2e823717a88ba56e8e..d68c9f8f53fc55e9f3626eb590e06b71dd0f6dd9 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/StoreTest.php @@ -42,7 +42,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', @@ -71,7 +71,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetScopeWithInvalidScope() { diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/WebsiteTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/WebsiteTest.php index 0bc15428b187fd78c41ad99a9bbba1e1ed1e642d..f13377811ea8ad0f728b71e5472f5d57c0216277 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/WebsiteTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/WebsiteTest.php @@ -42,7 +42,7 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', @@ -71,7 +71,7 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetScopeWithInvalidScope() { diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/Storage/DbTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/Storage/DbTest.php index 5afae729e73fc8ccad0d766f73c54ecd53bda7cf..4b264695e01dd49697bd950cd524693e78f0b13d 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/Storage/DbTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/Storage/DbTest.php @@ -116,7 +116,7 @@ class DbTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetWebsiteInvalidId() { @@ -162,7 +162,7 @@ class DbTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetGroupInvalidId() { diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php index 81400abe380868a3c9c8da93fe4e33149fd45894..c28ada75cde1ba2aa2d26c7433c5b553d6ab50a4 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php @@ -122,16 +122,6 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase */ protected $request; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cookieManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cookieMetadataFactoryMock; - /** * @var \Magento\TestFramework\Helper\ObjectManager */ @@ -159,17 +149,10 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false); + $this->_storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_httpContext = $this->getMock('Magento\Framework\App\Http\Context', [], [], '', false); $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->request = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $this->cookieMetadataFactoryMock = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', - [], - [], - '', - false - ); $this->_model = $this->helper->getObject('\Magento\Store\Model\StorageFactory', [ 'objectManager' => $this->_objectManagerMock, @@ -177,11 +160,9 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase 'logger' => $this->_logMock, 'sidResolver' => $this->_sidResolverMock, 'appState' => $this->_appStateMock, - 'cookieManager' => $this->cookieManagerMock, 'httpContext' => $this->_httpContext, 'scopeConfig' => $this->_scopeConfig, 'request' => $this->request, - 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock ]); $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); @@ -383,7 +364,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetWithStoresReinitUnknownScopeType() { @@ -416,16 +397,12 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->store->expects($this->once())->method('getId')->will($this->returnValue(21)); $this->store->expects($this->once())->method('getIsActive')->will($this->returnValue(true)); + $this->store->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('store1')); $this->storage->expects($this->any())->method('setCurrentStore')->with('store1'); $this->_objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($this->storage)); - $this->cookieManagerMock->expects($this->atLeastOnce()) - ->method('getCookie') - ->with(Store::COOKIE_NAME) - ->will($this->returnValue('store1')); - $this->assertEquals($this->storage, $this->_model->get($this->_arguments)); } @@ -450,8 +427,9 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase * * @param bool $isActiveStore * @param bool $isDefault + * @param string $cookieCall */ - public function testGetFromRequest($isActiveStore, $isDefault) + public function testGetFromRequest($isActiveStore, $isDefault, $cookieCall = '') { $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); @@ -475,15 +453,13 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->store->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(21)); $this->store->expects($this->once())->method('getIsActive')->will($this->returnValue($isActiveStore)); $this->store->expects($this->any())->method('getWebsite')->will($this->returnValue($this->website)); - + if (!empty($cookieCall)) { + $this->store->expects($this->once())->method($cookieCall); + } $this->storage->expects($this->any())->method('setCurrentStore')->with('store1'); $numCreateCookieCalls = $isDefault ? 0 : 1; $this->_objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($this->storage)); - $cookieMetadata = $this->helper->getObject('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', []); - $this->cookieMetadataFactoryMock->expects($this->exactly($numCreateCookieCalls)) - ->method('createPublicCookieMetadata') - ->will($this->returnValue($cookieMetadata)); $this->request->expects($this->atLeastOnce()) ->method('getParam') @@ -500,8 +476,8 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase { return [ [false, true], - [true, true], - [true, false], + [true, true, 'deleteCookie'], + [true, false, 'setCookie'], ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StoreManagerTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StoreManagerTest.php index ae7589476e3e2d8ca3fffb8a5d17f3aa590bdeb5..a128399e79f79d3a99dc71c15245090fc26f9c1d 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StoreManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StoreManagerTest.php @@ -63,7 +63,7 @@ class StoreManagerTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_storage = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storage = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_model = new \Magento\Store\Model\StoreManager( $this->_factoryMock, diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php index 61001e986b6a9200ce65538147b657a0d8af6c71..30993b8d447d352f3a6ad205aadd028ee3235252 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php @@ -39,6 +39,16 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ protected $requestMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Stdlib\CookieManager + */ + protected $cookieManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $cookieMetadataFactoryMock; + public function setUp() { $this->objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -53,6 +63,14 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'getCookie', 'getDistroBaseUrl', ], [], '', false); + $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false); + $this->cookieMetadataFactoryMock = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', + [], + [], + '', + false + ); } /** @@ -66,7 +84,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Resource\Store $resource */ $resource = $this->getMock( '\Magento\Store\Model\Resource\Store', - array('load', 'getIdFieldName', '__wakeup'), + ['load', 'getIdFieldName', '__wakeup'], [], '', false @@ -76,21 +94,21 @@ class StoreTest extends \PHPUnit_Framework_TestCase ->will($this->returnSelf()); $resource->expects($this->atLeastOnce())->method('getIdFieldName')->will($this->returnValue('store_id')); /** @var \Magento\Store\Model\Store $model */ - $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', array('resource' => $resource)); + $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', ['resource' => $resource]); $model->load($key); } public function loadDataProvider() { - return array( - array(1, null), - array('default', 'code'), - ); + return [ + [1, null], + ['default', 'code'], + ]; } public function testSetWebsite() { - $website = $this->getMock('\Magento\Store\Model\Website', array('getId', '__wakeup'), [], '', false); + $website = $this->getMock('\Magento\Store\Model\Website', ['getId', '__wakeup'], [], '', false); $website->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(2)); /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store'); @@ -106,7 +124,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testGetWebsite($websiteId, $website) { - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any()) ->method('getWebsite') ->with($websiteId) @@ -114,7 +132,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array('storeManager' => $storeManager) + ['storeManager' => $storeManager] ); $model->setWebsiteId($websiteId); $this->assertEquals($website, $model->getWebsite()); @@ -122,17 +140,17 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function getWebsiteDataProvider() { - $website = $this->getMock('\Magento\Store\Model\Website', array('__wakeup'), [], '', false); - return array( - array(null, false), - array(2, $website) - ); + $website = $this->getMock('\Magento\Store\Model\Website', ['__wakeup'], [], '', false); + return [ + [null, false], + [2, $website] + ]; } public function testGetUrl() { - $params = array('_scope_to_url' => true); - $defaultStore = $this->getMock('\Magento\Store\Model\Store', array('getId', '__wakeup'), [], '', false); + $params = ['_scope_to_url' => true]; + $defaultStore = $this->getMock('\Magento\Store\Model\Store', ['getId', '__wakeup'], [], '', false); $defaultStore->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(5)); @@ -142,7 +160,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo('test/route'), $this->equalTo($params)) ->will($this->returnValue('http://test/url')); - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any()) ->method('getStore') ->will($this->returnValue($defaultStore)); @@ -150,7 +168,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array('storeManager' => $storeManager, 'url' => $url) + ['storeManager' => $storeManager, 'url' => $url] ); $model->setStoreId(2); $this->assertEquals('http://test/url', $model->getUrl('test/route')); @@ -188,11 +206,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array( + [ 'config' => $configMock, 'request' => $this->requestMock, 'isCustomEntryPoint' => !$secure, - ) + ] ); $model->setCode('scopeCode'); $this->assertEquals($expectedBaseUrl, $model->getBaseUrl($type, $secure)); @@ -200,56 +218,56 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function getBaseUrlDataProvider() { - return array( - array( + return [ + [ \Magento\Framework\UrlInterface::URL_TYPE_WEB, false, 'web/unsecure/base_url', 'http://domain.com/web/unsecure/base_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_LINK, false, 'web/unsecure/base_link_url', 'http://domain.com/web/unsecure/base_link_url/index.php/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, 'web/unsecure/base_link_url', 'http://domain.com/web/unsecure/base_link_url/index.php/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, 'web/unsecure/base_media_url', 'http://domain.com/web/unsecure/base_media_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, 'web/unsecure/base_static_url', 'http://domain.com/web/unsecure/base_static_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, 'web/unsecure/base_url', 'http://domain.com/web/unsecure/base_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, 'web/unsecure/base_url', 'http://domain.com/web/unsecure/base_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_WEB, true, 'web/secure/base_url', 'http://distro.com/web/secure/base_url/' - ), - ); + ], + ]; } public function testGetBaseUrlEntryPoint() @@ -268,10 +286,10 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array( + [ 'config' => $configMock, 'isCustomEntryPoint' => false, - ) + ] ); $model->setCode('scopeCode'); $server = $_SERVER; @@ -304,11 +322,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testGetCurrentUrl($secure, $url, $expected) { - $defaultStore = $this->getMock('\Magento\Store\Model\Store', array( + $defaultStore = $this->getMock('\Magento\Store\Model\Store', [ 'getId', 'isCurrentlySecure', '__wakeup' - ), [], '', false); + ], [], '', false); $defaultStore->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(5)); $defaultStore->expects($this->atLeastOnce())->method('isCurrentlySecure')->will($this->returnValue($secure)); @@ -319,9 +337,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase $this->requestMock->expects($this->atLeastOnce())->method('getRequestString')->will($this->returnValue('')); - $this->requestMock->expects($this->atLeastOnce())->method('getQuery')->will($this->returnValue(array( + $this->requestMock->expects($this->atLeastOnce())->method('getQuery')->will($this->returnValue([ 'SID' => 'sid' - ))); + ])); $urlMock = $this->getMockForAbstractClass('\Magento\Framework\UrlInterface'); @@ -329,7 +347,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase $urlMock->expects($this->any())->method('getUrl') ->will($this->returnValue($url)); - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any()) ->method('getStore') ->will($this->returnValue($defaultStore)); @@ -350,11 +368,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getCurrentUrlDataProvider() { - return array( - array(true, 'http://test/url', 'http://test/url?SID=sid&___store=scope_code'), - array(true, 'http://test/url?SID=sid1&___store=scope', 'http://test/url?SID=sid&___store=scope_code'), - array(false, 'https://test/url', 'https://test/url?SID=sid&___store=scope_code') - ); + return [ + [true, 'http://test/url', 'http://test/url?SID=sid&___store=scope_code'], + [true, 'http://test/url?SID=sid1&___store=scope', 'http://test/url?SID=sid&___store=scope_code'], + [false, 'https://test/url', 'https://test/url?SID=sid&___store=scope_code'] + ]; } public function testGetPriceFilter() @@ -403,18 +421,18 @@ class StoreTest extends \PHPUnit_Framework_TestCase $config = $this->getMockForAbstractClass('\Magento\Framework\App\Config\ReinitableConfigInterface'); $config->expects($this->any()) ->method('getValue') - ->will($this->returnValueMap(array( - array('catalog/price/scope', ScopeInterface::SCOPE_STORE, 'scope_code', $priceScope), - array('currency/options/base', \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null, 'USD'), - array('currency/options/base', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, 'scope_code', 'UAH'), - ))); + ->will($this->returnValueMap([ + ['catalog/price/scope', ScopeInterface::SCOPE_STORE, 'scope_code', $priceScope], + ['currency/options/base', \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null, 'USD'], + ['currency/options/base', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, 'scope_code', 'UAH'], + ])); $currency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $currency->expects($this->any())->method('load')->with($currencyCode)->will($this->returnSelf()); $currencyFactory = $this->getMock( '\Magento\Directory\Model\CurrencyFactory', - array('create', 'load') + ['create', 'load'] ); $currencyFactory->expects($this->any())->method('create')->will($this->returnValue($currency)); @@ -422,7 +440,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase $appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', - array('currencyFactory' => $currencyFactory, 'config' => $config, 'appState' => $appState) + ['currencyFactory' => $currencyFactory, 'config' => $config, 'appState' => $appState] ); $model->setCode('scope_code'); $this->assertEquals($currency, $model->getBaseCurrency()); @@ -433,16 +451,16 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getBaseCurrencyDataProvider() { - return array( - array(0, 'USD'), - array(1, 'UAH'), - ); + return [ + [0, 'USD'], + [1, 'UAH'], + ]; } public function testGetAllowedCurrencies() { $currencyPath = 'cur/ren/cy/path'; - $expectedResult = array('EUR', 'USD'); + $expectedResult = ['EUR', 'USD']; $configMock = $this->getMockForAbstractClass( 'Magento\Framework\App\Config\ReinitableConfigInterface', @@ -456,11 +474,75 @@ class StoreTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('EUR,USD')); /** @var \Magento\Store\Model\Store $model */ - $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', array( + $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', [ 'config' => $configMock, 'currencyInstalled' => $currencyPath, - )); + ]); $this->assertEquals($expectedResult, $model->getAllowedCurrencies()); } + + public function testSetCookie() + { + $storeCode = 'store code'; + $cookieMetadata = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [], + [], + '', + false + ); + $cookieMetadata->expects($this->once()) + ->method('setHttpOnly') + ->with(true) + ->willReturnSelf(); + $cookieMetadata->expects($this->once()) + ->method('setDurationOneYear') + ->willReturnSelf(); + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($cookieMetadata)); + $this->cookieManagerMock->expects($this->once()) + ->method('setPublicCookie') + ->with(Store::COOKIE_NAME, $storeCode, $cookieMetadata); + /** @var \Magento\Store\Model\Store $model */ + $model = $this->objectManagerHelper->getObject( + 'Magento\Store\Model\Store', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + ]); + $model->setCode($storeCode); + $model->setCookie(); + } + + public function testGetStoreCodeFromCookie() + { + $this->cookieManagerMock->expects($this->once()) + ->method('getCookie') + ->with(Store::COOKIE_NAME); + /** @var \Magento\Store\Model\Store $model */ + $model = $this->objectManagerHelper->getObject( + 'Magento\Store\Model\Store', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + ]); + $model->getStoreCodeFromCookie(); + } + + public function testDeleteCookie() + { + $this->cookieManagerMock->expects($this->once()) + ->method('deleteCookie') + ->with(Store::COOKIE_NAME); + /** @var \Magento\Store\Model\Store $model */ + $model = $this->objectManagerHelper->getObject( + 'Magento\Store\Model\Store', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + ]); + $model->deleteCookie(); + } } diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StoresConfigTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StoresConfigTest.php index 4653c596eda27e180e33962d98ab399185c6e1ce..7890dd4efc63675c02228cf18f47d89dff065a1c 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StoresConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StoresConfigTest.php @@ -57,7 +57,7 @@ class StoresConfigTest extends \PHPUnit_Framework_TestCase { $this->_storeOne = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->_storeTwo = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); - $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_config = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->_model = new \Magento\Store\Model\StoresConfig( diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php index a611c653ae365a66e4995e439b2373384f93318a..70df030b661430cd5d243e5f40556a6a3470dda4 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php @@ -38,7 +38,7 @@ class CalculationTest extends \PHPUnit_Framework_TestCase { // create the mocks $resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); $taxData = $this->getMock('Magento\Tax\Helper\Data', ['getPostCodeSubStringLength'], [], '', false); $taxData diff --git a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxCalculationServiceTest.php b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxCalculationServiceTest.php index b13cd650e6f034cc0f52c1b1fd14e196e429bf69..ddfee97f6a14e564558f4120038510f035ddc8b8 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxCalculationServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxCalculationServiceTest.php @@ -46,7 +46,7 @@ class TaxCalculationServiceTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Tax\Service\V1\Data\TaxDetailsBuilder */ private $taxDetailsBuilder; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface */ + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\StoreManagerInterface */ private $storeManager; /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Tax\Model\Calculation\CalculatorFactory */ @@ -56,7 +56,7 @@ class TaxCalculationServiceTest extends \PHPUnit_Framework_TestCase { $objectManager = new ObjectManager($this); $this->quoteDetailsBuilder = $objectManager->getObject('Magento\Tax\Service\V1\Data\QuoteDetailsBuilder'); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor()->getMock(); $this->calculatorFactory = $this->getMockBuilder('Magento\Tax\Model\Calculation\CalculatorFactory') ->disableOriginalConstructor()->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/Config/CustomizationTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/Config/CustomizationTest.php index 032fde9d4de49da232893532d7d527ed83642854..f1f4e2abd0ab98a625a7653e9be26f9e6f5610d0 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Model/Config/CustomizationTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Model/Config/CustomizationTest.php @@ -30,7 +30,7 @@ namespace Magento\Theme\Model\Config; class CustomizationTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -57,7 +57,7 @@ class CustomizationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storeManager = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), '', true, diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php index 1c7691151911ee3a7424bd8a3b2109ad90d92494..e79991c8712071b6855f7ee7ec90fc3fadfa67fa 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php @@ -69,7 +69,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase /** @var $this->_themeMock \Magento\Core\Model\Theme */ $this->_themeMock = $this->getMock('Magento\Core\Model\Theme', array(), array(), '', false); $this->_storeManagerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), '', true, diff --git a/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php b/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php index d1646b52df9e6ef0511adac6ea0e02b574f3cf8b..a698b79d63ba406cb359ce9ad6619c6df6da9990 100644 --- a/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php @@ -55,7 +55,7 @@ class UserTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Mail\TransportInterface|PHPUnit_Framework_MockObject_MockObject */ protected $_transportMock; - /** @var \Magento\Store\Model\StoreManagerInterface|PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|PHPUnit_Framework_MockObject_MockObject */ protected $_storeManagerMock; /** @var \Magento\Store\Model\Store|PHPUnit_Framework_MockObject_MockObject */ @@ -130,7 +130,7 @@ class UserTest extends \PHPUnit_Framework_TestCase array() )->getMock(); $this->_storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->setMethods( array() )->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php index b3da4eb68bc330ca97d39cb6cddb96c48e5def30..680ddc7fe1c033d2bc80dfba0af0917c2a563256 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php @@ -33,34 +33,49 @@ use Magento\Framework\Exception\AuthorizationException; */ class RestTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Webapi\Controller\Rest */ + /** + * @var \Magento\Webapi\Controller\Rest + */ protected $_restController; - /** @var \Magento\Webapi\Controller\Rest\Request */ + /** + * @var \Magento\Webapi\Controller\Rest\Request + */ protected $_requestMock; - /** @var \Magento\Webapi\Controller\Rest\Response */ + /** + * @var \Magento\Webapi\Controller\Rest\Response + */ protected $_responseMock; - /** @var \Magento\Webapi\Controller\Rest\Router */ + /** + * @var \Magento\Webapi\Controller\Rest\Router + */ protected $_routerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Webapi\Controller\Rest\Router\Route */ + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Webapi\Controller\Rest\Router\Route + */ protected $_routeMock; - /** @var \Magento\Framework\ObjectManager */ + /** + * @var \Magento\Framework\ObjectManager + */ protected $_objectManagerMock; - /** @var \stdClass */ + /** + * @var \stdClass + */ protected $_serviceMock; - /** @var \Magento\Framework\App\State */ - protected $_appStateMock; - - /** @var \Magento\Framework\Oauth\OauthInterface */ + /** + * @var \Magento\Framework\Oauth\OauthInterface + */ protected $_oauthServiceMock; - /** @var \Magento\Framework\AuthorizationInterface */ + /** + * @var \Magento\Framework\AuthorizationInterface + */ protected $_authorizationMock; /** @@ -155,20 +170,6 @@ class RestTest extends \PHPUnit_Framework_TestCase parent::setUp(); } - /** - * Test redirected to install page - */ - public function testRedirectToInstallPage() - { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(false)); - $expectedMsg = 'Magento is not yet installed'; - - $this->_restController->dispatch($this->_requestMock); - $this->assertTrue($this->_responseMock->isException()); - $exceptionArray = $this->_responseMock->getException(); - $this->assertEquals($expectedMsg, $exceptionArray[0]->getMessage()); - } - /** * Test Secure Request and Secure route combinations * @@ -176,7 +177,6 @@ class RestTest extends \PHPUnit_Framework_TestCase */ public function testSecureRouteAndRequest($isSecureRoute, $isSecureRequest) { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue([])); $this->_routeMock->expects($this->any())->method('isSecure')->will($this->returnValue($isSecureRoute)); $this->_routeMock->expects($this->once())->method('getParameters')->will($this->returnValue([])); @@ -205,7 +205,6 @@ class RestTest extends \PHPUnit_Framework_TestCase */ public function testInSecureRequestOverSecureRoute() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue([])); $this->_routeMock->expects($this->any())->method('isSecure')->will($this->returnValue(true)); $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['1'])); @@ -224,11 +223,10 @@ class RestTest extends \PHPUnit_Framework_TestCase public function testAuthorizationFailed() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(false)); $this->_oauthServiceMock->expects( $this->any())->method('validateAccessTokenRequest')->will($this->returnValue('fred') - ); + ); $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['5', '6'])); $this->_restController->dispatch($this->_requestMock); @@ -253,7 +251,6 @@ class RestTest extends \PHPUnit_Framework_TestCase { $this->_routeMock->expects($this->once())->method('getParameters')->will($this->returnValue($parameters)); $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['1'])); - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); $this->_requestMock->expects($this->any())->method('getRequestData')->will($this->returnValue($requestData)); $this->userContextMock->expects($this->any())->method('getUserId')->will($this->returnValue($userId)); @@ -328,4 +325,4 @@ class TestService { return null; } -} +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php index ee5bca50adad72a924374d492f06dee579b35087..25f780582ddf058df514f6fc0602cb57feb7c5f8 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php @@ -96,7 +96,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase $className = 'Magento\Framework\Object'; $methodName = 'testMethod'; $isSecure = false; - $aclResources = array('Magento_TestModule::resourceA'); + $aclResources = array(array('Magento_TestModule::resourceA')); $this->_apiConfigMock->expects($this->once()) ->method('getServiceMethodInfo') ->with($operationName, $requestedServices) diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php index a84ec784d38b37187f4fc5c1bb75f24804567195..20bf17149153cfe156d18d197942417d0b014e89 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php @@ -27,27 +27,36 @@ namespace Magento\Webapi\Controller; class SoapTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Webapi\Controller\Soap */ + /** + * @var \Magento\Webapi\Controller\Soap + */ protected $_soapController; - /** @var \Magento\Webapi\Model\Soap\Server */ + /** + * @var \Magento\Webapi\Model\Soap\Server + */ protected $_soapServerMock; - /** @var \Magento\Webapi\Model\Soap\Wsdl\Generator */ + /** + * @var \Magento\Webapi\Model\Soap\Wsdl\Generator + */ protected $_wsdlGeneratorMock; - /** @var \Magento\Webapi\Controller\Soap\Request */ + /** + * @var \Magento\Webapi\Controller\Soap\Request + */ protected $_requestMock; - /** @var \Magento\Webapi\Controller\Response */ + /** + * @var \Magento\Webapi\Controller\Response + */ protected $_responseMock; - /** @var \Magento\Webapi\Controller\ErrorProcessor */ + /** + * @var \Magento\Webapi\Controller\ErrorProcessor + */ protected $_errorProcessorMock; - /** @var \Magento\Framework\App\State */ - protected $_appStateMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Locale\ResolverInterface */ @@ -118,42 +127,11 @@ class SoapTest extends \PHPUnit_Framework_TestCase ); } - /** - * Test redirected to install page - */ - public function testRedirectToInstallPage() - { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(false)); - $this->_errorProcessorMock->expects($this->any())->method('maskException')->will($this->returnArgument(0)); - $encoding = "utf-8"; - $this->_soapServerMock->expects($this->any())->method('getApiCharset')->will($this->returnValue($encoding)); - - $this->_soapController->dispatch($this->_requestMock); - $expectedMessage = <<<EXPECTED_MESSAGE -<?xml version="1.0" encoding="{$encoding}"?> -<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" > - <env:Body> - <env:Fault> - <env:Code> - <env:Value>env:Sender</env:Value> - </env:Code> - <env:Reason> - <env:Text xml:lang="en">Magento is not yet installed</env:Text> - </env:Reason> - </env:Fault> - </env:Body> -</env:Envelope> -EXPECTED_MESSAGE; - - $this->assertXmlStringEqualsXmlString($expectedMessage, $this->_responseMock->getBody()); - } - /** * Test successful WSDL content generation. */ public function testDispatchWsdl() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_mockGetParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL, 1); $wsdl = 'Some WSDL content'; $this->_wsdlGeneratorMock->expects($this->any())->method('generate')->will($this->returnValue($wsdl)); @@ -167,7 +145,6 @@ EXPECTED_MESSAGE; */ public function testDispatchSoapRequest() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_soapServerMock->expects($this->once())->method('handle'); $response = $this->_soapController->dispatch($this->_requestMock); $this->assertEquals(200, $response->getHttpResponseCode()); @@ -178,7 +155,6 @@ EXPECTED_MESSAGE; */ public function testDispatchWithException() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $exceptionMessage = 'some error message'; $exception = new \Magento\Webapi\Exception($exceptionMessage); $this->_soapServerMock->expects($this->any())->method('handle')->will($this->throwException($exception)); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php index eb66ff88f74e57e6bcf8335276ed623758edfc94..97b6eb20476b4de361db753b6db69095d0c1661c 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php @@ -39,7 +39,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\DomDocument\Factory */ protected $_domDocumentFactory; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManagerMock; /** @var \Magento\Webapi\Model\Soap\Server\Factory */ diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php index 51316482330a193eb4a642bd68b9981f3aae84f0..29679944e47086d9abe9f0c8b1eb5581d17a057e 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php @@ -42,7 +42,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $_typeProcessor; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; protected function setUp() @@ -91,7 +91,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ); $this->storeManagerMock = $this->getMockBuilder( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->setMethods(['getStore'])->disableOriginalConstructor()->getMockForAbstractClass(); $storeMock = $this->getMockBuilder( diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DataFromArrayTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DataFromArrayTest.php index f1aecef20a56b65daec1bf784fe514d1bd003cab..31a891d2017937e9768e26c977f44089aed3c307 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DataFromArrayTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DataFromArrayTest.php @@ -37,7 +37,10 @@ class DataFromArrayTest extends \PHPUnit_Framework_TestCase $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $objectFactory = new \Magento\Webapi\Service\Entity\WebapiObjectManager($objectManager); $typeProcessor = $objectManager->getObject('Magento\Webapi\Model\Config\ClassReflector\TypeProcessor'); - $this->serializer = new ServiceArgsSerializer($typeProcessor, $objectFactory); + $this->serializer = $objectManager->getObject( + 'Magento\Webapi\Controller\ServiceArgsSerializer', + ['typeProcessor' => $typeProcessor, 'objectManager' => $objectFactory] + ); } public function testSimpleProperties() diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Helper/DataTest.php index 6e3b32a5270a3ca798f96ad7b38a01d833d7563b..70b58ed5e574d06eed101b00c1e35ef444efd1eb 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Helper/DataTest.php @@ -42,7 +42,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ->with('wishlist/index/cart', array('item' => '%item%', 'uenc' => $encoded)) ->will($this->returnValue($url)); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $storeManager->expects($this->any()) ->method('getStore') ->will($this->returnValue($store)); diff --git a/app/code/Magento/Install/Controller/Wizard/Index.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/AuthenticationStateTest.php similarity index 80% rename from app/code/Magento/Install/Controller/Wizard/Index.php rename to dev/tests/unit/testsuite/Magento/Wishlist/Model/AuthenticationStateTest.php index 2c1bd21c85b7e13c1d6e91bbace312a343ab8ec6..62d0c563b58c28343595519f9dee70aee1498df4 100644 --- a/app/code/Magento/Install/Controller/Wizard/Index.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/AuthenticationStateTest.php @@ -22,17 +22,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; +namespace Magento\Wishlist\Model; -class Index extends \Magento\Install\Controller\Wizard +class AuthenticationStateTest extends \PHPUnit_Framework_TestCase { - /** - * Index action - * - * @return void - */ - public function execute() + public function testIsEnabled() { - $this->_redirect('*/*/begin'); + $this->assertTrue((new AuthenticationState())->isEnabled()); } } + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ConfigTest.php index b2bcb25f5980423cad9339bcbefd703ad3ca27ae..69665d3a4b84f5caaabf08c6a161e7be0de42e91 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ConfigTest.php @@ -28,60 +28,58 @@ class ConfigTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Wishlist\Model\Config */ - protected $_model; + protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $_catalogConfig; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Model\Attribute\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $_attributeConfig; protected function setUp() { - $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->_catalogConfig = $this->getMock('Magento\Catalog\Model\Config', array(), array(), '', false); - $this->_attributeConfig = $this->getMock( - 'Magento\Catalog\Model\Attribute\Config', - array(), - array(), - '', - false - ); - $this->_model = new \Magento\Wishlist\Model\Config( - $this->_scopeConfig, - $this->_catalogConfig, - $this->_attributeConfig - ); + $this->_scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')->getMock(); + $this->_catalogConfig = $this->getMockBuilder('Magento\Catalog\Model\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->_attributeConfig = $this->getMockBuilder('Magento\Catalog\Model\Attribute\Config') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new Config($this->_scopeConfig, $this->_catalogConfig, $this->_attributeConfig); } public function testGetProductAttributes() { - $this->_catalogConfig->expects( - $this->once() - )->method( - 'getProductAttributes' - )->will( - $this->returnValue(array('attribute_one', 'attribute_two')) - ); - $this->_attributeConfig->expects( - $this->once() - )->method( - 'getAttributeNames' - )->with( - 'wishlist_item' - )->will( - $this->returnValue(array('attribute_three')) - ); - $expectedResult = array('attribute_one', 'attribute_two', 'attribute_three'); - $this->assertEquals($expectedResult, $this->_model->getProductAttributes()); + $expectedResult = ['attribute_one', 'attribute_two', 'attribute_three']; + + $this->_catalogConfig->expects($this->once()) + ->method('getProductAttributes') + ->willReturn(['attribute_one', 'attribute_two']); + $this->_attributeConfig->expects($this->once()) + ->method('getAttributeNames') + ->with('wishlist_item') + ->willReturn(['attribute_three']); + + $this->assertEquals($expectedResult, $this->model->getProductAttributes()); + } + + public function testGetSharingEmailLimit() + { + $this->assertEquals(Config::SHARING_EMAIL_LIMIT, $this->model->getSharingEmailLimit()); + } + + public function testGetSharingTextLimit() + { + $this->assertEquals(Config::SHARING_TEXT_LIMIT, $this->model->getSharingTextLimit()); } } diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ItemTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ItemTest.php index 6f71067757345126e489a5225830e29e5473848d..b3b9a875fdf3693c99bd3f57adf50042f7eeece5 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ItemTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ItemTest.php @@ -24,56 +24,188 @@ namespace Magento\Wishlist\Model; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ItemTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\TestFramework\Helper\ObjectManager + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Catalog\Model\Resource\Url|\PHPUnit_Framework_MockObject_MockObject + */ + protected $catalogUrl; + + /** + * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productTypeConfig; + + /** + * @var \Magento\Wishlist\Model\Resource\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * @var \Magento\Wishlist\Model\Resource\Item\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collection; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManager; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $date; + + /** + * @var \Magento\Wishlist\Model\Item\OptionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $optionFactory; + + /** + * @var \Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemOptFactory; + + /** + * @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $objectManager; + protected $productFactory; /** - * @var \Magento\Wishlist\Model\Item + * @var Item */ - protected $wishlistItem; + protected $model; - protected function setUp() + public function setUp() { - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false); - $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); - $storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], ''); - $dateMock = $this->getMock('\Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false); - $productFactoryMock = $this->getMock('\Magento\Catalog\Model\ProductFactory', [], [], '', false); - $catalogUrlMock = $this->getMock('\Magento\Catalog\Model\Resource\Url', [], [], '', false); - $wishlistOptFactoryMock = $this->getMock('\Magento\Wishlist\Model\Item\OptionFactory', [], [], '', false); - $wishlOptionCollectionFactoryMock = $this->getMock( - 'Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory', - [], - [], - '', - false - ); - $productTypeConfigMock = $this->getMock( - '\Magento\Catalog\Model\ProductTypes\ConfigInterface', - [], - [], - '' + $context = $this->getMockBuilder('Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->getMock(); + $this->date = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + ->disableOriginalConstructor() + ->getMock(); + $this->productFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->catalogUrl = $this->getMockBuilder('Magento\Catalog\Model\Resource\Url') + ->disableOriginalConstructor() + ->getMock(); + $this->optionFactory = $this->getMockBuilder('Magento\Wishlist\Model\Item\OptionFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->itemOptFactory = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->productTypeConfig = $this->getMockBuilder('Magento\Catalog\Model\ProductTypes\ConfigInterface') + ->getMock(); + $this->resource = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item') + ->disableOriginalConstructor() + ->getMock(); + $this->collection = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new Item( + $context, + $this->registry, + $this->storeManager, + $this->date, + $this->productFactory, + $this->catalogUrl, + $this->optionFactory, + $this->itemOptFactory, + $this->productTypeConfig, + $this->resource, + $this->collection, + array() ); + } + + /** + * @dataProvider getOptionsDataProvider + */ + public function testAddGetOptions($code, $option) + { + $this->assertEmpty($this->model->getOptions()); + $optionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + ->disableOriginalConstructor() + ->setMethods(array('setData', 'getCode', '__wakeup')) + ->getMock(); + $optionMock->expects($this->any()) + ->method('setData') + ->willReturnSelf(); + $optionMock->expects($this->any()) + ->method('getCode') + ->willReturn($code); + + $this->optionFactory->expects($this->any()) + ->method('create') + ->willReturn($optionMock); + $this->model->addOption($option); + $this->assertEquals(1, count($this->model->getOptions())); + } - $this->wishlistItem = $this->objectManager->getObject( - '\Magento\Wishlist\Model\Item', - [ - 'context' => $contextMock, - 'registry' => $registryMock, - 'storeManager' => $storeManagerMock, - 'date' => $dateMock, - 'productFactory' => $productFactoryMock, - 'catalogUrl' => $catalogUrlMock, - 'wishlistOptFactory' => $wishlistOptFactoryMock, - 'wishlOptionCollectionFactory' => $wishlOptionCollectionFactoryMock, - 'productTypeConfig' => $productTypeConfigMock, - ] + /** + * @dataProvider getOptionsDataProvider + */ + public function testRemoveOptionByCode($code, $option) + { + $this->assertEmpty($this->model->getOptions()); + $optionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + ->disableOriginalConstructor() + ->setMethods(array('setData', 'getCode', '__wakeup')) + ->getMock(); + $optionMock->expects($this->any()) + ->method('setData') + ->willReturnSelf(); + $optionMock->expects($this->any()) + ->method('getCode') + ->willReturn($code); + + $this->optionFactory->expects($this->any()) + ->method('create') + ->willReturn($optionMock); + $this->model->addOption($option); + $this->assertEquals(1, count($this->model->getOptions())); + $this->model->removeOption($code); + $actualOptions = $this->model->getOptions(); + $actualOption = array_pop($actualOptions); + $this->assertTrue($actualOption->isDeleted()); + } + + public function getOptionsDataProvider() + { + $optionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + ->disableOriginalConstructor() + ->setMethods(array('getCode', '__wakeup')) + ->getMock(); + $optionMock->expects($this->any()) + ->method('getCode') + ->willReturn('second_key'); + + $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + return array( + array('first_key', array('code' => 'first_key', 'value' => 'first_data')), + array('second_key',$optionMock), + array('third_key', new \Magento\Framework\Object(array('code' => 'third_key', 'product' => $productMock))), ); } @@ -81,28 +213,22 @@ class ItemTest extends \PHPUnit_Framework_TestCase { $code = 'someOption'; $optionValue = 100; - $optionsOneMock = $this->getMock( - '\Magento\Sales\Model\Quote\Item', - ['getCode', '__wakeup', 'getValue'], - [], - '', - false - ); - $optionsTwoMock = $this->getMock( - '\Magento\Sales\Model\Quote\Item', - ['getValue', '__wakeup'], - [], - '', - false - ); + $optionsOneMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('getCode', '__wakeup', 'getValue')) + ->getMock(); + $optionsTwoMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('__wakeup', 'getValue')) + ->getMock(); $optionsOneMock->expects($this->once())->method('getCode')->will($this->returnValue($code)); $optionsOneMock->expects($this->once())->method('getValue')->will($this->returnValue($optionValue)); $optionsTwoMock->expects($this->once())->method('getValue')->will($this->returnValue($optionValue)); - $result = $this->wishlistItem->compareOptions( - [$code => $optionsOneMock], - [$code => $optionsTwoMock] + $result = $this->model->compareOptions( + array($code => $optionsOneMock), + array($code => $optionsTwoMock) ); $this->assertTrue($result); @@ -113,28 +239,22 @@ class ItemTest extends \PHPUnit_Framework_TestCase $code = 'someOption'; $optionOneValue = 100; $optionTwoValue = 200; - $optionsOneMock = $this->getMock( - '\Magento\Sales\Model\Quote\Item', - ['getCode', '__wakeup', 'getValue'], - [], - '', - false - ); - $optionsTwoMock = $this->getMock( - '\Magento\Sales\Model\Quote\Item', - ['getValue', '__wakeup'], - [], - '', - false - ); + $optionsOneMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('getCode', '__wakeup', 'getValue')) + ->getMock(); + $optionsTwoMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('__wakeup', 'getValue')) + ->getMock(); $optionsOneMock->expects($this->once())->method('getCode')->will($this->returnValue($code)); $optionsOneMock->expects($this->once())->method('getValue')->will($this->returnValue($optionOneValue)); $optionsTwoMock->expects($this->once())->method('getValue')->will($this->returnValue($optionTwoValue)); - $result = $this->wishlistItem->compareOptions( - [$code => $optionsOneMock], - [$code => $optionsTwoMock] + $result = $this->model->compareOptions( + array($code => $optionsOneMock), + array($code => $optionsTwoMock) ); $this->assertFalse($result); @@ -143,14 +263,20 @@ class ItemTest extends \PHPUnit_Framework_TestCase public function testCompareOptionsNegativeOptionsTwoHaveNotOption() { $code = 'someOption'; - $optionsOneMock = $this->getMock('\Magento\Sales\Model\Quote\Item', ['getCode', '__wakeup'], [], '', false); - $optionsTwoMock = $this->getMock('\Magento\Sales\Model\Quote\Item', [], [], '', false); + $optionsOneMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('getCode', '__wakeup')) + ->getMock(); + $optionsTwoMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('__wakeup')) + ->getMock(); $optionsOneMock->expects($this->once())->method('getCode')->will($this->returnValue($code)); - $result = $this->wishlistItem->compareOptions( - [$code => $optionsOneMock], - ['someOneElse' => $optionsTwoMock] + $result = $this->model->compareOptions( + array($code => $optionsOneMock), + array('someOneElse' => $optionsTwoMock) ); $this->assertFalse($result); diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/LocaleQuantityProcessorTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/LocaleQuantityProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f3e9742bed29bbdf0f2f1a22f0e84ef543c4f4dc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/LocaleQuantityProcessorTest.php @@ -0,0 +1,88 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Wishlist\Model; + + +class LocaleQuantityProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var LocaleQuantityProcessor + */ + protected $processor; + + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resolver; + + /** + * @var \Magento\Framework\Filter\LocalizedToNormalized|\PHPUnit_Framework_MockObject_MockObject + */ + protected $filter; + + public function setUp() + { + $this->resolver = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface')->getMock(); + $this->filter = $this->getMockBuilder('Magento\Framework\Filter\LocalizedToNormalized') + ->disableOriginalConstructor() + ->getMock(); + $this->processor = new LocaleQuantityProcessor($this->resolver, $this->filter); + } + + /** + * @param int $qtyResult + * @param int|null $expectedResult + * @dataProvider processDataProvider + */ + public function testProcess($qtyResult, $expectedResult) + { + $qty = 10; + $localCode = 'en_US'; + + $this->resolver->expects($this->once()) + ->method('getLocaleCode') + ->willReturn($localCode); + + $this->filter->expects($this->once()) + ->method('setOptions') + ->with(['locale' => $localCode]) + ->willReturnSelf(); + + $this->filter->expects($this->once()) + ->method('filter') + ->with($qty) + ->willReturn($qtyResult); + + $this->assertEquals($expectedResult, $this->processor->process($qty)); + } + + public function processDataProvider() + { + return [ + 'positive' => [10.00, 10.00], + 'negative' => [0, null], + ]; + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ObserverTest.php new file mode 100644 index 0000000000000000000000000000000000000000..54c346b2fb16df83b79fe72c9115d9e6d39390a4 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ObserverTest.php @@ -0,0 +1,332 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Wishlist\Model; + + +class ObserverTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Observer + */ + protected $observer; + + /** + * @var \Magento\Wishlist\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + /** + * @var \Magento\Checkout\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSession; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSession; + + /** + * @var \Magento\Wishlist\Model\WishlistFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlistFactory; + + /** + * @var \Magento\Wishlist\Model\Wishlist|\PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlist; + + /** + * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + public function setUp() + { + $this->helper = $this->getMockBuilder('Magento\Wishlist\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + $this->checkoutSession = $this->getMockBuilder('Magento\Checkout\Model\Session') + ->setMethods( + [ + 'getSharedWishlist', + 'getWishlistPendingMessages', + 'getWishlistPendingUrls', + 'getWishlistIds', + 'getSingleWishlistId', + 'setSingleWishlistId', + 'setWishlistIds', + 'setWishlistPendingUrls', + 'setWishlistPendingMessages', + 'setNoCartRedirect', + ] + ) + ->disableOriginalConstructor() + ->getMock(); + $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['setWishlistItemCount', 'isLoggedIn', 'getCustomerId']) + ->getMock(); + $this->wishlistFactory = $this->getMockBuilder('Magento\Wishlist\Model\WishlistFactory') + ->setMethods(['create']) + ->getMock(); + $this->wishlist = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + ->getMock(); + + $this->wishlistFactory->expects($this->any()) + ->method('create') + ->willReturn($this->wishlist); + + $this->observer = new Observer( + $this->helper, + $this->checkoutSession, + $this->customerSession, + $this->wishlistFactory, + $this->messageManager + ); + } + + public function testCustomerLogin() + { + $event = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + /** @var $event \Magento\Framework\Event\Observer */ + + $this->helper->expects($this->once()) + ->method('calculate'); + + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Observer', + $this->observer->customerLogin($event) + ); + } + + public function testCustomerLogout() + { + $event = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + /** @var $event \Magento\Framework\Event\Observer */ + + $this->customerSession->expects($this->once()) + ->method('setWishlistItemCount') + ->with($this->equalTo(0)); + + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Observer', + $this->observer->customerLogout($event) + ); + } + + public function testProcessCartUpdateBefore() + { + $customerId = 1; + $itemId = 5; + $itemQty = 123; + $productId = 321; + + $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + + $event = $this->getMockBuilder('Magento\Framework\Event') + ->setMethods(['getCart', 'getInfo']) + ->disableOriginalConstructor() + ->getMock(); + + $eventObserver->expects($this->any()) + ->method('getEvent') + ->willReturn($event); + + $quoteItem = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->setMethods(['getProductId', 'getBuyRequest']) + ->disableOriginalConstructor() + ->getMock(); + + $buyRequest = $this->getMockBuilder('Magento\Framework\Object') + ->setMethods(['setQty']) + ->disableOriginalConstructor() + ->getMock(); + + $cart = $this->getMockBuilder('Magento\Checkout\Model\Cart')->disableOriginalConstructor()->getMock(); + $quote = $this->getMockBuilder('Magento\Sales\Model\Quote') + ->setMethods(['getCustomerId', 'getItemById', 'removeItem']) + ->disableOriginalConstructor() + ->getMock(); + + $event->expects($this->once()) + ->method('getCart') + ->willReturn($cart); + + $event->expects($this->once()) + ->method('getInfo') + ->willReturn([$itemId => ['qty' => $itemQty, 'wishlist' => true]]); + + $cart->expects($this->any()) + ->method('getQuote') + ->willReturn($quote); + + $quoteItem->expects($this->once()) + ->method('getProductId') + ->willReturn($productId); + $quoteItem->expects($this->once()) + ->method('getBuyRequest') + ->willReturn($buyRequest); + + $buyRequest->expects($this->once()) + ->method('setQty') + ->with($itemQty) + ->willReturnSelf(); + + $quote->expects($this->once()) + ->method('getCustomerId') + ->willReturn($customerId); + + $quote->expects($this->once()) + ->method('getItemById') + ->with($itemId) + ->willReturn($quoteItem); + + $quote->expects($this->once()) + ->method('removeItem') + ->with($itemId); + + $this->wishlist->expects($this->once()) + ->method('loadByCustomerId') + ->with($this->logicalOr($customerId, true)) + ->willReturnSelf(); + + $this->wishlist->expects($this->once()) + ->method('addNewItem') + ->with($this->logicalOr($productId, $buyRequest)); + + $this->wishlist->expects($this->once()) + ->method('save'); + + $this->helper->expects($this->once()) + ->method('calculate'); + + /** @var $eventObserver \Magento\Framework\Event\Observer */ + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Observer', + $this->observer->processCartUpdateBefore($eventObserver) + ); + } + + public function testProcessAddToCart() + { + $wishlistId = 1; + $customerId = 2; + $url = 'http://some.pending/url'; + $message = 'some error msg'; + + $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + $event = $this->getMockBuilder('Magento\Framework\Event') + ->setMethods(['getRequest', 'getResponse']) + ->disableOriginalConstructor() + ->getMock(); + $request = $this->getMockBuilder('Magento\Framework\App\RequestInterface')->getMock(); + $response = $this->getMockBuilder('Magento\Framework\App\ResponseInterface') + ->setMethods(['setRedirect']) + ->getMockForAbstractClass(); + $wishlists = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Wishlist\Collection') + ->disableOriginalConstructor() + ->getMock(); + $loadedWishlist = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist\Item') + ->setMethods(['getId', 'delete']) + ->disableOriginalConstructor() + ->getMock(); + + $eventObserver->expects($this->any())->method('getEvent')->willReturn($event); + + $request->expects($this->any())->method('getParam')->with('wishlist_next')->willReturn(true); + $event->expects($this->once())->method('getRequest')->willReturn($request); + + $this->checkoutSession->expects($this->once())->method('getSharedWishlist'); + $this->checkoutSession->expects($this->once())->method('getWishlistPendingMessages')->willReturn([$message]); + $this->checkoutSession->expects($this->once())->method('getWishlistPendingUrls')->willReturn([$url]); + $this->checkoutSession->expects($this->once())->method('getWishlistIds'); + $this->checkoutSession->expects($this->once())->method('getSingleWishlistId')->willReturn($wishlistId); + + $this->customerSession->expects($this->once()) + ->method('isLoggedIn') + ->willReturn(true); + $this->customerSession->expects($this->once()) + ->method('getCustomerId') + ->willReturn($customerId); + $this->wishlist->expects($this->once()) + ->method('loadByCustomerId') + ->with($this->logicalOr($customerId, true)) + ->willReturnSelf(); + $this->wishlist->expects($this->once()) + ->method('getItemCollection') + ->willReturn($wishlists); + $loadedWishlist->expects($this->once()) + ->method('getId') + ->willReturn($wishlistId); + $loadedWishlist->expects($this->once()) + ->method('delete'); + $wishlists->expects($this->once()) + ->method('load') + ->willReturn([$loadedWishlist]); + $this->checkoutSession->expects($this->once()) + ->method('setWishlistIds') + ->with([]) + ->willReturnSelf(); + $this->checkoutSession->expects($this->once()) + ->method('setSingleWishlistId') + ->with(null) + ->willReturnSelf(); + $this->checkoutSession->expects($this->once()) + ->method('setWishlistPendingUrls') + ->with([]) + ->willReturnSelf(); + $this->checkoutSession->expects($this->once()) + ->method('setWishlistPendingMessages') + ->with([]) + ->willReturnSelf(); + $this->messageManager->expects($this->once()) + ->method('addError') + ->with($message) + ->willReturnSelf(); + $event->expects($this->once()) + ->method('getResponse') + ->willReturn($response); + $response->expects($this->once()) + ->method('setRedirect') + ->with($url); + $this->checkoutSession->expects($this->once()) + ->method('setNoCartRedirect') + ->with(true); + + /** @var $eventObserver \Magento\Framework\Event\Observer */ + $this->observer->processAddToCart($eventObserver); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/WishlistTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/WishlistTest.php new file mode 100644 index 0000000000000000000000000000000000000000..01fadaf9e72ac91fe3ed087754de83d46e24248e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/WishlistTest.php @@ -0,0 +1,303 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Wishlist\Model; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class WishlistTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Catalog\Helper\Product|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productHelper; + + /** + * @var \Magento\Wishlist\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + /** + * @var \Magento\Wishlist\Model\Resource\Wishlist|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * @var \Magento\Wishlist\Model\Resource\Wishlist\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collection; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManager; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $date; + + /** + * @var \Magento\Wishlist\Model\ItemFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemFactory; + + /** + * @var \Magento\Wishlist\Model\Resource\Item\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemsFactory; + + /** + * @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productFactory; + + /** + * @var \Magento\Framework\Math\Random|\PHPUnit_Framework_MockObject_MockObject + */ + protected $mathRandom; + + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTime; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventDispatcher; + + /** + * @var Wishlist + */ + protected $wishlist; + + public function setUp() + { + $context = $this->getMockBuilder('Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->eventDispatcher = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->getMock(); + $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(); + $this->productHelper = $this->getMockBuilder('Magento\Catalog\Helper\Product') + ->disableOriginalConstructor() + ->getMock(); + $this->helper = $this->getMockBuilder('Magento\Wishlist\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + $this->resource = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + $this->collection = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Wishlist\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->getMock(); + $this->date = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + ->disableOriginalConstructor() + ->getMock(); + $this->itemFactory = $this->getMockBuilder('Magento\Wishlist\Model\ItemFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->itemsFactory = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->productFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->mathRandom = $this->getMockBuilder('Magento\Framework\Math\Random') + ->disableOriginalConstructor() + ->getMock(); + $this->dateTime = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime') + ->disableOriginalConstructor() + ->getMock(); + + $context->expects($this->once()) + ->method('getEventDispatcher') + ->will($this->returnValue($this->eventDispatcher)); + + $this->wishlist = new Wishlist( + $context, + $this->registry, + $this->productHelper, + $this->helper, + $this->resource, + $this->collection, + $this->storeManager, + $this->date, + $this->itemFactory, + $this->itemsFactory, + $this->productFactory, + $this->mathRandom, + $this->dateTime, + false + ); + } + + public function testLoadByCustomerId() + { + $customerId = 1; + $customerIdFieldName = 'customer_id'; + $sharingCode = 'expected_sharing_code'; + $this->eventDispatcher->expects($this->any()) + ->method('dispatch'); + $this->resource->expects($this->once()) + ->method('addCommitCallback') + ->will($this->returnSelf()); + $this->resource->expects($this->once()) + ->method('commit'); + $this->resource->expects($this->any()) + ->method('getCustomerIdFieldName'); + $this->resource->expects($this->once()) + ->method('load') + ->with($this->logicalOr($this->wishlist, $customerId, $customerIdFieldName)); + $this->mathRandom->expects($this->once()) + ->method('getUniqueHash') + ->will($this->returnValue($sharingCode)); + + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Wishlist', + $this->wishlist->loadByCustomerId($customerId, true) + ); + $this->assertEquals($customerId, $this->wishlist->getCustomerId()); + $this->assertEquals($sharingCode, $this->wishlist->getSharingCode()); + } + + /** + * @param int|\Magento\Wishlist\Model\Item|\PHPUnit_Framework_MockObject_MockObject $itemId + * @param \Magento\Framework\Object $buyRequest + * @param null|array|\Magento\Framework\Object $param + * @throws \Magento\Framework\Model\Exception + * + * @dataProvider updateItemDataProvider + */ + public function testUpdateItem($itemId, $buyRequest, $param) + { + $storeId = 1; + $productId = 1; + $stores = [(new \Magento\Framework\Object)->setId($storeId)]; + + $newItem = $this->getMockBuilder('Magento\Wishlist\Model\Item')->disableOriginalConstructor()->getMock(); + $newItem->expects($this->any())->method('setProductId')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setWishlistId')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setStoreId')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setOptions')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setProduct')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setQty')->will($this->returnSelf()); + $newItem->expects($this->any())->method('getItem')->will($this->returnValue(2)); + + $this->itemFactory->expects($this->once())->method('create')->will($this->returnValue($newItem)); + + $this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue($stores)); + $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($stores[0])); + + $product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); + $product->expects($this->any())->method('getId')->will($this->returnValue($productId)); + + $instanceType = $this->getMockBuilder('Magento\Catalog\Model\Product\Type\AbstractType') + ->disableOriginalConstructor() + ->getMock(); + $instanceType->expects($this->once()) + ->method('processConfiguration') + ->will( + $this->returnValue( + $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock() + ) + ); + + $newProduct = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); + $newProduct->expects($this->any()) + ->method('setStoreId') + ->with($storeId) + ->will($this->returnSelf()); + $newProduct->expects($this->once()) + ->method('load') + ->with($productId) + ->will($this->returnSelf()); + $newProduct->expects($this->once()) + ->method('getTypeInstance') + ->will($this->returnValue($instanceType)); + + $item = $this->getMockBuilder('Magento\Wishlist\Model\Item')->disableOriginalConstructor()->getMock(); + $item->expects($this->once()) + ->method('getProduct') + ->will($this->returnValue($product)); + + $items = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $items->expects($this->once()) + ->method('addWishlistFilter') + ->will($this->returnSelf()); + $items->expects($this->once()) + ->method('addStoreFilter') + ->will($this->returnSelf()); + $items->expects($this->once()) + ->method('setVisibilityFilter') + ->will($this->returnSelf()); + $items->expects($this->once()) + ->method('getItemById') + ->will($this->returnValue($item)); + $items->expects($this->any()) + ->method('getIterator') + ->will($this->returnValue(new \ArrayIterator([$item]))); + + $this->itemsFactory->expects($this->any()) + ->method('create') + ->will($this->returnValue($items)); + + $this->productFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($newProduct)); + + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Wishlist', + $this->wishlist->updateItem($itemId, $buyRequest, $param) + ); + } + + /** + * @return array + */ + public function updateItemDataProvider() + { + return [ + '0' => [1, new \Magento\Framework\Object(), null], + ]; + } +} + \ No newline at end of file diff --git a/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php b/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php index 88d4e6ed57b5d7daa012983f1295cb0bfa5de8c5..feb6edff6deb9f5cfafd4e56bbc1ead0e78b0fa7 100644 --- a/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php +++ b/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php @@ -22,9 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -define('BP', realpath(__DIR__ . '/../../../../../../') . '/'); - -require_once BP . 'app/autoload.php'; +require_once __DIR__ . '/../../../../../../app/autoload.php'; (new \Magento\Framework\Autoload\IncludePath())->addIncludePath( - array(BP . 'dev/tests/static/framework', BP . 'dev/tools', BP . '/lib') + array(BP . '/dev/tests/static/framework', BP . '/dev/tools') ); diff --git a/dev/tools/Magento/Tools/Migration/themes_view.php b/dev/tools/Magento/Tools/Migration/themes_view.php index 0a74b86fc7f635eb3aa7ec5ab9ceb41ea9d55fd2..e74ee0f20078dc3708b259aec04dfa1198ba8bab 100644 --- a/dev/tools/Magento/Tools/Migration/themes_view.php +++ b/dev/tools/Magento/Tools/Migration/themes_view.php @@ -21,12 +21,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + require_once __DIR__ . '/../../../../../app/bootstrap.php'; -$rootDir = realpath(__DIR__ . '/../../../../..'); +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); try { - $entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint($rootDir, array()); - - $objectManager = new \Magento\Framework\App\ObjectManager(); + $objectManager = $bootstrap->getObjectManager(); /** @var $configModel \Magento\Framework\App\Config\ReinitableConfigInterface */ $configModel = $objectManager->get('Magento\Framework\App\Config\ReinitableConfigInterface'); $configModel->reinit(); diff --git a/dev/tools/Magento/Tools/View/deploy.php b/dev/tools/Magento/Tools/View/deploy.php index f0735222f46a0fd92aa09af9bd966c0cd276c27b..741fd25f77ebeffc6c86bfb98c7b4b58b13a11b1 100644 --- a/dev/tools/Magento/Tools/View/deploy.php +++ b/dev/tools/Magento/Tools/View/deploy.php @@ -30,7 +30,6 @@ $baseName = basename(__FILE__); $options = getopt('', array('langs::', 'dry-run', 'verbose::', 'help')); define('USAGE', "USAGE:\n\tphp -f {$baseName} -- [--langs=en_US,de_DE,...] [--verbose=0|1] [--dry-run] [--help]\n"); -define('BARE_BOOTSTRAP', 1); require __DIR__ . '/../../../../../app/bootstrap.php'; $autoloader = new \Magento\Framework\Autoload\IncludePath(); $autoloader->addIncludePath([BP . '/dev/tests/static/framework', realpath(__DIR__ . '/../../..')]); diff --git a/dev/tools/bootstrap.php b/dev/tools/bootstrap.php index 445c23378b09ca64b5b23125d542d7b779f5be52..06ca15114a447d3915033c2b7ad28e65e77c80f3 100644 --- a/dev/tools/bootstrap.php +++ b/dev/tools/bootstrap.php @@ -22,7 +22,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ require_once __DIR__ . '/../../app/autoload.php'; -define('BP', __DIR__ . '/../..'); (new \Magento\Framework\Autoload\IncludePath())->addIncludePath( array( BP . '/app/code', diff --git a/index.php b/index.php index 6eada12c9022ab6619d48ec0b7142819f3c1f365..9aa971b7efdce3969c8b1ba32fdf4340e7a9d259 100644 --- a/index.php +++ b/index.php @@ -4,11 +4,10 @@ * * Example - run a particular store or website: * -------------------------------------------- - * $params = $_SERVER; - * $params['MAGE_RUN_CODE'] = 'website2'; - * $params['MAGE_RUN_TYPE'] = 'website'; - * ... - * $entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); + * $extra = ['MAGE_RUN_CODE' => 'website2', 'MAGE_RUN_TYPE' => 'website']; + * $bootstrap = new \Magento\Framework\App\Bootstrap(BP, $_SERVER, $extra); + * $app = $bootstrap->createApplication('Magento\Framework\App\Http'); + * $bootstrap->run($app); * -------------------------------------------- * * Magento @@ -32,6 +31,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + require __DIR__ . '/app/bootstrap.php'; -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $_SERVER); -$entryPoint->run('Magento\Framework\App\Http'); +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER, null); +/** @var \Magento\Framework\App\Http $app */ +$app = $bootstrap->createApplication('Magento\Framework\App\Http'); +$bootstrap->run($app); diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..3e1e88961bce9fef8788dc2e1aff3a7803fad957 --- /dev/null +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -0,0 +1,391 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\App; + +use Magento\Framework\Profiler; +use \Magento\Framework\AppInterface; + +/** + * A bootstrap of Magento application + * + * Performs basic initialization root function: injects init parameters and creates object manager + * Can create/run applications + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Bootstrap +{ + /**#+ + * Possible errors that can be triggered by the bootstrap + */ + const ERR_MAINTENANCE = 901; + const ERR_IS_INSTALLED = 902; + /**#- */ + + /**#+ + * Initialization parameters that allow control bootstrap behavior of asserting maintenance mode or is installed + * + * Possible values: + * - true -- set expectation that it is required + * - false -- set expectation that is required not to + * - null -- bypass the assertion completely + * + * If key is absent in the parameters array, the default behavior will be used + * @see DEFAULT_REQUIRE_MAINTENANCE + * @see DEFAULT_REQUIRE_IS_INSTALLED + */ + const PARAM_REQUIRE_MAINTENANCE = 'MAGE_REQUIRE_MAINTENANCE'; + const PARAM_REQUIRE_IS_INSTALLED = 'MAGE_REQUIRE_IS_INSTALLED'; + /**#- */ + + /**#+ + * Default behavior of bootstrap assertions + */ + const DEFAULT_REQUIRE_MAINTENANCE = false; + const DEFAULT_REQUIRE_IS_INSTALLED = true; + /**#- */ + + /** + * The initialization parameters (normally come from the $_SERVER) + * + * @var array + */ + private $server; + + /** + * Root directory + * + * @var string + */ + private $rootDir; + + /** + * Object manager + * + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + /** + * Directory list + * + * @var Filesystem\DirectoryList + */ + private $dirList; + + /** + * Configuration directory + * + * @var \Magento\Framework\Filesystem\Directory\ReadInterface + */ + private $configDir; + + /** + * Maintenance mode manager + * + * @var \Magento\Framework\App\MaintenanceMode + */ + private $maintenance; + + /** + * Bootstrap-specific error code that may have been set in runtime + * + * @var int + */ + private $errorCode = 0; + + /** + * Attribute for creating object manager + * + * @var ObjectManagerFactory + */ + private $factory; + + /** + * Static method so that client code does not have to create Object Manager Factory every time Bootstrap is called + * + * @param string $rootDir + * @param array $initParams + * @param ObjectManagerFactory $factory + * @return Bootstrap + */ + public static function create($rootDir, array $initParams, ObjectManagerFactory $factory = null) + { + if ($factory === null) { + $factory = new ObjectManagerFactory; + } + return new self($factory, $rootDir, $initParams); + } + + /** + * Constructor + * + * @param ObjectManagerFactory $factory + * @param string $rootDir + * @param array $initParams + */ + public function __construct(ObjectManagerFactory $factory, $rootDir, array $initParams) + { + $this->factory = $factory; + $this->rootDir = $rootDir; + $this->server = $initParams; + } + + /** + * Gets the current parameters + * + * @return array + */ + public function getParams() + { + return $this->server; + } + + /** + * Factory method for creating application instances + * + * @param string $type + * @param array $arguments + * @return \Magento\Framework\AppInterface + * @throws \InvalidArgumentException + */ + public function createApplication($type, $arguments = []) + { + try { + $this->init(); + $application = $this->objectManager->create($type, $arguments); + if (!($application instanceof AppInterface)) { + throw new \InvalidArgumentException("The provided class doesn't implement AppInterface: {$type}"); + } + return $application; + } catch (\Exception $e) { + $this->terminate($e); + } + } + + /** + * Runs an application + * + * @param \Magento\Framework\AppInterface $application + * @return void + */ + public function run(AppInterface $application) + { + try { + try { + \Magento\Framework\Profiler::start('magento'); + $this->initErrorHandler(); + $this->init(); + $this->assertMaintenance(); + $this->assertInstalled(); + $response = $application->launch(); + $response->sendResponse(); + \Magento\Framework\Profiler::stop('magento'); + } catch (\Exception $e) { + \Magento\Framework\Profiler::stop('magento'); + if (!$application->catchException($this, $e)) { + throw $e; + } + } + } catch (\Exception $e) { + $this->terminate($e); + } + } + + /** + * Asserts maintenance mode + * + * @return void + * @throws \Exception + */ + protected function assertMaintenance() + { + $isExpected = $this->getIsExpected(self::PARAM_REQUIRE_MAINTENANCE, self::DEFAULT_REQUIRE_MAINTENANCE); + if (null === $isExpected) { + return; + } + $this->init(); + $isOn = $this->maintenance->isOn(isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : ''); + if ($isOn && !$isExpected) { + $this->errorCode = self::ERR_MAINTENANCE; + throw new \Exception('Unable to proceed: the maintenance mode is enabled.'); + } + if (!$isOn && $isExpected) { + $this->errorCode = self::ERR_MAINTENANCE; + throw new \Exception('Unable to proceed: the maintenance mode must be enabled first.'); + } + } + + /** + * Asserts whether application is installed + * + * @return void + * @throws \Exception + */ + protected function assertInstalled() + { + $isExpected = $this->getIsExpected(self::PARAM_REQUIRE_IS_INSTALLED, self::DEFAULT_REQUIRE_IS_INSTALLED); + if (null === $isExpected) { + return; + } + $this->init(); + $isInstalled = $this->isInstalled(); + if (!$isInstalled && $isExpected) { + $this->errorCode = self::ERR_IS_INSTALLED; + throw new \Exception('Application is not installed yet.'); + } + if ($isInstalled && !$isExpected) { + $this->errorCode = self::ERR_IS_INSTALLED; + throw new \Exception('Application is already installed.'); + } + } + + /** + * Analyze a key in the initialization parameters as "is expected" parameter + * + * If there is no such key, returns default value. Otherwise casts it to boolean, unless it is null + * + * @param string $key + * @param bool $default + * @return bool|null + */ + private function getIsExpected($key, $default) + { + if (array_key_exists($key, $this->server)) { + if (isset($this->server[$key])) { + return (bool)(int)$this->server[$key]; + } + return null; + } + return $default; + } + + /** + * Determines whether application is installed + * + * @return bool + */ + private function isInstalled() + { + $this->init(); + return $this->configDir->isExist('local.xml'); + } + + /** + * Gets the object manager instance + * + * @return \Magento\Framework\ObjectManager + */ + public function getObjectManager() + { + $this->init(); + return $this->objectManager; + } + + /** + * Gets the directory list instance + * + * @return Filesystem\DirectoryList + */ + public function getDirList() + { + $this->init(); + return $this->dirList; + } + + /** + * Sets a custom error handler + * + * @return void + */ + private function initErrorHandler() + { + $handler = new ErrorHandler; + set_error_handler([$handler, 'handler']); + } + + /** + * Initializes the essential objects + * + * @return void + */ + private function init() + { + if (!$this->objectManager) { + $this->objectManager = $this->factory->create($this->rootDir, $this->server); + $this->dirList = $this->objectManager->get('Magento\Framework\App\Filesystem\DirectoryList'); + $this->maintenance = $this->objectManager->get('Magento\Framework\App\MaintenanceMode'); + /** @var $fileSystem \Magento\Framework\App\Filesystem */ + $fileSystem = $this->objectManager->get('Magento\Framework\App\Filesystem'); + $this->configDir = $fileSystem->getDirectoryRead(Filesystem::CONFIG_DIR); + } + } + + /** + * Getter for error code + * + * @return int + */ + public function getErrorCode() + { + return $this->errorCode; + } + + /** + * Checks whether developer mode is set in the initialization parameters + * + * @return bool + */ + public function isDeveloperMode() + { + return isset($this->server[State::PARAM_MODE]) && $this->server[State::PARAM_MODE] == State::MODE_DEVELOPER; + } + + /** + * Display an exception and terminate program execution + * + * @param \Exception $e + * @return void + * @SuppressWarnings(PHPMD.ExitExpression) + */ + protected function terminate(\Exception $e) + { + if ($this->isDeveloperMode()) { + echo $e; + } else { + $message = "An error has happened during application run. See debug log for details.\n"; + try { + if (!$this->objectManager) { + throw new \DomainException(); + } + $this->objectManager->get('Magento\Framework\Logger')->logException($e); + } catch (\Exception $e) { + $message .= "Could not write error message to log. Please use developer mode to see the message.\n"; + } + echo $message; + } + exit(1); + } +} diff --git a/lib/internal/Magento/Framework/App/Cache/State.php b/lib/internal/Magento/Framework/App/Cache/State.php index 76521cdb5c4de0bd9465a4b4e4ab79ccf8026324..b74851cca903a289a7f58d52fa0be1e046b67192 100644 --- a/lib/internal/Magento/Framework/App/Cache/State.php +++ b/lib/internal/Magento/Framework/App/Cache/State.php @@ -61,21 +61,17 @@ class State implements StateInterface /** * @param State\OptionsInterface $options * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool - * @param \Magento\Framework\App\State $appState * @param bool $banAll Whether all cache types are forced to be disabled */ public function __construct( State\OptionsInterface $options, \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool, - \Magento\Framework\App\State $appState, $banAll = false ) { $this->_options = $options; $this->_cacheFrontend = $cacheFrontendPool->get(\Magento\Framework\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID); - if ($appState->isInstalled()) { - $this->_loadTypeStatuses($banAll); - } + $this->_loadTypeStatuses($banAll); } /** diff --git a/lib/internal/Magento/Framework/App/Config/Element.php b/lib/internal/Magento/Framework/App/Config/Element.php index 77a1c91e4a539aa52eed6ea99b8c121d5fdc7833..cae7d6fe1ea6be888cf10edc039528e78d0af23f 100644 --- a/lib/internal/Magento/Framework/App/Config/Element.php +++ b/lib/internal/Magento/Framework/App/Config/Element.php @@ -35,6 +35,7 @@ class Element extends \Magento\Framework\Simplexml\Element * @param string $var * @param boolean $value * @return boolean + * @SuppressWarnings(PHPMD.ShortMethodName) */ public function is($var, $value = true) { diff --git a/lib/internal/Magento/Framework/App/Cron.php b/lib/internal/Magento/Framework/App/Cron.php index 2157b253281e4c591e7c9e70cba7cc685547d92c..f4e4597e7e6e3e861de36cd89bb50aa3576cece5 100644 --- a/lib/internal/Magento/Framework/App/Cron.php +++ b/lib/internal/Magento/Framework/App/Cron.php @@ -25,6 +25,7 @@ */ namespace Magento\Framework\App; +use Magento\Framework\App; use Magento\Framework\Event\ManagerInterface; class Cron implements \Magento\Framework\AppInterface @@ -82,4 +83,12 @@ class Cron implements \Magento\Framework\AppInterface $this->_response->setCode(0); return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/lib/internal/Magento/Framework/App/EntryPoint/EntryPoint.php b/lib/internal/Magento/Framework/App/EntryPoint/EntryPoint.php deleted file mode 100644 index ebc7082fe4cac0f0c98c95e04b09e8a294535753..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/App/EntryPoint/EntryPoint.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * Application entry point, used to bootstrap and run application - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\EntryPoint; - -use Magento\Framework\App\State; -use Magento\Framework\App\EntryPointInterface; -use Magento\Framework\ObjectManager; - -class EntryPoint implements EntryPointInterface -{ - /** - * @var string - */ - protected $_rootDir; - - /** - * @var array - */ - protected $_parameters; - - /** - * Application object manager - * - * @var ObjectManager - */ - protected $_locator; - - /** - * @param string $rootDir - * @param array $parameters - * @param ObjectManager $objectManager - * @SuppressWarnings(PHPMD.ExitExpression) - */ - public function __construct($rootDir, array $parameters = array(), ObjectManager $objectManager = null) - { - $this->_rootDir = $rootDir; - $this->_parameters = $parameters; - $this->_locator = $objectManager; - } - - /** - * Run application - * - * @param string $applicationName - * @param array $arguments - * @return void - */ - public function run($applicationName, array $arguments = array()) - { - try { - \Magento\Framework\Profiler::start('magento'); - if (!$this->_locator) { - $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory(); - $this->_locator = $locatorFactory->create($this->_rootDir, $this->_parameters); - } - $application = $this->_locator->create($applicationName, $arguments); - $response = $application->launch(); - \Magento\Framework\Profiler::stop('magento'); - $response->sendResponse(); - } catch (\Exception $exception) { - if (isset( - $this->_parameters[State::PARAM_MODE] - ) && $this->_parameters[State::PARAM_MODE] == State::MODE_DEVELOPER - ) { - echo $exception->getMessage() . "\n\n"; - echo $exception->getTraceAsString(); - } else { - $message = "Error happened during application run.\n"; - try { - if (!$this->_locator) { - throw new \DomainException(); - } - $this->_locator->get('Magento\Framework\Logger')->logException($exception); - } catch (\Exception $e) { - $message .= "Could not write error message to log. Please use developer mode to see the message.\n"; - } - echo $message; - } - } - } -} diff --git a/lib/internal/Magento/Framework/App/Error/Handler.php b/lib/internal/Magento/Framework/App/Error/Handler.php deleted file mode 100644 index b3e2186a5015a6c6cdd951f616676abbda4f815b..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/App/Error/Handler.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Default Error Handler - */ -namespace Magento\Framework\App\Error; - -class Handler extends \Magento\Framework\Error\Handler -{ - /** - * @var \Magento\Framework\Logger - */ - protected $_logger; - - /** - * @var \Magento\Framework\App\Filesystem - */ - protected $_filesystem; - - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @param \Magento\Framework\Logger $logger - * @param \Magento\Framework\App\Filesystem $filesystem - * @param \Magento\Framework\App\State $appState - */ - public function __construct( - \Magento\Framework\Logger $logger, - \Magento\Framework\App\Filesystem $filesystem, - \Magento\Framework\App\State $appState - ) { - $this->_logger = $logger; - $this->_filesystem = $filesystem; - $this->_appState = $appState; - } - - /** - * Process exception - * - * @param \Exception $exception - * @param array $params - * @return void - */ - public function processException(\Exception $exception, array $params = array()) - { - if ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) { - parent::processException($exception, $params); - } else { - $reportData = array($exception->getMessage(), $exception->getTraceAsString()) + $params; - // retrieve server data - if (isset($_SERVER)) { - if (isset($_SERVER['REQUEST_URI'])) { - $reportData['url'] = $_SERVER['REQUEST_URI']; - } - if (isset($_SERVER['SCRIPT_NAME'])) { - $reportData['script_name'] = $_SERVER['SCRIPT_NAME']; - } - } - require_once $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::PUB_DIR) . '/errors/report.php'; - } - } - - /** - * Show error as exception or log it - * - * @param string $errorMessage - * @throws \Exception - * @return void - */ - protected function _processError($errorMessage) - { - if ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) { - parent::_processError($errorMessage); - } else { - $exception = new \Exception($errorMessage); - $errorMessage .= $exception->getTraceAsString(); - $this->_logger->log($errorMessage, \Zend_Log::ERR); - } - } -} diff --git a/lib/internal/Magento/Framework/Error/Handler.php b/lib/internal/Magento/Framework/App/ErrorHandler.php similarity index 60% rename from lib/internal/Magento/Framework/Error/Handler.php rename to lib/internal/Magento/Framework/App/ErrorHandler.php index f56e38fce067feaad3c4b24e1b213c3fc04fee08..79339fcac808e7c5b50b55a67c9162be47dccbda 100644 --- a/lib/internal/Magento/Framework/Error/Handler.php +++ b/lib/internal/Magento/Framework/App/ErrorHandler.php @@ -21,12 +21,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\Error; + +namespace Magento\Framework\App; /** - * Default Error Handler + * An error handler that converts runtime errors into exceptions */ -class Handler implements HandlerInterface +class ErrorHandler { /** * Error messages @@ -51,33 +52,6 @@ class Handler implements HandlerInterface E_USER_DEPRECATED => 'User Deprecated Functionality' ); - /** - * Process exception - * - * @param \Exception $exception - * @param string[] $params - * @return void - */ - public function processException(\Exception $exception, array $params = array()) - { - echo '<pre>'; - echo $exception->getMessage() . "\n\n"; - echo $exception->getTraceAsString(); - echo '</pre>'; - } - - /** - * Show error as exception - * - * @param string $errorMessage - * @return void - * @throws \Exception - */ - protected function _processError($errorMessage) - { - throw new \Exception($errorMessage); - } - /** * Custom error handler * @@ -86,6 +60,7 @@ class Handler implements HandlerInterface * @param string $errorFile * @param int $errorLine * @return bool + * @throws \Exception */ public function handler($errorNo, $errorStr, $errorFile, $errorLine) { @@ -97,23 +72,8 @@ class Handler implements HandlerInterface if ($errorNo == 0) { return false; } - - // PEAR specific message handling - if (stripos($errorFile . $errorStr, 'pear') !== false) { - // ignore strict and deprecated notices - if ($errorNo == E_STRICT || $errorNo == E_DEPRECATED) { - return true; - } - // ignore attempts to read system files when open_basedir is set - if ($errorNo == E_WARNING && stripos($errorStr, 'open_basedir') !== false) { - return true; - } - } - $errorMessage = isset( - $this->errorPhrases[$errorNo] - ) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})"; - $errorMessage .= ": {$errorStr} in {$errorFile} on line {$errorLine}"; - $this->_processError($errorMessage); - return true; + $msg = isset($this->errorPhrases[$errorNo]) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})"; + $msg .= ": {$errorStr} in {$errorFile} on line {$errorLine}"; + throw new \Exception($msg); } } diff --git a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList/Verification.php b/lib/internal/Magento/Framework/App/Filesystem/DirectoryList/Verification.php index 6b02df42e47cc2d49f1e65829de18e05b30d1d96..90fd518e9ac1509c37dfee0e30466ba09db68633 100644 --- a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList/Verification.php +++ b/lib/internal/Magento/Framework/App/Filesystem/DirectoryList/Verification.php @@ -26,7 +26,7 @@ namespace Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\State; -use Magento\Framework\BootstrapException; +use Magento\Framework\App\InitException; use Magento\Framework\App\Filesystem; use Magento\Framework\Filesystem\FilesystemException; @@ -86,7 +86,7 @@ class Verification * Create the required directories, if they don't exist, and verify write access for existing directories * * @return void - * @throws BootstrapException + * @throws InitException */ public function createAndVerifyDirectories() { @@ -108,7 +108,7 @@ class Verification if ($fails) { $dirList = implode(', ', $fails); - throw new BootstrapException("Cannot create or verify write access: {$dirList}"); + throw new InitException("Cannot create or verify write access: {$dirList}"); } } } diff --git a/lib/internal/Magento/Framework/App/Http.php b/lib/internal/Magento/Framework/App/Http.php index 042a858d312669ea3c870930293bde9f951bee41..c20801d4c1b6d5b67d6d6ada07a0a4299a44969a 100644 --- a/lib/internal/Magento/Framework/App/Http.php +++ b/lib/internal/Magento/Framework/App/Http.php @@ -35,6 +35,14 @@ use Magento\Framework\Event; */ class Http implements \Magento\Framework\AppInterface { + /**#@+ + * Parameters for redirecting if the application is not installed + */ + const NOT_INSTALLED_URL_PATH_PARAM = 'MAGE_NOT_INSTALLED_URL_PATH'; + const NOT_INSTALLED_URL_PARAM = 'MAGE_NOT_INSTALLED_URL'; + const NOT_INSTALLED_URL_PATH = 'setup/'; + /**#@-*/ + /** * @var \Magento\Framework\ObjectManager */ @@ -71,7 +79,7 @@ class Http implements \Magento\Framework\AppInterface protected $_filesystem; /** - * @var Response\Http + * @var ResponseHttp */ protected $_response; @@ -112,45 +120,162 @@ class Http implements \Magento\Framework\AppInterface */ public function launch() { - try { - $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); - $this->_state->setAreaCode($areaCode); - $this->_objectManager->configure($this->_configLoader->load($areaCode)); - $this->_response = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface') - ->dispatch($this->_request); - // This event gives possibility to launch something before sending output (allow cookie setting) - $eventParams = array('request' => $this->_request, 'response' => $this->_response); - $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams); - } catch (\Exception $exception) { - $message = $exception->getMessage() . "\n"; - try { - if ($this->_state->getMode() == State::MODE_DEVELOPER) { - $message .= '<pre>'; - $message .= $exception->getMessage() . "\n\n"; - $message .= $exception->getTraceAsString(); - $message .= '</pre>'; - } else { - $reportData = array($exception->getMessage(), $exception->getTraceAsString()); - // retrieve server data - if (isset($_SERVER)) { - if (isset($_SERVER['REQUEST_URI'])) { - $reportData['url'] = $_SERVER['REQUEST_URI']; - } - if (isset($_SERVER['SCRIPT_NAME'])) { - $reportData['script_name'] = $_SERVER['SCRIPT_NAME']; - } - } - require_once $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php'; - $processor = new \Magento\Framework\Error\Processor($this->_response); - $processor->saveReport($reportData); - $this->_response = $processor->processReport(); - } - } catch (\Exception $exception) { - $message .= "Unknown error happened."; - } + $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); + $this->_state->setAreaCode($areaCode); + $this->_objectManager->configure($this->_configLoader->load($areaCode)); + $this->_response = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface') + ->dispatch($this->_request); + // This event gives possibility to launch something before sending output (allow cookie setting) + $eventParams = array('request' => $this->_request, 'response' => $this->_response); + $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams); + return $this->_response; + } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + $result = $this->handleDeveloperMode($bootstrap, $exception) + || $this->handleBootstrapErrors($bootstrap) + || $this->handleSessionException($bootstrap, $exception) + || $this->handleInitException($exception) + || $this->handleGenericReport($bootstrap, $exception); + return $result; + } + + /** + * Error handler for developer mode + * + * @param Bootstrap $bootstrap + * @param \Exception $exception + * @return bool + */ + private function handleDeveloperMode(Bootstrap $bootstrap, \Exception $exception) + { + if ($bootstrap->isDeveloperMode()) { $this->_response->setHttpResponseCode(500); - $this->_response->setBody($message); + $this->_response->setHeader('Content-Type', 'text/plain'); + $this->_response->setBody($exception->getMessage() . "\n" . $exception->getTraceAsString()); + $this->_response->sendResponse(); + return true; } - return $this->_response; + return false; + } + + /** + * Handler for bootstrap errors + * + * @param Bootstrap $bootstrap + * @return bool + */ + private function handleBootstrapErrors(Bootstrap $bootstrap) + { + $bootstrapCode = $bootstrap->getErrorCode(); + if (Bootstrap::ERR_MAINTENANCE == $bootstrapCode) { + require $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/503.php'; + return true; + } + if (Bootstrap::ERR_IS_INSTALLED == $bootstrapCode) { + $path = $this->getInstallerRedirectPath($bootstrap->getParams()); + $this->_response->setRedirect($path); + $this->_response->sendHeaders(); + return true; + } + return false; + } + + /** + * Handler for session errors + * + * @param Bootstrap $bootstrap + * @param \Exception $exception + * @return bool + */ + private function handleSessionException(Bootstrap $bootstrap, \Exception $exception) + { + if ($exception instanceof \Magento\Framework\Session\Exception) { + $path = $this->getBaseUrlPath($bootstrap->getParams()); + $this->_response->setRedirect($path); + $this->_response->sendHeaders(); + return true; + } + return false; + } + + /** + * Handler for application initialization errors + * + * @param \Exception $exception + * @return bool + */ + private function handleInitException(\Exception $exception) + { + if ($exception instanceof \Magento\Framework\App\InitException) { + require $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/404.php'; + return true; + } + return false; + } + + /** + * Handle for any other errors + * + * @param Bootstrap $bootstrap + * @param \Exception $exception + * @return bool + */ + private function handleGenericReport(Bootstrap $bootstrap, \Exception $exception) + { + $reportData = array($exception->getMessage(), $exception->getTraceAsString()); + $params = $bootstrap->getParams(); + if (isset($params['REQUEST_URI'])) { + $reportData['url'] = $params['REQUEST_URI']; + } + if (isset($params['SCRIPT_NAME'])) { + $reportData['script_name'] = $params['SCRIPT_NAME']; + } + require $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php'; + return true; + } + + /** + * Determines redirect URL when application is not installed + * + * @param array $server + * @return string + */ + public function getInstallerRedirectPath($server) + { + if (isset($server[self::NOT_INSTALLED_URL_PARAM])) { + return $server[self::NOT_INSTALLED_URL_PARAM]; + } + if (isset($server[self::NOT_INSTALLED_URL_PATH_PARAM])) { + $urlPath = $server[self::NOT_INSTALLED_URL_PATH_PARAM]; + } else { + $urlPath = self::NOT_INSTALLED_URL_PATH; + } + return $this->getBaseUrlPath($server) . $urlPath; + } + + /** + * Determines a base URL path from the environment + * + * @param string $server + * @return string + */ + private function getBaseUrlPath($server) + { + $result = ''; + if (isset($server['SCRIPT_NAME'])) { + $envPath = str_replace('\\', '/', dirname($server['SCRIPT_NAME'])); + if ($envPath != '.' && $envPath != '/') { + $result = $envPath; + } + } + if (!preg_match('/\/$/', $result)) { + $result .= '/'; + } + return $result; } } diff --git a/dev/tests/unit/testsuite/Magento/Install/App/_files/config.php b/lib/internal/Magento/Framework/App/InitException.php similarity index 69% rename from dev/tests/unit/testsuite/Magento/Install/App/_files/config.php rename to lib/internal/Magento/Framework/App/InitException.php index d4c98f15f4d41e3f156a17de83dc58baddc3efe4..0edd0c7e09a2f2a7b9bdac17f6251e8d14282c8c 100644 --- a/dev/tests/unit/testsuite/Magento/Install/App/_files/config.php +++ b/lib/internal/Magento/Framework/App/InitException.php @@ -17,8 +17,16 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\App; + +/** + * An exception that indicates application initialization error */ -return array('uninstall' => 1); +class InitException extends \Exception +{ +} diff --git a/lib/internal/Magento/Framework/App/MaintenanceMode.php b/lib/internal/Magento/Framework/App/MaintenanceMode.php new file mode 100644 index 0000000000000000000000000000000000000000..92107be00197b017f14089dcafb75f894a3133f1 --- /dev/null +++ b/lib/internal/Magento/Framework/App/MaintenanceMode.php @@ -0,0 +1,140 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\App; + +use Magento\Framework\App\Filesystem; +use Magento\Framework\App\Filesystem\DirectoryList; + +/** + * Application Maintenance Mode + */ +class MaintenanceMode +{ + /** + * Maintenance flag file name + * + * DO NOT consolidate this file and the IP white list into one. + * It is going to work much faster in 99% of cases: the isOn() will return false whenever file doesn't exist. + */ + const FLAG_FILENAME = '.maintenance.flag'; + + /** + * IP-addresses file name + */ + const IP_FILENAME = '.maintenance.ip'; + + /** + * Maintenance flag dir + */ + const FLAG_DIR = Filesystem::VAR_DIR; + + /** + * Path to store files + * + * @var \Magento\Framework\Filesystem\Directory\WriteInterface + */ + protected $flagDir; + + /** + * Constructor + * + * @param \Magento\Framework\App\Filesystem $filesystem + */ + public function __construct(Filesystem $filesystem) + { + $this->flagDir = $filesystem->getDirectoryWrite(self::FLAG_DIR); + } + + /** + * Checks whether mode is on + * + * Optionally specify an IP-address to compare against the white list + * + * @param string $remoteAddr + * @return bool + */ + public function isOn($remoteAddr = '') + { + if (!$this->flagDir->isExist(self::FLAG_FILENAME)) { + return false; + } + $info = $this->getAddressInfo(); + return !in_array($remoteAddr, $info); + } + + /** + * Sets maintenance mode "on" or "off" + * + * @param bool $isOn + * @return bool + */ + public function set($isOn) + { + if ($isOn) { + return $this->flagDir->touch(self::FLAG_FILENAME); + } + if ($this->flagDir->isExist(self::FLAG_FILENAME)) { + return $this->flagDir->delete(self::FLAG_FILENAME); + } + return true; + } + + /** + * Sets list of allowed IP addresses + * + * @param string $addresses + * @return bool + * @throws \InvalidArgumentException + */ + public function setAddresses($addresses) + { + $addresses = (string)$addresses; + if (empty($addresses)) { + if ($this->flagDir->isExist(self::IP_FILENAME)) { + return $this->flagDir->delete(self::IP_FILENAME); + } + return true; + } + if (!preg_match('/^[^\s,]+(,[^\s,]+)*$/', $addresses)) { + throw new \InvalidArgumentException("One or more IP-addresses is expected (comma-separated)\n"); + } + $result = $this->flagDir->writeFile(self::IP_FILENAME, $addresses); + return false !== $result ? true : false; + } + + /** + * Get list of IP addresses effective for maintenance mode + * + * @return string[] + */ + public function getAddressInfo() + { + if ($this->flagDir->isExist(self::IP_FILENAME)) { + $temp = $this->flagDir->readFile(self::IP_FILENAME); + return explode(',', trim($temp)); + } else { + return []; + } + } +} diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index 2d929ce6b787890940e4db8a52370d8fb9a4cbe1..e6d138d1454474763ddc42ffc9ea346b04f9c2fd 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -214,7 +214,7 @@ class ObjectManagerFactory * @param mixed $argumentMapper * @param string $appMode * @return array - * @throws \Magento\Framework\BootstrapException + * @throws \Magento\Framework\App\InitException */ protected function _loadPrimaryConfig(DirectoryList $directoryList, $argumentMapper, $appMode) { @@ -239,7 +239,7 @@ class ObjectManagerFactory ); $configData = $reader->read('primary'); } catch (\Exception $e) { - throw new \Magento\Framework\BootstrapException($e->getMessage()); + throw new \Magento\Framework\App\InitException($e->getMessage(), $e->getCode(), $e); } return $configData; } diff --git a/lib/internal/Magento/Framework/App/PageCache/Version.php b/lib/internal/Magento/Framework/App/PageCache/Version.php index 55705dd2d3c6d8d4b3a6ac8661faf5527ac3f0cb..e593e82b500cf63e6e0b0db5357a0f0bf6a0e301 100644 --- a/lib/internal/Magento/Framework/App/PageCache/Version.php +++ b/lib/internal/Magento/Framework/App/PageCache/Version.php @@ -96,7 +96,8 @@ class Version if ($this->request->isPost()) { $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() ->setDuration(self::COOKIE_PERIOD) - ->setPath('/'); + ->setPath('/') + ->setHttpOnly(false); $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $this->generateValue(), $publicCookieMetadata); } } diff --git a/lib/internal/Magento/Framework/App/Response/Http.php b/lib/internal/Magento/Framework/App/Response/Http.php index 76eeceb2411789e5d957eace9c529142d5c6c730..28e5a33a17a19298d253d63b8628201b89257065 100644 --- a/lib/internal/Magento/Framework/App/Response/Http.php +++ b/lib/internal/Magento/Framework/App/Response/Http.php @@ -97,9 +97,9 @@ class Http extends \Zend_Controller_Response_Http implements HttpInterface if (!empty($data)) { ksort($data); $cookieValue = sha1(serialize($data)); - $publicCookMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + $sensitiveCookMetadata = $this->cookieMetadataFactory->createSensitiveCookieMetadata() ->setPath('/'); - $this->cookieManager->setPublicCookie(self::COOKIE_VARY_STRING, $cookieValue, $publicCookMetadata); + $this->cookieManager->setSensitiveCookie(self::COOKIE_VARY_STRING, $cookieValue, $sensitiveCookMetadata); } else { $cookieMetadata = $this->cookieMetadataFactory->createCookieMetadata() ->setPath('/'); diff --git a/lib/internal/Magento/Framework/App/State/MaintenanceMode.php b/lib/internal/Magento/Framework/App/State/MaintenanceMode.php deleted file mode 100644 index adc1bb357a60cb152dd50256604bab65caca23f9..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/App/State/MaintenanceMode.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\State; - -use Magento\Framework\App\Filesystem; - -/** - * Application Maintenance Mode - */ -class MaintenanceMode -{ - /** - * Maintenance flag name - */ - const FLAG_FILENAME = 'maintenance.flag'; - - /** - * Maintenance flag dir - */ - const FLAG_DIR = Filesystem::VAR_DIR; - - /** - * @var \Magento\Framework\App\Filesystem - */ - protected $filesystem; - - /** - * @param \Magento\Framework\App\Filesystem $filesystem - */ - public function __construct(Filesystem $filesystem) - { - $this->filesystem = $filesystem; - } - - /** - * Turn on store maintenance mode - * - * @param string $data - * @return bool - */ - public function turnOn($data = 'maintenance') - { - try { - $this->filesystem->getDirectoryWrite(self::FLAG_DIR) - ->writeFile(self::FLAG_FILENAME, $data); - } catch (\Exception $e) { - return false; - } - return true; - } - - /** - * Turn off store maintenance mode - * - * @return bool - */ - public function turnOff() - { - try { - $this->filesystem->getDirectoryWrite(self::FLAG_DIR)->delete(self::FLAG_FILENAME); - } catch (\Exception $e) { - return false; - } - return true; - } -} diff --git a/lib/internal/Magento/Framework/App/StaticResource.php b/lib/internal/Magento/Framework/App/StaticResource.php index 3b4999e4dd8bacd8b28e96ab67096761f6c861b2..c22c0f71910114c618cca173b98b2717b001e54d 100644 --- a/lib/internal/Magento/Framework/App/StaticResource.php +++ b/lib/internal/Magento/Framework/App/StaticResource.php @@ -26,6 +26,7 @@ namespace Magento\Framework\App; use Magento\Framework\App\ObjectManager; use Magento\Framework\App\Request; use Magento\Framework\App\Response; +use Magento\Framework\App; /** * Entry point for retrieving static resources like JS, CSS, images by requested public path @@ -40,7 +41,7 @@ class StaticResource implements \Magento\Framework\AppInterface private $state; /** - * @var Response\FileInterface + * @var \Magento\Framework\App\Response\FileInterface */ private $response; @@ -116,26 +117,33 @@ class StaticResource implements \Magento\Framework\AppInterface if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) { $this->response->setHttpResponseCode(404); } else { - try { - $path = $this->request->get('resource'); - $params = $this->parsePath($path); - $this->state->setAreaCode($params['area']); - $this->objectManager->configure($this->configLoader->load($params['area'])); - $file = $params['file']; - unset($params['file']); - $asset = $this->assetRepo->createAsset($file, $params); - $this->response->setFilePath($asset->getSourceFile()); - $this->publisher->publish($asset); - } catch (\Exception $e) { - if ($appMode == \Magento\Framework\App\State::MODE_DEVELOPER) { - throw $e; - } - $this->response->setHttpResponseCode(404); - } + $path = $this->request->get('resource'); + $params = $this->parsePath($path); + $this->state->setAreaCode($params['area']); + $this->objectManager->configure($this->configLoader->load($params['area'])); + $file = $params['file']; + unset($params['file']); + $asset = $this->assetRepo->createAsset($file, $params); + $this->response->setFilePath($asset->getSourceFile()); + $this->publisher->publish($asset); } return $this->response; } + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + $this->response->setHttpResponseCode(404); + $this->response->setHeader('Content-Type', 'text/plain'); + if ($bootstrap->isDeveloperMode()) { + $this->response->setBody($exception->getMessage() . "\n" . $exception->getTraceAsString()); + } + $this->response->sendResponse(); + return true; + } + /** * Parse path to identify parts needed for searching original file * diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index 9a1447c397e949baef7ad1b0f69ae112d6280c7f..6acd25180d6b8a19082294a7c06dbe934f0e67fa 100644 --- a/lib/internal/Magento/Framework/AppInterface.php +++ b/lib/internal/Magento/Framework/AppInterface.php @@ -35,7 +35,7 @@ interface AppInterface /** * Magento version */ - const VERSION = '0.1.0-alpha94'; + const VERSION = '0.1.0-alpha95'; /** * Launch application @@ -43,4 +43,17 @@ interface AppInterface * @return \Magento\Framework\App\ResponseInterface */ public function launch(); + + /** + * Ability to handle exceptions that may have occurred during bootstrap and launch + * + * Return values: + * - true: exception has been handled, no additional action is needed + * - false: exception has not been handled - pass the control to Bootstrap + * + * @param App\Bootstrap $bootstrap + * @param \Exception $exception + * @return bool + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception); } diff --git a/lib/internal/Magento/Framework/BootstrapException.php b/lib/internal/Magento/Framework/BootstrapException.php deleted file mode 100644 index cd37ed0e06328b2ff595b46e008203e6a5cfea67..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/BootstrapException.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Error of not fulfilling basic requirements necessary for the application bootstrap. - * \Exception handling should not rely on any part of the application because it has not been initialized yet. - */ -namespace Magento\Framework; - -class BootstrapException extends \Magento\Framework\Exception -{ -} diff --git a/lib/internal/Magento/Framework/DB/Select.php b/lib/internal/Magento/Framework/DB/Select.php index a7c26c5682c0c45b08a8755a71bf97ede1b09b9d..ca7232661d6b62b3d2f3626a2080191ef1da9658 100644 --- a/lib/internal/Magento/Framework/DB/Select.php +++ b/lib/internal/Magento/Framework/DB/Select.php @@ -28,8 +28,6 @@ use Magento\Framework\DB\Adapter\AdapterInterface; /** * Class for SQL SELECT generation and results. * - * @method \Magento\Framework\DB\Adapter\AdapterInterface|Zend_Db_Adapter_Abstract getAdapter() - * @property \Magento\Framework\DB\Adapter\AdapterInterface|Zend_Db_Adapter_Abstract $_adapter * @method \Magento\Framework\DB\Select from($name, $cols = '*', $schema = null) * @method \Magento\Framework\DB\Select join($name, $cond, $cols = '*', $schema = null) * @method \Magento\Framework\DB\Select joinInner($name, $cond, $cols = '*', $schema = null) @@ -66,6 +64,36 @@ class Select extends \Zend_Db_Select */ const SQL_STRAIGHT_JOIN = 'STRAIGHT_JOIN'; + /** + * FULLTEXT search in MySQL search mode "natural language" + */ + const FULLTEXT_MODE_NATURAL = 'IN NATURAL LANGUAGE MODE'; + + /** + * FULLTEXT search in MySQL search mode "natural language with query expansion" + */ + const FULLTEXT_MODE_NATURAL_QUERY = 'IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION'; + + /** + * FULLTEXT search in MySQL search mode "boolean" + */ + const FULLTEXT_MODE_BOOLEAN = 'IN BOOLEAN MODE'; + + /** + * FULLTEXT search in MySQL search mode "query expansion" + */ + const FULLTEXT_MODE_QUERY = 'WITH QUERY EXPANSION'; + + /** + * FULLTEXT search in MySQL MATCH method + */ + const MATCH = 'MATCH'; + + /** + * FULLTEXT search in MySQL AGAINST method + */ + const AGAINST = 'AGAINST'; + /** * Class constructor * Add straight join support @@ -121,12 +149,55 @@ class Select extends \Zend_Db_Select $type = null; } if (is_array($value)) { - $cond = $this->_adapter->quoteInto($cond, $value); + $cond = $this->getAdapter()->quoteInto($cond, $value); $value = null; } return parent::where($cond, $value, $type); } + /** + * Method for FULLTEXT search in Mysql, will generated MATCH ($columns) AGAINST ('$expression' $mode) + * + * @param string|string[] $columns Columns which add to MATCH () + * @param string $expression Expression which add to AGAINST () + * @param string $mode + * @return string + */ + public function getMatchQuery($columns, $expression, $mode = self::FULLTEXT_MODE_NATURAL) + { + if (is_array($columns)) { + $columns = implode(', ', $columns); + } + + $expression = $this->getAdapter()->quote($expression); + + $condition = self::MATCH . " ({$columns}) " . self::AGAINST . " ({$expression} {$mode})"; + return $condition; + } + + /** + * Method for FULLTEXT search in Mysql, will added generated + * MATCH ($columns) AGAINST ('$expression' $mode) to where clause + * + * @param string|string[] $columns Columns which add to MATCH () + * @param string $expression Expression which add to AGAINST () + * @param bool $isCondition true=AND, false=OR + * @param string $mode + * @return $this + */ + public function match($columns, $expression, $isCondition = true, $mode = self::FULLTEXT_MODE_NATURAL) + { + $fullCondition = $this->getMatchQuery($columns, $expression, $mode); + + if ($isCondition) { + $this->where($fullCondition); + } else { + $this->orWhere($fullCondition); + } + + return $this; + } + /** * Reset unused LEFT JOIN(s) * diff --git a/lib/internal/Magento/Framework/Event/Config/Data.php b/lib/internal/Magento/Framework/Event/Config/Data.php index 13733d86d431f4ce9e86bce4279c227a0116c984..f22612ba5f2d05af42973061b8cea63fb6af9c22 100644 --- a/lib/internal/Magento/Framework/Event/Config/Data.php +++ b/lib/internal/Magento/Framework/Event/Config/Data.php @@ -34,45 +34,18 @@ class Data extends \Magento\Framework\Config\Data\Scoped */ protected $_scopePriorityScheme = array('global'); - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @param \Magento\Framework\Event\Config\Reader $reader * @param \Magento\Framework\Config\ScopeInterface $configScope * @param \Magento\Framework\Config\CacheInterface $cache - * @param \Magento\Framework\App\State $appState * @param string $cacheId */ public function __construct( \Magento\Framework\Event\Config\Reader $reader, \Magento\Framework\Config\ScopeInterface $configScope, \Magento\Framework\Config\CacheInterface $cache, - \Magento\Framework\App\State $appState, $cacheId = 'event_config_cache' ) { - $this->_appState = $appState; parent::__construct($reader, $configScope, $cache, $cacheId); } - - /** - * Get config value by key - * - * @param null|string $path - * @param null|mixed $default - * @return null|mixed - */ - public function get($path = null, $default = null) - { - if (!$this->_appState->isInstalled() && !in_array( - $this->_configScope->getCurrentScope(), - array('global', 'install') - ) - ) { - return $default; - } - return parent::get($path, $default); - } } diff --git a/dev/tests/unit/testsuite/Magento/_files/errors/report.php b/lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php similarity index 72% rename from dev/tests/unit/testsuite/Magento/_files/errors/report.php rename to lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php index 2c5136b1fbc938b0985ad1fd1936ee25563c9686..f4ee9f7e5ee129433c6de99e8d88e2b9e21e31a8 100644 --- a/dev/tests/unit/testsuite/Magento/_files/errors/report.php +++ b/lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php @@ -18,9 +18,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Framework\Filter; -/** @var $reportData array */ -\Magento\Framework\App\Error\HandlerTest::assertNotEmpty($reportData); +class LocalizedToNormalized extends \Zend_Filter_LocalizedToNormalized +{ + +} diff --git a/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php b/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php index b81ba96350b831c0cbb36b0921a16a7b73c4ab72..68def3908175f7877da4803194bf472ced73f49f 100644 --- a/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php +++ b/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php @@ -61,29 +61,29 @@ class MagentoImport implements PreProcessorInterface protected $assetRepo; /** - * @var \Magento\Framework\View\Design\Theme\Provider + * @var \Magento\Framework\View\Design\Theme\ListInterface */ - protected $themeProvider; + protected $themeList; /** * @param DesignInterface $design * @param CollectorInterface $fileSource * @param ErrorHandlerInterface $errorHandler * @param \Magento\Framework\View\Asset\Repository $assetRepo - * @param \Magento\Framework\View\Design\Theme\Provider $themeProvider + * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList */ public function __construct( DesignInterface $design, CollectorInterface $fileSource, ErrorHandlerInterface $errorHandler, \Magento\Framework\View\Asset\Repository $assetRepo, - \Magento\Framework\View\Design\Theme\Provider $themeProvider + \Magento\Framework\View\Design\Theme\ListInterface $themeList ) { $this->design = $design; $this->fileSource = $fileSource; $this->errorHandler = $errorHandler; $this->assetRepo = $assetRepo; - $this->themeProvider = $themeProvider; + $this->themeList = $themeList; } /** @@ -135,7 +135,7 @@ class MagentoImport implements PreProcessorInterface { $context = $asset->getContext(); if ($context instanceof FallbackContext) { - return $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode()); + return $this->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath()); } return $this->design->getDesignTheme(); } diff --git a/lib/internal/Magento/Framework/Locale/Lists.php b/lib/internal/Magento/Framework/Locale/Lists.php index 6fc19cce6fb1e448a868b4974828ca1028d0b2e4..14ccdd46be193da4ab0c8aba6600391d3e0ec1cc 100644 --- a/lib/internal/Magento/Framework/Locale/Lists.php +++ b/lib/internal/Magento/Framework/Locale/Lists.php @@ -25,11 +25,6 @@ namespace Magento\Framework\Locale; class Lists implements \Magento\Framework\Locale\ListsInterface { - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @var \Magento\Framework\App\ScopeResolverInterface */ @@ -46,20 +41,17 @@ class Lists implements \Magento\Framework\Locale\ListsInterface protected $_localeResolver; /** - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param \Magento\Framework\Locale\ConfigInterface $config * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param string $locale */ public function __construct( - \Magento\Framework\App\State $appState, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, \Magento\Framework\Locale\ConfigInterface $config, \Magento\Framework\Locale\ResolverInterface $localeResolver, $locale = null ) { - $this->_appState = $appState; $this->_scopeResolver = $scopeResolver; $this->_config = $config; $this->_localeResolver = $localeResolver; @@ -181,7 +173,7 @@ class Lists implements \Magento\Framework\Locale\ListsInterface { $currencies = $this->getTranslationList('currencytoname'); $options = array(); - $allowed = $this->_getAllowedCurrencies(); + $allowed = $this->_config->getAllowedCurrencies(); foreach ($currencies as $name => $code) { if (!in_array($code, $allowed)) { @@ -193,21 +185,6 @@ class Lists implements \Magento\Framework\Locale\ListsInterface return $this->_sortOptionArray($options); } - /** - * Retrieve array of allowed currencies - * - * @return array - */ - protected function _getAllowedCurrencies() - { - if ($this->_appState->isInstalled()) { - $allowed = $this->_scopeResolver->getScope()->getAllowedCurrencies(); - } else { - $allowed = $this->_config->getAllowedCurrencies(); - } - return $allowed; - } - /** * @inheritdoc */ diff --git a/lib/internal/Magento/Framework/Module/Declaration/Reader/Filesystem.php b/lib/internal/Magento/Framework/Module/Declaration/Reader/Filesystem.php index 6c60c93ee9290574549b420c60406c4bd9f4cf08..bbb3cd229d0db44ca6a0b49bfdb43758733bddea 100644 --- a/lib/internal/Magento/Framework/Module/Declaration/Reader/Filesystem.php +++ b/lib/internal/Magento/Framework/Module/Declaration/Reader/Filesystem.php @@ -30,7 +30,6 @@ use Magento\Framework\Module\Declaration\Converter\Dom; use Magento\Framework\Module\Declaration\SchemaLocator; use Magento\Framework\Module\DependencyManagerInterface; use Magento\Framework\Config\ValidationStateInterface; -use Magento\Framework\App\State; class Filesystem extends \Magento\Framework\Config\Reader\Filesystem { @@ -45,11 +44,6 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem */ protected $_allowedModules; - /** - * @var \Magento\Framework\App\State - */ - protected $appState; - /** * @var \Magento\Framework\Module\DependencyManagerInterface */ @@ -70,7 +64,6 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem * @param Dom $converter * @param SchemaLocator $schemaLocator * @param ValidationStateInterface $validationState - * @param State $appState * @param DependencyManagerInterface $dependencyManager * @param string $fileName * @param array $idAttributes @@ -83,7 +76,6 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem Dom $converter, SchemaLocator $schemaLocator, ValidationStateInterface $validationState, - State $appState, DependencyManagerInterface $dependencyManager, $fileName = 'module.xml', $idAttributes = array(), @@ -102,7 +94,6 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem $defaultScope ); $this->_allowedModules = $allowedModules; - $this->appState = $appState; $this->dependencyManager = $dependencyManager; } @@ -112,11 +103,8 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem public function read($scope = null) { $activeModules = $this->_filterActiveModules(parent::read($scope)); - - if ($this->appState->isInstalled()) { - foreach ($activeModules as $moduleConfig) { - $this->dependencyManager->checkModuleDependencies($moduleConfig, $activeModules); - } + foreach ($activeModules as $moduleConfig) { + $this->dependencyManager->checkModuleDependencies($moduleConfig, $activeModules); } return $this->_sortModules($activeModules); } diff --git a/app/code/Magento/Store/Model/Exception.php b/lib/internal/Magento/Framework/Module/Exception.php similarity index 88% rename from app/code/Magento/Store/Model/Exception.php rename to lib/internal/Magento/Framework/Module/Exception.php index 60415d42c816c0ababca5767a77c7dc7c9deae9d..b8e7c64b64e967acdda380e7d5bf39a44cbbb380 100644 --- a/app/code/Magento/Store/Model/Exception.php +++ b/lib/internal/Magento/Framework/Module/Exception.php @@ -22,11 +22,10 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Store exception - */ -namespace Magento\Store\Model; -class Exception extends \Magento\Framework\Model\Exception +namespace Magento\Framework\Module; + + +class Exception extends \Exception { } diff --git a/lib/internal/Magento/Framework/Module/FrontController/Plugin/Install.php b/lib/internal/Magento/Framework/Module/FrontController/Plugin/Install.php deleted file mode 100644 index 814091521e7e9925d91de21051d15659d92b2ec9..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Module/FrontController/Plugin/Install.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php -/** - * Application installation plugin. Should be used by applications that require module install/upgrade. - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\Module\FrontController\Plugin; - -use Magento\Framework\Cache\FrontendInterface; -use Magento\Framework\Module\UpdaterInterface; -use Magento\Framework\App\State; - -class Install -{ - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @var FrontendInterface - */ - protected $_cache; - - /** - * @var UpdaterInterface - */ - protected $_updater; - - /** - * @param State $appState - * @param FrontendInterface $cache - * @param UpdaterInterface $dbUpdater - */ - public function __construct(State $appState, FrontendInterface $cache, UpdaterInterface $dbUpdater) - { - $this->_appState = $appState; - $this->_cache = $cache; - $this->_dbUpdater = $dbUpdater; - } - - /** - * @param \Magento\Framework\App\FrontController $subject - * @param callable $proceed - * @param \Magento\Framework\App\RequestInterface $request - * - * @return \Magento\Framework\App\ResponseInterface - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function aroundDispatch( - \Magento\Framework\App\FrontController $subject, - \Closure $proceed, - \Magento\Framework\App\RequestInterface $request - ) { - if ($this->_appState->isInstalled() && !$this->_cache->load('data_upgrade')) { - $this->_dbUpdater->updateScheme(); - $this->_dbUpdater->updateData(); - $this->_cache->save('true', 'data_upgrade'); - } - return $proceed($request); - } -} diff --git a/lib/internal/Magento/Framework/Module/Manager.php b/lib/internal/Magento/Framework/Module/Manager.php index 92149b131726f6495638131a17721cffdda05e64..f1f19465e7486b2d2bdb0cd35b94e65faf04a1e9 100644 --- a/lib/internal/Magento/Framework/Module/Manager.php +++ b/lib/internal/Magento/Framework/Module/Manager.php @@ -27,10 +27,12 @@ */ namespace Magento\Framework\Module; +use \Magento\Framework\Module\Updater\SetupInterface; + class Manager { /** - * @var ConfigInterface + * @var Output\ConfigInterface */ private $_outputConfig; @@ -44,19 +46,27 @@ class Manager */ private $_outputConfigPaths; + /** + * @var ResourceInterface + */ + private $_moduleResource; + /** * @param Output\ConfigInterface $outputConfig * @param ModuleListInterface $moduleList + * @param ResourceInterface $moduleResource * @param array $outputConfigPaths */ public function __construct( Output\ConfigInterface $outputConfig, ModuleListInterface $moduleList, + ResourceInterface $moduleResource, array $outputConfigPaths = array() ) { $this->_outputConfig = $outputConfig; $this->_moduleList = $moduleList; $this->_outputConfigPaths = $outputConfigPaths; + $this->_moduleResource = $moduleResource; } /** @@ -107,4 +117,47 @@ class Manager } return true; } + + /** + * Check if DB schema is up to date + * + * @param string $moduleName + * @param string $resourceName + * @return bool + */ + public function isDbSchemaUpToDate($moduleName, $resourceName) + { + $dbVer = $this->_moduleResource->getDbVersion($resourceName); + return $this->isModuleVersionEqual($moduleName, $dbVer); + } + + /** + * @param string $moduleName + * @param string $resourceName + * @return bool + */ + public function isDbDataUpToDate($moduleName, $resourceName) + { + $dataVer = $this->_moduleResource->getDataVersion($resourceName); + return $this->isModuleVersionEqual($moduleName, $dataVer); + } + + /** + * Check if DB data is up to date + * + * @param string $moduleName + * @param string|bool $version + * @return bool + * @throws \UnexpectedValueException + */ + private function isModuleVersionEqual($moduleName, $version) + { + $module = $this->_moduleList->getModule($moduleName); + if (empty($module['schema_version'])) { + throw new \UnexpectedValueException("Schema version for module '$moduleName' is not specified"); + } + $configVer = $module['schema_version']; + + return ($version !== false && version_compare($configVer, $version) === SetupInterface::VERSION_COMPARE_EQUAL); + } } diff --git a/lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php b/lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php new file mode 100644 index 0000000000000000000000000000000000000000..a837f4dc1dc913b40054db25466dfc816aff62c4 --- /dev/null +++ b/lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php @@ -0,0 +1,116 @@ +<?php +/** + * Validation of DB up to date state + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Module\Plugin; + +use Magento\Framework\Cache\FrontendInterface; +use Magento\Framework\Module\Updater; +use Magento\Framework\App\State; + +class DbStatusValidator +{ + /** + * @var FrontendInterface + */ + private $cache; + + /** + * @var \Magento\Framework\Module\ModuleListInterface + */ + private $moduleList; + + /** + * @var \Magento\Framework\Module\ResourceResolverInterface + */ + private $resourceResolver; + + /** + * @var \Magento\Framework\Module\Manager + */ + private $moduleManager; + + /** + * @param FrontendInterface $cache + * @param \Magento\Framework\Module\ModuleListInterface $moduleList + * @param \Magento\Framework\Module\ResourceResolverInterface $resourceResolver + * @param \Magento\Framework\Module\Manager $moduleManager + */ + public function __construct( + FrontendInterface $cache, + \Magento\Framework\Module\ModuleListInterface $moduleList, + \Magento\Framework\Module\ResourceResolverInterface $resourceResolver, + \Magento\Framework\Module\Manager $moduleManager + ) { + $this->cache = $cache; + $this->moduleList = $moduleList; + $this->resourceResolver = $resourceResolver; + $this->moduleManager = $moduleManager; + } + + /** + * @param \Magento\Framework\App\FrontController $subject + * @param \Closure $proceed + * @param \Magento\Framework\App\RequestInterface $request + * + * @throws \Magento\Framework\Module\Exception + * @return \Magento\Framework\App\ResponseInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundDispatch( + \Magento\Framework\App\FrontController $subject, + \Closure $proceed, + \Magento\Framework\App\RequestInterface $request + ) { + if (!$this->cache->load('db_is_up_to_date')) { + if (!$this->isDbUpToDate()) { + throw new \Magento\Framework\Module\Exception( + 'Looks like database is outdated. Please, use setup tool to perform update' + ); + } else { + $this->cache->save('true', 'db_is_up_to_date'); + } + } + return $proceed($request); + } + + /** + * Check if DB is up to date + * + * @return bool + */ + private function isDbUpToDate() + { + foreach (array_keys($this->moduleList->getModules()) as $moduleName) { + foreach ($this->resourceResolver->getResourceList($moduleName) as $resourceName) { + $isSchemaUpToDate = $this->moduleManager->isDbSchemaUpToDate($moduleName, $resourceName); + $isDataUpToDate = $this->moduleManager->isDbDataUpToDate($moduleName, $resourceName); + if (!$isSchemaUpToDate || !$isDataUpToDate) { + return false; + } + } + } + return true; + } +} diff --git a/lib/internal/Magento/Framework/Module/Updater.php b/lib/internal/Magento/Framework/Module/Updater.php index b7d40cdba085104702104b0496c3dd316cbb79b9..bc19c5b7ee5bd92880fe31c5f9d34dd767af8034 100644 --- a/lib/internal/Magento/Framework/Module/Updater.php +++ b/lib/internal/Magento/Framework/Module/Updater.php @@ -26,17 +26,9 @@ namespace Magento\Framework\Module; use Magento\Framework\App\State; -use Magento\Framework\Module\Updater\SetupFactory; -class Updater implements \Magento\Framework\Module\UpdaterInterface +class Updater { - /** - * Setup model factory - * - * @var SetupFactory - */ - protected $_factory; - /** * Flag which allow run data install/upgrade * @@ -51,20 +43,6 @@ class Updater implements \Magento\Framework\Module\UpdaterInterface */ protected $_appState; - /** - * If it set to true, we will ignore applying scheme updates - * - * @var bool - */ - protected $_skipModuleUpdate; - - /** - * Map that contains setup model names per resource name - * - * @var array - */ - protected $_resourceList; - /** * @var ModuleListInterface */ @@ -80,39 +58,30 @@ class Updater implements \Magento\Framework\Module\UpdaterInterface */ protected $_setupFactory; + /** + * @var \Magento\Framework\Module\Manager + */ + private $_moduleManager; + /** * @param Updater\SetupFactory $setupFactory * @param State $appState * @param ModuleListInterface $moduleList * @param ResourceResolverInterface $resourceResolver - * @param bool $skipModuleUpdate + * @param Manager $moduleManager */ public function __construct( Updater\SetupFactory $setupFactory, State $appState, ModuleListInterface $moduleList, ResourceResolverInterface $resourceResolver, - $skipModuleUpdate = false + \Magento\Framework\Module\Manager $moduleManager ) { $this->_appState = $appState; $this->_moduleList = $moduleList; $this->_resourceResolver = $resourceResolver; $this->_setupFactory = $setupFactory; - $this->_skipModuleUpdate = $skipModuleUpdate; - } - - /** - * Check whether modules updates processing should be skipped - * - * @return bool - */ - protected function _shouldSkipProcessModulesUpdates() - { - if (!$this->_appState->isInstalled()) { - return false; - } - - return $this->_skipModuleUpdate; + $this->_moduleManager = $moduleManager; } /** @@ -122,21 +91,19 @@ class Updater implements \Magento\Framework\Module\UpdaterInterface */ public function updateScheme() { - if ($this->_shouldSkipProcessModulesUpdates()) { - return; - } - \Magento\Framework\Profiler::start('apply_db_schema_updates'); $this->_appState->setUpdateMode(true); $afterApplyUpdates = array(); foreach (array_keys($this->_moduleList->getModules()) as $moduleName) { foreach ($this->_resourceResolver->getResourceList($moduleName) as $resourceName) { - $setup = $this->_setupFactory->create($resourceName, $moduleName); - $setup->applyUpdates(); + if (!$this->_moduleManager->isDbSchemaUpToDate($moduleName, $resourceName)) { + $setup = $this->_setupFactory->create($resourceName, $moduleName); + $setup->applyUpdates(); - if ($setup->getCallAfterApplyAllUpdates()) { - $afterApplyUpdates[] = $setup; + if ($setup->getCallAfterApplyAllUpdates()) { + $afterApplyUpdates[] = $setup; + } } } } @@ -158,12 +125,11 @@ class Updater implements \Magento\Framework\Module\UpdaterInterface */ public function updateData() { - if (!$this->_isUpdatedSchema) { - return; - } foreach (array_keys($this->_moduleList->getModules()) as $moduleName) { foreach ($this->_resourceResolver->getResourceList($moduleName) as $resourceName) { - $this->_setupFactory->create($resourceName, $moduleName)->applyDataUpdates(); + if (!$this->_moduleManager->isDbDataUpToDate($moduleName, $resourceName)) { + $this->_setupFactory->create($resourceName, $moduleName)->applyDataUpdates(); + } } } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Helper/Composite.php b/lib/internal/Magento/Framework/ObjectManager/Helper/Composite.php new file mode 100644 index 0000000000000000000000000000000000000000..003e5727252d8806ed23b1e7af049a73cf452187 --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Helper/Composite.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\ObjectManager\Helper; + +/** + * Helper for classes which implement Composite pattern. + */ +class Composite +{ + /** + * @param array $declaredComponents Array of the components which should be registered in the following format: + * <pre> + * [ + * ['type' => $firstComponentObject, 'sortOrder' => 15], + * ['type' => $secondComponentObject, 'sortOrder' => 10], + * ... + * ] + * </pre> + * @return array Array of components declarations. Items are sorted and misconfigured ones are removed. + */ + public function filterAndSortDeclaredComponents($declaredComponents) + { + /** Eliminate misconfigured components */ + $declaredComponents = array_filter( + $declaredComponents, + function ($component) { + return (isset($component['type']) && isset($component['sortOrder'])); + } + ); + /** Sort all components according to the provided sort order */ + uasort( + $declaredComponents, + function ($firstComponent, $secondComponent) { + $firstComponentSortOrder = (int)$firstComponent['sortOrder']; + $secondComponentSortOrder = (int)$secondComponent['sortOrder']; + if ($firstComponentSortOrder == $secondComponentSortOrder) { + return 0; + } else if ($firstComponentSortOrder < $secondComponentSortOrder) { + return -1; + } else { + return 1; + } + } + ); + $declaredComponents = array_values($declaredComponents); + return $declaredComponents; + } +} diff --git a/lib/internal/Magento/Framework/Search/AbstractKeyValuePair.php b/lib/internal/Magento/Framework/Search/AbstractKeyValuePair.php new file mode 100644 index 0000000000000000000000000000000000000000..a93d6f7c6902ed51c45f23ed9db2cab6c8a4995b --- /dev/null +++ b/lib/internal/Magento/Framework/Search/AbstractKeyValuePair.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +class AbstractKeyValuePair +{ + /** + * Field name + * + * @var string + */ + protected $name; + + /** + * Field values + * + * @var mixed + */ + protected $value; + + /** + * @param string $name + * @param mixed $value + */ + public function __construct($name, $value) + { + $this->name = $name; + $this->value = $value; + } + + /** + * Get field name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get field values + * + * @return array + */ + public function getValue() + { + return $this->value; + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php index 0f39d132f712d330257b8747260412ef670cd85d..8af39b9b05afd2d4ecb7fa1951971772cb913cc7 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php @@ -1,7 +1,5 @@ <?php /** - * MySQL Search Adapter - * * Magento * * NOTICE OF LICENSE @@ -25,9 +23,14 @@ */ namespace Magento\Framework\Search\Adapter\Mysql; -use Magento\Framework\Search\AdapterInterface; +use Magento\Framework\App\Resource; +use Magento\Framework\DB\Select; use Magento\Framework\Search\RequestInterface; +use Magento\Framework\Search\AdapterInterface; +/** + * MySQL Search Adapter + */ class Adapter implements AdapterInterface { /** @@ -44,16 +47,24 @@ class Adapter implements AdapterInterface */ protected $responseFactory; + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + /** * @param Mapper $mapper * @param ResponseFactory $responseFactory + * @param \Magento\Framework\App\Resource $resource */ public function __construct( Mapper $mapper, - ResponseFactory $responseFactory + ResponseFactory $responseFactory, + Resource $resource ) { $this->mapper = $mapper; $this->responseFactory = $responseFactory; + $this->resource = $resource; } /** @@ -61,17 +72,40 @@ class Adapter implements AdapterInterface */ public function query(RequestInterface $request) { + /** @var Select $query */ $query = $this->mapper->buildQuery($request); - $response = $this->executeQuery($query); + $response = [ + 'documents' => $this->executeDocuments($query), + 'aggregations' => $this->executeAggregations($query), + ]; return $this->responseFactory->create($response); } /** * Executes query and return raw response + * @param Select $select * - * @return mixed + * @return array + */ + private function executeDocuments(Select $select) + { + return $this->getConnection()->fetchAssoc($select); + } + + /** + * @param Select $select + * @return array + */ + private function executeAggregations(Select $select) + { + return []; + } + + /** + * @return \Magento\Framework\DB\Adapter\AdapterInterface */ - private function executeQuery() + private function getConnection() { + return $this->resource->getConnection(Resource::DEFAULT_READ_RESOURCE); } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php index 855cc50bf852a4247b00d4779158595f84519bd5..5c3f84a7612afed22ee25c2c62a10f5fdfe818f2 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php @@ -1,7 +1,5 @@ <?php /** - * Aggregation Factory - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Adapter\Mysql; +/** + * Aggregation Factory + */ class AggregationFactory { /** @@ -62,6 +63,6 @@ class AggregationFactory ] ); } - return $this->objectManager->create('\Magento\Framework\Search\Aggregation', $buckets); + return $this->objectManager->create('\Magento\Framework\Search\Aggregation', ['buckets' => $buckets]); } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Dimensions.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Dimensions.php new file mode 100644 index 0000000000000000000000000000000000000000..520975451b3544abaaaa09e39c72c3fb4f50fc1a --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Dimensions.php @@ -0,0 +1,90 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\Framework\App\ScopeResolverInterface; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Search\Request\Dimension; + +class Dimensions +{ + const DEFAULT_DIMENSION_NAME = 'scope'; + + const STORE_FIELD_NAME = 'store_id'; + + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + /** + * @var ScopeResolverInterface + */ + private $scopeResolver; + + /** + * @param \Magento\Framework\App\Resource $resource + * @param ScopeResolverInterface $scopeResolver + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + ScopeResolverInterface $scopeResolver + ) { + $this->resource = $resource; + $this->scopeResolver = $scopeResolver; + } + + /** + * @param Dimension $dimension + * @return string + */ + public function build(Dimension $dimension) + { + /** @var AdapterInterface $adapter */ + $adapter = $this->resource->getConnection(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE); + + return $this->generateExpression($dimension, $adapter); + } + + /** + * @param Dimension $dimension + * @param AdapterInterface $adapter + * @return string + */ + private function generateExpression(Dimension $dimension, AdapterInterface $adapter) + { + $identifier = $dimension->getName(); + $value = $dimension->getValue(); + + if (self::DEFAULT_DIMENSION_NAME === $identifier) { + $identifier = self::STORE_FIELD_NAME; + $value = $this->scopeResolver->getScope($value)->getId(); + } + + return sprintf( + '%s = %s', + $adapter->quoteIdentifier($identifier), + $adapter->quote($value) + ); + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php index 5d28d0264244cb4e1bd2773a19c5d62dbe2263f8..c8d2d27fef0c328bb7dd6661dd0279e1b4537d29 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php @@ -1,7 +1,5 @@ <?php /** - * Response Factory - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Adapter\Mysql; +/** + * Document Factory + */ class DocumentFactory { /** @@ -33,14 +34,21 @@ class DocumentFactory * @var \Magento\Framework\ObjectManager */ protected $objectManager; + /** + * @var \Magento\Framework\Search\EntityMetadata + */ + private $entityId; /** * @param \Magento\Framework\ObjectManager $objectManager + * @param \Magento\Framework\Search\EntityMetadata $entityId */ public function __construct( - \Magento\Framework\ObjectManager $objectManager + \Magento\Framework\ObjectManager $objectManager, + \Magento\Framework\Search\EntityMetadata $entityId ) { $this->objectManager = $objectManager; + $this->entityId = $entityId; } /** @@ -51,17 +59,20 @@ class DocumentFactory */ public function create($rawDocument) { - $fields = array(); + /** @var \Magento\Framework\Search\DocumentField[] $fields */ + $fields = []; + $documentId = null; + $entityId = $this->entityId->getEntityId(); foreach ($rawDocument as $rawField) { - /** @var \Magento\Framework\Search\DocumentField[] $fields */ - $fields[] = $this->objectManager->create( - '\Magento\Framework\Search\DocumentField', - [ - $rawField['name'], - $rawField['values'] - ] - ); + if ($rawField['name'] == $entityId) { + $documentId = $rawField['value']; + } else { + $fields[] = $this->objectManager->create('\Magento\Framework\Search\DocumentField', $rawField); + } } - return $this->objectManager->create('\Magento\Framework\Search\Document', $fields); + return $this->objectManager->create( + '\Magento\Framework\Search\Document', + ['documentFields' => $fields, 'documentId' => $documentId] + ); } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php new file mode 100644 index 0000000000000000000000000000000000000000..117849c1af609ae016155c6d4386e2285192e95f --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php @@ -0,0 +1,129 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Filter; + +use Magento\Framework\DB\Select; +use Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range; +use Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term; +use Magento\Framework\Search\Request\FilterInterface as RequestFilterInterface; + +class Builder implements BuilderInterface +{ + /** + * @var Range + */ + private $range; + /** + * @var Term + */ + private $term; + + /** + * @param Range $range + * @param Term $term + */ + public function __construct( + Range $range, + Term $term + ) { + $this->range = $range; + $this->term = $term; + } + + /** + * {@inheritdoc} + */ + public function build(RequestFilterInterface $filter) + { + switch ($filter->getType()) { + case RequestFilterInterface::TYPE_BOOL: + /** @var \Magento\Framework\Search\Request\Filter\Bool $filter */ + $queries = []; + $must = $this->buildFilters($filter->getMust(), Select::SQL_AND); + if (!empty($must)) { + $queries[] = $must; + } + $should = $this->buildFilters($filter->getShould(), Select::SQL_OR); + if (!empty($should)) { + $queries[] = $this->wrapBrackets($should); + } + $mustNot = $this->buildFilters($filter->getMustNot(), Select::SQL_AND); + if (!empty($mustNot)) { + $queries[] = '!' . $this->wrapBrackets($mustNot); + } + $query = $this->generateQuery($queries, Select::SQL_AND); + break; + case RequestFilterInterface::TYPE_TERM: + /** @var \Magento\Framework\Search\Request\Filter\Term $filter */ + $query = $this->term->buildFilter($filter); + break; + case RequestFilterInterface::TYPE_RANGE: + /** @var \Magento\Framework\Search\Request\Filter\Range $filter */ + $query = $this->range->buildFilter($filter); + break; + default: + throw new \InvalidArgumentException(sprintf('Unknown filter type \'%s\'', $filter->getType())); + } + return $this->wrapBrackets($query); + } + + /** + * @param \Magento\Framework\Search\Request\FilterInterface[] $filters + * @param string $unionOperator + * @return string + */ + private function buildFilters(array $filters, $unionOperator) + { + $queries = []; + foreach ($filters as $filter) { + $queries[] = $this->build($filter); + } + return $this->generateQuery($queries, $unionOperator); + } + + /** + * @param string[] $queries + * @param string $unionOperator + * @return string + */ + private function generateQuery(array $queries, $unionOperator) + { + $query = implode( + ' ' . $unionOperator . ' ', + $queries + ); + return $query; + } + + /** + * @param string $query + * @return string + */ + private function wrapBrackets($query) + { + return empty($query) + ? $query + : '(' . $query . ')'; + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..aa987061745b58ea6950f6cf10f08ec81fcc5f11 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php @@ -0,0 +1,35 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Filter\Builder; + +interface FilterInterface +{ + /** + * @param \Magento\Framework\Search\Request\FilterInterface $filter + * @return \Magento\Framework\DB\Select + */ + public function buildFilter( + \Magento\Framework\Search\Request\FilterInterface $filter + ); +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php new file mode 100644 index 0000000000000000000000000000000000000000..19637d02d646e2b0dd02a60ab960c3eadcd3e06e --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php @@ -0,0 +1,87 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Filter\Builder; + +use Magento\Framework\App\Resource; +use Magento\Framework\DB\Adapter\AdapterInterface; + +class Range implements FilterInterface +{ + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + + /** + * @param \Magento\Framework\App\Resource $resource + */ + public function __construct(\Magento\Framework\App\Resource $resource) + { + $this->resource = $resource; + } + + /** + * @param \Magento\Framework\Search\Request\FilterInterface $filter + * @return \Magento\Framework\DB\Select + */ + public function buildFilter( + \Magento\Framework\Search\Request\FilterInterface $filter + ) { + $adapter = $this->resource->getConnection(Resource::DEFAULT_READ_RESOURCE); + /** @var \Magento\Framework\Search\Request\Filter\Range $filter */ + return $this->generateCondition($filter->getField(), $filter->getFrom(), $filter->getTo(), $adapter); + } + + private function generateCondition($field, $from, $to, AdapterInterface $adapter) + { + $hasFromValue = !is_null($from); + $hasToValue = !is_null($to); + + $condition = ''; + + if ($hasFromValue and $hasToValue) { + $condition = sprintf( + '%s >= %s %s %s < %s', + $field, + $adapter->quote($from), + \Zend_Db_Select::SQL_AND, + $field, + $adapter->quote($to) + ); + } elseif ($hasFromValue and !$hasToValue) { + $condition = sprintf( + '%s >= %s', + $field, + $adapter->quote($from) + ); + } elseif (!$hasFromValue and $hasToValue) { + $condition = sprintf( + '%s < %s', + $field, + $adapter->quote($to) + ); + } + return $condition; + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php new file mode 100644 index 0000000000000000000000000000000000000000..940e4aef6b4f27cf8830d8e1f7e21d97dbe0423e --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Filter\Builder; + +use Magento\Framework\App\Resource; + +class Term implements FilterInterface +{ + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + + /** + * @param \Magento\Framework\App\Resource $resource + */ + public function __construct(\Magento\Framework\App\Resource $resource) + { + $this->resource = $resource; + } + + /** + * {@inheritdoc} + */ + public function buildFilter( + \Magento\Framework\Search\Request\FilterInterface $filter + ) { + $adapter = $this->resource->getConnection(Resource::DEFAULT_READ_RESOURCE); + + /** @var \Magento\Framework\Search\Request\Filter\Term $filter */ + $condition = sprintf( + '%s = %s', + $filter->getField(), + $adapter->quote($filter->getValue()) + ); + return $condition; + } +} diff --git a/lib/internal/Magento/Framework/App/EntryPointInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php similarity index 76% rename from lib/internal/Magento/Framework/App/EntryPointInterface.php rename to lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php index 83c57a3b99bdac990676a66b65b351da0c3afb84..1b21f97e1703aad0dd879e5bb122d4147893bd36 100644 --- a/lib/internal/Magento/Framework/App/EntryPointInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php @@ -1,7 +1,5 @@ <?php /** - * Application entry point. Bootstraps and runs application - * * Magento * * NOTICE OF LICENSE @@ -23,14 +21,15 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\App; +namespace Magento\Framework\Search\Adapter\Mysql\Filter; + +use Magento\Framework\Search\Request\FilterInterface as RequestFilterInterface; -interface EntryPointInterface +interface BuilderInterface { /** - * @param string $applicationName - * @param array $arguments - * @return void + * @param RequestFilterInterface $filter + * @return string */ - public function run($applicationName, array $arguments = array()); + public function build(RequestFilterInterface $filter); } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php index 938d160486d9a525aeec623f724e3fc9c5fb0c97..818b9d061b9f7a791c8a573e5c4942fa66875808 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php @@ -1,7 +1,5 @@ <?php /** - * Mapper class. Maps library request to specific adapter dependent query - * * Magento * * NOTICE OF LICENSE @@ -25,18 +23,249 @@ */ namespace Magento\Framework\Search\Adapter\Mysql; +use Magento\Framework\App\Resource\Config; +use Magento\Framework\DB\Select; +use Magento\Framework\Search\Adapter\Mysql\Filter\Builder; +use Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match as MatchQueryBuilder; +use Magento\Framework\Search\Request\Query\Bool as BoolQuery; +use Magento\Framework\Search\Request\Query\Filter as FilterQuery; +use Magento\Framework\Search\Request\Query\Match as MatchQuery; +use Magento\Framework\Search\Request\QueryInterface as RequestQueryInterface; use Magento\Framework\Search\RequestInterface; +/** + * Mapper class. Maps library request to specific adapter dependent query + */ class Mapper { + const BOOL_MUST_NOT = true; + const BOOL_MUST = false; + + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + + /** + * @var ScoreBuilder + */ + private $scoreBuilderFactory; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match + */ + private $matchQueryBuilder; + /** + * @var Filter\Builder + */ + private $filterBuilder; + /** + * @var Dimensions + */ + private $dimensionsBuilder; + + /** + * @param \Magento\Framework\App\Resource $resource + * @param ScoreBuilderFactory $scoreBuilderFactory + * @param MatchQueryBuilder $matchQueryBuilder + * @param Builder $filterBuilder + * @param Dimensions $dimensionsBuilder + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + ScoreBuilderFactory $scoreBuilderFactory, + MatchQueryBuilder $matchQueryBuilder, + Builder $filterBuilder, + Dimensions $dimensionsBuilder + ) { + $this->resource = $resource; + $this->scoreBuilderFactory = $scoreBuilderFactory; + $this->matchQueryBuilder = $matchQueryBuilder; + $this->filterBuilder = $filterBuilder; + $this->dimensionsBuilder = $dimensionsBuilder; + } + /** * Build adapter dependent query * * @param RequestInterface $request - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @return mixed + * @return Select */ public function buildQuery(RequestInterface $request) { + /** @var ScoreBuilder $scoreBuilder */ + $scoreBuilder = $this->scoreBuilderFactory->create(); + $select = $this->processQuery($scoreBuilder, $request->getQuery(), $this->getSelect(), self::BOOL_MUST); + $select = $this->processDimensions($request, $select); + $tableName = $this->resource->getTableName($request->getIndex()); + $select->from($tableName) + ->columns($scoreBuilder->build()) + ->order($scoreBuilder->getScoreAlias() . ' ' . Select::SQL_DESC); + return $select; + } + + /** + * Process query + * + * @param ScoreBuilder $scoreBuilder + * @param RequestQueryInterface $query + * @param Select $select + * @param bool $isNot + * @return Select + * @throws \InvalidArgumentException + */ + protected function processQuery( + ScoreBuilder $scoreBuilder, + RequestQueryInterface $query, + Select $select, + $isNot + ) { + switch ($query->getType()) { + case RequestQueryInterface::TYPE_MATCH: + /** @var MatchQuery $query */ + $scoreBuilder->startQuery(); + $select = $this->matchQueryBuilder->build( + $scoreBuilder, + $select, + $query, + $isNot + ); + $scoreBuilder->endQuery($query->getBoost()); + break; + case RequestQueryInterface::TYPE_BOOL: + /** @var BoolQuery $query */ + $select = $this->processBoolQuery($scoreBuilder, $query, $select); + break; + case RequestQueryInterface::TYPE_FILTER: + /** @var FilterQuery $query */ + $select = $this->processFilterQuery($scoreBuilder, $query, $select, $isNot); + break; + default: + throw new \InvalidArgumentException(sprintf('Unknown query type \'%s\'', $query->getType())); + } + return $select; + } + + /** + * Process bool query + * + * @param ScoreBuilder $scoreBuilder + * @param BoolQuery $query + * @param Select $select + * @return Select + */ + private function processBoolQuery(ScoreBuilder $scoreBuilder, BoolQuery $query, Select $select) + { + $scoreBuilder->startQuery(); + + $select = $this->processBoolQueryCondition( + $scoreBuilder, + $query->getMust(), + $select, + self::BOOL_MUST + ); + + $select = $this->processBoolQueryCondition( + $scoreBuilder, + $query->getShould(), + $select, + self::BOOL_MUST + ); + + $select = $this->processBoolQueryCondition( + $scoreBuilder, + $query->getMustNot(), + $select, + self::BOOL_MUST_NOT + ); + + $scoreBuilder->endQuery($query->getBoost()); + + return $select; + } + + /** + * Process bool query condition (must, should, must_not) + * + * @param ScoreBuilder $scoreBuilder + * @param RequestQueryInterface[] $subQueryList + * @param Select $select + * @param bool $isNot + * @return Select + */ + private function processBoolQueryCondition( + ScoreBuilder $scoreBuilder, + array $subQueryList, + Select $select, + $isNot + ) { + foreach ($subQueryList as $subQuery) { + $select = $this->processQuery($scoreBuilder, $subQuery, $select, $isNot); + } + return $select; + } + + /** + * Process filter query + * + * @param ScoreBuilder $scoreBuilder + * @param FilterQuery $query + * @param Select $select + * @param bool $isNot + * @return Select + */ + private function processFilterQuery(ScoreBuilder $scoreBuilder, FilterQuery $query, Select $select, $isNot) + { + switch ($query->getReferenceType()) { + case FilterQuery::REFERENCE_QUERY: + $scoreBuilder->startQuery(); + $select = $this->processQuery($scoreBuilder, $query->getReference(), $select, $isNot); + $scoreBuilder->endQuery($query->getBoost()); + break; + case FilterQuery::REFERENCE_FILTER: + $filterCondition = $this->filterBuilder->build($query->getReference()); + if ($isNot === true) { + $filterCondition = '!' . $filterCondition; + } + $select->where($filterCondition); + $scoreBuilder->addCondition(1, $query->getBoost()); + break; + } + return $select; + } + + /** + * Get empty Select + * + * @return Select + */ + private function getSelect() + { + return $this->resource->getConnection(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE)->select(); + } + + /** + * Add filtering by dimensions + * + * @param RequestInterface $request + * @param Select $select + * @return \Magento\Framework\DB\Select + */ + private function processDimensions(RequestInterface $request, Select $select) + { + $dimensions = []; + foreach ($request->getDimensions() as $dimension) { + $dimensions[] = $this->dimensionsBuilder->build($dimension); + } + + if (!empty($dimensions)) { + $query = sprintf( + '(%s)', + implode(' ' . Select::SQL_OR . ' ', $dimensions) + ); + $select->where($query); + } + + return $select; } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php new file mode 100644 index 0000000000000000000000000000000000000000..2c57d1bc5226b13aeb205f51223f96044a00202e --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Query\Builder; + +use Magento\Framework\DB\Select; +use Magento\Framework\Search\Adapter\Mysql\ScoreBuilder; +use Magento\Framework\Search\Request\Query\Bool; +use Magento\Framework\Search\Request\QueryInterface as RequestQueryInterface; + +class Match implements QueryInterface +{ + /** + * {@inheritdoc} + */ + public function build( + ScoreBuilder $scoreBuilder, + Select $select, + RequestQueryInterface $query, + $conditionType + ) { + /** @var $query \Magento\Framework\Search\Request\Query\Match */ + foreach ($query->getMatches() as $match) { + $mode = Select::FULLTEXT_MODE_NATURAL; + if ($conditionType === Bool::QUERY_CONDITION_NOT) { + $match['value'] = '-' . $match['value']; + $mode = Select::FULLTEXT_MODE_BOOLEAN; + } + + $scoreBuilder->addCondition( + $select->getMatchQuery($match['field'], $match['value'], $mode), + isset($match['boost']) ? $match['boost'] : 1 + ); + + $select->match($match['field'], $match['value'], true, $mode); + } + return $select; + } +} diff --git a/app/code/Magento/Install/Controller/Wizard/LocaleChange.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php similarity index 60% rename from app/code/Magento/Install/Controller/Wizard/LocaleChange.php rename to lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php index 1b5428d1dae3c004444f10ce24c21de4172bf61a..98107060318f540ad70cd0907469471d10b591d1 100644 --- a/app/code/Magento/Install/Controller/Wizard/LocaleChange.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,26 +21,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; +namespace Magento\Framework\Search\Adapter\Mysql\Query\Builder; + +use Magento\Framework\Search\Adapter\Mysql\ScoreBuilder; -class LocaleChange extends \Magento\Install\Controller\Wizard +interface QueryInterface { /** - * Change current locale - * - * @return void + * @param \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder $scoreBuilder + * @param \Magento\Framework\DB\Select $select + * @param \Magento\Framework\Search\Request\QueryInterface $query + * @param bool $isNot + * @return \Magento\Framework\DB\Select */ - public function execute() - { - $this->_checkIfInstalled(); - - $locale = $this->getRequest()->getParam('locale'); - $timezone = $this->getRequest()->getParam('timezone'); - $currency = $this->getRequest()->getParam('currency'); - if ($locale) { - $this->_session->setLocale($locale)->setTimezone($timezone)->setCurrency($currency); - } - - $this->_redirect('*/*/locale'); - } + public function build( + ScoreBuilder $scoreBuilder, + \Magento\Framework\DB\Select $select, + \Magento\Framework\Search\Request\QueryInterface $query, + $isNot + ); } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php index 1040b48b5d911b10bd4aa2f4b359c57b856091b6..25f71db383e0f2b86d128c918283ac9be3d52d95 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php @@ -1,7 +1,5 @@ <?php /** - * Response Factory - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Adapter\Mysql; use Magento\Framework\Search\QueryResponse; +/** + * Response Factory + */ class ResponseFactory { /** @@ -73,13 +74,14 @@ class ResponseFactory */ public function create($rawResponse) { + $rawResponse = $this->prepareData($rawResponse); $documents = array(); foreach ($rawResponse['documents'] as $rawDocument) { /** @var \Magento\Framework\Search\Document[] $documents */ $documents[] = $this->documentFactory->create($rawDocument); } /** @var \Magento\Framework\Search\Aggregation $aggregations */ - $aggregations = $this->documentFactory->create($rawResponse['aggregation']); + $aggregations = $this->aggregationFactory->create($rawResponse['aggregations']); return $this->objectManager->create( '\Magento\Framework\Search\QueryResponse', [ @@ -88,4 +90,51 @@ class ResponseFactory ] ); } + + /** + * Preparing + * + * @param array $rawResponse + * @return array + */ + private function prepareData(array $rawResponse) + { + $preparedResponse = []; + $preparedResponse['documents'] = $this->prepareDocuments($rawResponse['documents']); + $preparedResponse['aggregations'] = $this->prepareAggregations($rawResponse['aggregations']); + return $preparedResponse; + } + + /** + * Prepare Documents + * + * @param array $rawDocumentList + * @return array + */ + private function prepareDocuments(array $rawDocumentList) + { + $documentList = []; + foreach ($rawDocumentList as $document) { + $documentFieldList = []; + foreach ($document as $name => $values) { + $documentFieldList[] = [ + 'name' => $name, + 'value' => $values + ]; + } + $documentList[] = $documentFieldList; + } + return $documentList; + } + + /** + * Prepare Aggregations + * + * @param array $rawAggregations + * @return array + */ + private function prepareAggregations(array $rawAggregations) + { + return $rawAggregations; // Prepare aggregations here + } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php new file mode 100644 index 0000000000000000000000000000000000000000..554d2a0768d56022a6e79878d39b4d315d4b3e59 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php @@ -0,0 +1,116 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +/** + * Class for generating sql condition for calculating store manager + */ +class ScoreBuilder +{ + /** + * @var string + */ + private $scoreCondition = ''; + + /** + * Get column alias for global score query in sql + * + * @return string + */ + public function getScoreAlias() + { + return 'global_score'; + } + + /** + * Get generated sql condition for global score + * + * @return string + */ + public function build() + { + $scoreCondition = $this->scoreCondition; + $this->clear(); + $scoreAlias = $this->getScoreAlias(); + + return "({$scoreCondition}) AS {$scoreAlias}"; + } + + /** + * Start Query + * + * @return void + */ + public function startQuery() + { + $this->addPlus(); + $this->scoreCondition .= '('; + } + + /** + * End Query + * + * @param float $boost + * @return void + */ + public function endQuery($boost) + { + $this->scoreCondition .= ") * {$boost}"; + } + + /** + * Add Condition for score calculation + * + * @param string $score + * @param float $boost + * @return void + */ + public function addCondition($score, $boost) + { + $this->addPlus(); + $this->scoreCondition .= "{$score} * {$boost}"; + } + + /** + * Add Plus sign for Score calculation + * + * @return void + */ + private function addPlus() + { + if (!empty($this->scoreCondition) && substr($this->scoreCondition, -1) != '(') { + $this->scoreCondition .= ' + '; + } + } + + /** + * Clear score manager + * + * @return void + */ + private function clear() + { + $this->scoreCondition = ''; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Factory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php similarity index 68% rename from app/code/Magento/Sales/Model/Resource/Factory.php rename to lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php index fe617ed01912ba1065882a381925d5a5fff0caed..fc6ea871c61cafeb9e08591a437407a1e2b274ba 100644 --- a/app/code/Magento/Sales/Model/Resource/Factory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Model\Resource; +namespace Magento\Framework\Search\Adapter\Mysql; /** - * Factory class for \Magento\Sales\Model\Resource\Order\AbstractOrder + * ScoreBuilder Factory */ -class Factory +class ScoreBuilderFactory { /** * Object Manager instance @@ -35,25 +35,35 @@ class Factory */ protected $_objectManager = null; + /** + * Instance name to create + * + * @var string + */ + protected $_instanceName = null; + /** * Factory constructor * * @param \Magento\Framework\ObjectManager $objectManager + * @param string $instanceName */ - public function __construct(\Magento\Framework\ObjectManager $objectManager) - { + public function __construct( + \Magento\Framework\ObjectManager $objectManager, + $instanceName = 'Magento\Framework\Search\Adapter\Mysql\ScoreBuilder' + ) { $this->_objectManager = $objectManager; + $this->_instanceName = $instanceName; } /** * Create class instance with specified parameters * - * @param string $instanceName * @param array $data - * @return \Magento\Sales\Model\Resource\Order\AbstractOrder + * @return \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder */ - public function create($instanceName, array $data = array()) + public function create(array $data = array()) { - return $this->_objectManager->create($instanceName, $data); + return $this->_objectManager->create($this->_instanceName, $data); } } diff --git a/lib/internal/Magento/Framework/Search/AdapterFactory.php b/lib/internal/Magento/Framework/Search/AdapterFactory.php index 72af3424bd6c7642e4f1d6e90b3abf1aa0e50976..3540caf62805e26f86c1c9630f1ee4d27fa922cc 100644 --- a/lib/internal/Magento/Framework/Search/AdapterFactory.php +++ b/lib/internal/Magento/Framework/Search/AdapterFactory.php @@ -1,7 +1,5 @@ <?php /** - * Adapter Factory - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Adapter Factory + */ class AdapterFactory { /** diff --git a/lib/internal/Magento/Framework/Search/AdapterInterface.php b/lib/internal/Magento/Framework/Search/AdapterInterface.php index b439981f00e88ceb37ff012de205c80ab171d230..33d98c49f52ad216388b6e0fab913181febf0533 100644 --- a/lib/internal/Magento/Framework/Search/AdapterInterface.php +++ b/lib/internal/Magento/Framework/Search/AdapterInterface.php @@ -1,7 +1,5 @@ <?php /** - * Search Adapter interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Adapter interface + */ interface AdapterInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Aggregation.php b/lib/internal/Magento/Framework/Search/Aggregation.php index b9a065fb59987cd737f3fa3dac5e29e1da12cd54..8c5f8ca7fb5a250a1151ab263413c81ae594d1fe 100644 --- a/lib/internal/Magento/Framework/Search/Aggregation.php +++ b/lib/internal/Magento/Framework/Search/Aggregation.php @@ -1,7 +1,5 @@ <?php /** - * Faceted data - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Faceted data + */ class Aggregation implements \IteratorAggregate { /** diff --git a/lib/internal/Magento/Framework/Search/Bucket.php b/lib/internal/Magento/Framework/Search/Bucket.php index 17e7f27a704f76accde138319bfdec18be80c961..9481611035138b7f7ea2f7eee237f20e7bfa604f 100644 --- a/lib/internal/Magento/Framework/Search/Bucket.php +++ b/lib/internal/Magento/Framework/Search/Bucket.php @@ -1,7 +1,5 @@ <?php /** - * Facet Bucket - * * Magento * * NOTICE OF LICENSE @@ -25,49 +23,9 @@ */ namespace Magento\Framework\Search; -class Bucket +/** + * Facet Bucket + */ +class Bucket extends AbstractKeyValuePair { - /** - * Bucket name - * - * @var string - */ - protected $name; - - /** - * Bucket value - * - * @var mixed - */ - protected $value; - - /** - * @param string $name - * @param mixed $value - */ - public function __construct($name, $value) - { - $this->name = $name; - $this->value = $value; - } - - /** - * Get bucket name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get bucket values - * - * @return mixed - */ - public function getValue() - { - return $this->value; - } } diff --git a/lib/internal/Magento/Framework/Search/Document.php b/lib/internal/Magento/Framework/Search/Document.php index ea540197a39247a38e59a133150ca3bfa0b8c69f..1d0ba3c731692aae9a5d1bf7d19e16d62d41763f 100644 --- a/lib/internal/Magento/Framework/Search/Document.php +++ b/lib/internal/Magento/Framework/Search/Document.php @@ -1,7 +1,5 @@ <?php /** - * Search Document - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Document + */ class Document implements \IteratorAggregate { /** diff --git a/lib/internal/Magento/Framework/Search/DocumentField.php b/lib/internal/Magento/Framework/Search/DocumentField.php index 5e8af0f3cfe344966370fd922e11feaaaf8a868f..195ecbdc7d8f7c9e16b679c9660a53bf51ac4746 100644 --- a/lib/internal/Magento/Framework/Search/DocumentField.php +++ b/lib/internal/Magento/Framework/Search/DocumentField.php @@ -1,7 +1,5 @@ <?php /** - * Search Document Field - * * Magento * * NOTICE OF LICENSE @@ -25,49 +23,9 @@ */ namespace Magento\Framework\Search; -class DocumentField +/** + * Search Document Field + */ +class DocumentField extends AbstractKeyValuePair { - /** - * Document field name - * - * @var string - */ - protected $name; - - /** - * Document field values - * - * @var array - */ - protected $values; - - /** - * @param string $name - * @param array $values - */ - public function __construct($name, array $values) - { - $this->name = $name; - $this->values = $values; - } - - /** - * Get field name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get field values - * - * @return array - */ - public function getValues() - { - return $this->values; - } } diff --git a/lib/internal/Magento/Framework/Search/EntityMetadata.php b/lib/internal/Magento/Framework/Search/EntityMetadata.php new file mode 100644 index 0000000000000000000000000000000000000000..7b732606833c7436b4651e054e22c73c57662e30 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/EntityMetadata.php @@ -0,0 +1,54 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\Search; + +/** + * Entity metadata + */ +class EntityMetadata +{ + /** + * @var string + */ + private $entityId; + + /** + * @param string $entityId + */ + public function __construct($entityId) + { + $this->entityId = $entityId; + } + + /** + * Get entity id + * + * @return string + */ + public function getEntityId() + { + return $this->entityId; + } +} diff --git a/lib/internal/Magento/Framework/Search/QueryResponse.php b/lib/internal/Magento/Framework/Search/QueryResponse.php index f93bb9156420dccc2df4ae52b4109ab7286cc4c7..b3188a55599202bd1273016dac3c5e1c946d0835 100644 --- a/lib/internal/Magento/Framework/Search/QueryResponse.php +++ b/lib/internal/Magento/Framework/Search/QueryResponse.php @@ -1,7 +1,5 @@ <?php /** - * Search Response - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Response + */ class QueryResponse implements ResponseInterface, \IteratorAggregate, \Countable { /** @@ -37,15 +38,15 @@ class QueryResponse implements ResponseInterface, \IteratorAggregate, \Countable /** * Aggregation Collection * - * @var Aggregation[] + * @var Aggregation */ protected $aggregations; /** * @param Document[] $documents - * @param Aggregation[] $aggregations + * @param Aggregation $aggregations */ - public function __construct(array $documents, array $aggregations) + public function __construct(array $documents, Aggregation $aggregations) { $this->documents = $documents; $this->aggregations = $aggregations; @@ -73,7 +74,7 @@ class QueryResponse implements ResponseInterface, \IteratorAggregate, \Countable /** * Return Aggregation Collection * - * @return Aggregation[] + * @return Aggregation */ public function getAggregations() { diff --git a/lib/internal/Magento/Framework/Search/Request.php b/lib/internal/Magento/Framework/Search/Request.php index 787aed2417aaddbcd31c276d74cc3d0da98888d4..939805ff3ba3f79aea72906e1dd31748e84844aa 100644 --- a/lib/internal/Magento/Framework/Search/Request.php +++ b/lib/internal/Magento/Framework/Search/Request.php @@ -1,6 +1,5 @@ <?php /** - * Search Request * Magento * * NOTICE OF LICENSE @@ -29,6 +28,8 @@ use Magento\Framework\Search\Request\Dimension; use Magento\Framework\Search\Request\QueryInterface; /** + * Search Request + * * @codeCoverageIgnore */ class Request implements RequestInterface @@ -118,7 +119,7 @@ class Request implements RequestInterface */ public function getDimensions() { - $this->dimensions; + return $this->dimensions; } /** diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php index ac529f8ed124da186f12eefef79eabf5cf335a47..b4902e8cec0e6a0a8e42f537d0f64155f6d7c73a 100644 --- a/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php @@ -1,7 +1,5 @@ <?php /** - * Metric - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request\Aggregation; +/** + * Metric + */ class Metric { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php index 705ec8ea551c11751f7752f6c26cf42c3a0b8139..6735b84f53d1d985f7aae641a59ce8c5f2c2c3b3 100644 --- a/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php @@ -1,7 +1,5 @@ <?php /** - * Range - * * Magento * * NOTICE OF LICENSE @@ -26,6 +24,7 @@ namespace Magento\Framework\Search\Request\Aggregation; /** + * Range * @SuppressWarnings(PHPMD.ShortVariable) */ class Range diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php index 22028dfe32919b5898b74b920365f738dc3d9144..f4b8b8461932b45d4e1702c4655dd1c2b1bc3a94 100644 --- a/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php @@ -1,7 +1,5 @@ <?php /** - * Range Buckets - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Aggregation; use Magento\Framework\Search\Request\BucketInterface; +/** + * Range Buckets + */ class RangeBucket implements BucketInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php index 6c4fca13c4ddac164cdaadd39f04b40af69df865..650c93b49107f4c0459a9b374423657ce0318e93 100644 --- a/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php @@ -1,7 +1,5 @@ <?php /** - * Term Buckets - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Aggregation; use Magento\Framework\Search\Request\BucketInterface; +/** + * Term Buckets + */ class TermBucket implements BucketInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/BucketInterface.php b/lib/internal/Magento/Framework/Search/Request/BucketInterface.php index 3457b28817958944f81cdb75dbf9687321db7cf3..eb060564761a6dffcbdbf84f2ed55a6247f9257d 100644 --- a/lib/internal/Magento/Framework/Search/Request/BucketInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/BucketInterface.php @@ -1,7 +1,5 @@ <?php /** - * Aggregation Bucket Interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request; +/** + * Aggregation Bucket Interface + */ interface BucketInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Config/Converter.php b/lib/internal/Magento/Framework/Search/Request/Config/Converter.php index 9c244774944cf04a003d8a74b8fec6b5c1d393fa..2cd3ded1c81483162f388e5328fe4cfc127cee05 100644 --- a/lib/internal/Magento/Framework/Search/Request/Config/Converter.php +++ b/lib/internal/Magento/Framework/Search/Request/Config/Converter.php @@ -1,6 +1,5 @@ <?php /** - * Search Request xml converter * Magento * * NOTICE OF LICENSE @@ -24,6 +23,9 @@ */ namespace Magento\Framework\Search\Request\Config; +/** + * Search Request xml converter + */ class Converter implements \Magento\Framework\Config\ConverterInterface { /** @@ -45,7 +47,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface $request['dimensions'] = $this->convertNodes($simpleXmlNode->dimensions, 'name'); $request['queries'] = $this->convertNodes($simpleXmlNode->queries, 'name'); $request['filters'] = $this->convertNodes($simpleXmlNode->filters, 'name'); - $request['aggregation'] = $this->convertNodes($simpleXmlNode->aggregation, 'name'); + $request['aggregations'] = $this->convertNodes($simpleXmlNode->aggregations, 'name'); $requests[$name] = $request; } return $requests; @@ -66,17 +68,6 @@ class Converter implements \Magento\Framework\Config\ConverterInterface return $data; } - /** - * Deep converting simlexml element to array - * - * @param \SimpleXMLElement $node - * @return array - */ - protected function convertToArray(\SimpleXMLElement $node) - { - return $this->mergeAttributes(json_decode(json_encode($node), true)); - } - /** * Convert nodes to array * @@ -87,22 +78,35 @@ class Converter implements \Magento\Framework\Config\ConverterInterface protected function convertNodes(\SimpleXMLElement $nodes, $name) { $list = []; - /** @var \SimpleXMLElement $node */ - foreach ($nodes->children() as $node) { - $element = $this->convertToArray($node->attributes()); - if ($node->count() > 0) { - $element = $this->convertChildNodes($element, $node); - } - $type = (string)$node->attributes('xsi', true)['type']; - if (!empty($type)) { - $element['type'] = $type; - } + if (!empty($nodes)) { + /** @var \SimpleXMLElement $node */ + foreach ($nodes->children() as $node) { + $element = $this->convertToArray($node->attributes()); + if ($node->count() > 0) { + $element = $this->convertChildNodes($element, $node); + } + $type = (string)$node->attributes('xsi', true)['type']; + if (!empty($type)) { + $element['type'] = $type; + } - $list[$element[$name]] = $element; + $list[$element[$name]] = $element; + } } return $list; } + /** + * Deep converting simlexml element to array + * + * @param \SimpleXMLElement $node + * @return array + */ + protected function convertToArray(\SimpleXMLElement $node) + { + return $this->mergeAttributes(json_decode(json_encode($node), true)); + } + /** * Convert child nodes to array * diff --git a/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php b/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php index f76772e36beb873ec476254f63892e241fb14594..103b7fe0f7b7c796f909e0e1cb662f2f4e9c9787 100644 --- a/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php +++ b/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php @@ -1,7 +1,5 @@ <?php /** - * Search Request schema locator - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request\Config; +/** + * Search Request schema locator + */ class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Dimension.php b/lib/internal/Magento/Framework/Search/Request/Dimension.php index 1cdc73a0b24b07c7056fc0d8f9dce3ae822f20d0..e391198ac0284a8e87826b0bdde64e93c9a28472 100644 --- a/lib/internal/Magento/Framework/Search/Request/Dimension.php +++ b/lib/internal/Magento/Framework/Search/Request/Dimension.php @@ -23,37 +23,11 @@ */ namespace Magento\Framework\Search\Request; -class Dimension -{ - /** @var string */ - private $name; - - /** @var string */ - private $value; - - /** - * @param string $name - * @param string $value - */ - public function __construct($name, $value) - { - $this->name = $name; - $this->value = $value; - } - - /** - * @return string - */ - public function getValue() - { - return $this->value; - } +use Magento\Framework\Search\AbstractKeyValuePair; - /** - * @return string - */ - public function getName() - { - return $this->name; - } +/** + * Search Request Dimension + */ +class Dimension extends AbstractKeyValuePair +{ } diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php b/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php index b83fdf3df443ed07eaaaa92f3a5a40ad0e44531f..fe86bd5cc66e5fb87a4030e43aff7e02d03d0f26 100644 --- a/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php @@ -1,6 +1,5 @@ <?php /** - * Bool Filter * Magento * * NOTICE OF LICENSE @@ -26,6 +25,9 @@ namespace Magento\Framework\Search\Request\Filter; use Magento\Framework\Search\Request\FilterInterface; +/** + * Bool Filter + */ class Bool implements FilterInterface { /** @@ -87,7 +89,7 @@ class Bool implements FilterInterface /** * Get Must filters * - * @return array + * @return \Magento\Framework\Search\Request\FilterInterface[] */ public function getMust() { @@ -97,7 +99,7 @@ class Bool implements FilterInterface /** * Get Should filters * - * @return array + * @return \Magento\Framework\Search\Request\FilterInterface[] */ public function getShould() { @@ -107,7 +109,7 @@ class Bool implements FilterInterface /** * Get Must Not filters * - * @return array + * @return \Magento\Framework\Search\Request\FilterInterface[] */ public function getMustNot() { diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Range.php b/lib/internal/Magento/Framework/Search/Request/Filter/Range.php index db64a3894f8f8867e5d15f762ee1ed92e92fe5c0..50c7fe8cbcfe8125e57039d64e014076d9693919 100644 --- a/lib/internal/Magento/Framework/Search/Request/Filter/Range.php +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Range.php @@ -1,7 +1,5 @@ <?php /** - * Range Filter - * * Magento * * NOTICE OF LICENSE @@ -28,6 +26,7 @@ namespace Magento\Framework\Search\Request\Filter; use Magento\Framework\Search\Request\FilterInterface; /** + * Range Filter * @SuppressWarnings(PHPMD.ShortVariable) */ class Range implements FilterInterface diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Term.php b/lib/internal/Magento/Framework/Search/Request/Filter/Term.php index 1ee1e0628385396c3d1f10c4021aa457091d9b80..98518dee35236cec9cdeabf7cdc79a1e830b7736 100644 --- a/lib/internal/Magento/Framework/Search/Request/Filter/Term.php +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Term.php @@ -1,7 +1,5 @@ <?php /** - * Term Filter - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Filter; use Magento\Framework\Search\Request\FilterInterface; +/** + * Term Filter + */ class Term implements FilterInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/FilterInterface.php b/lib/internal/Magento/Framework/Search/Request/FilterInterface.php index 4f7df883ff345a0d1583bbfa7901e3df6a5571e4..d1b594594b4338cec7bcff3fbab4e98741ed37cc 100644 --- a/lib/internal/Magento/Framework/Search/Request/FilterInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/FilterInterface.php @@ -1,7 +1,5 @@ <?php /** - * Filter Interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request; +/** + * Filter Interface + */ interface FilterInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Mapper.php b/lib/internal/Magento/Framework/Search/Request/Mapper.php index 8b76ac54787b0021845eb054eeb252861d6348d5..6a35bbae6fa246341843950c7db5bc15763911b0 100644 --- a/lib/internal/Magento/Framework/Search/Request/Mapper.php +++ b/lib/internal/Magento/Framework/Search/Request/Mapper.php @@ -51,7 +51,7 @@ class Mapper /** * @var array */ - private $aggregation; + private $aggregations; /** * @var \Magento\Framework\ObjectManager @@ -67,7 +67,7 @@ class Mapper * @param \Magento\Framework\ObjectManager $objectManager * @param array $queries * @param string $rootQueryName - * @param array $aggregation + * @param array $aggregations * @param array $filters * @throws \Exception * @throws \InvalidArgumentException @@ -77,12 +77,12 @@ class Mapper \Magento\Framework\ObjectManager $objectManager, array $queries, $rootQueryName, - array $aggregation, + array $aggregations = [], array $filters = [] ) { $this->objectManager = $objectManager; $this->queries = $queries; - $this->aggregation = $aggregation; + $this->aggregations = $aggregations; $this->filters = $filters; $this->rootQuery = $this->get($rootQueryName); @@ -245,8 +245,8 @@ class Mapper [ 'name' => $filter['name'], 'field' => $filter['field'], - 'from' => $filter['from'], - 'to' => $filter['to'] + 'from' => isset($filter['from']) ? $filter['from'] : null, + 'to' => isset($filter['to']) ? $filter['to'] : null, ] ); @@ -283,7 +283,7 @@ class Mapper */ private function validateQueries() { - $this->validateNotUsed($this->queries, $this->mappedQueries, 'Query %1 not used in request hierarchy'); + $this->validateNotUsed($this->queries, $this->mappedQueries, 'Query %1 is not used in request hierarchy'); } /** @@ -292,7 +292,7 @@ class Mapper */ private function validateFilters() { - $this->validateNotUsed($this->filters, $this->mappedFilters, 'Filter %1 not used in request hierarchy'); + $this->validateNotUsed($this->filters, $this->mappedFilters, 'Filter %1 is not used in request hierarchy'); } /** @@ -320,7 +320,7 @@ class Mapper public function getBuckets() { $buckets = array(); - foreach ($this->aggregation as $bucketData) { + foreach ($this->aggregations as $bucketData) { $arguments = [ 'name' => $bucketData['name'], diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Bool.php b/lib/internal/Magento/Framework/Search/Request/Query/Bool.php index 186c96acf9b9ee2b50f2743144b2d2ecabbb4faa..ea48a2f2c09d9e3e1db9a85fa96760810dce361e 100644 --- a/lib/internal/Magento/Framework/Search/Request/Query/Bool.php +++ b/lib/internal/Magento/Framework/Search/Request/Query/Bool.php @@ -1,6 +1,5 @@ <?php /** - * Bool Query * Magento * * NOTICE OF LICENSE @@ -26,8 +25,15 @@ namespace Magento\Framework\Search\Request\Query; use Magento\Framework\Search\Request\QueryInterface; +/** + * Bool Query + */ class Bool implements QueryInterface { + const QUERY_CONDITION_MUST = 'must'; + const QUERY_CONDITION_SHOULD = 'should'; + const QUERY_CONDITION_NOT = 'not'; + /** * Boost * @@ -106,7 +112,7 @@ class Bool implements QueryInterface /** * Get Should queries * - * @return array + * @return QueryInterface[] */ public function getShould() { @@ -116,7 +122,7 @@ class Bool implements QueryInterface /** * Get Must queries * - * @return array + * @return QueryInterface[] */ public function getMust() { @@ -126,7 +132,7 @@ class Bool implements QueryInterface /** * Get Must Not queries * - * @return array + * @return QueryInterface[] */ public function getMustNot() { diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Filter.php b/lib/internal/Magento/Framework/Search/Request/Query/Filter.php index 480daadb74b69feb95079e2e8e4f35f8a2aa8f77..151e4c098afb1219175f6bb90875d0cb68c160ed 100644 --- a/lib/internal/Magento/Framework/Search/Request/Query/Filter.php +++ b/lib/internal/Magento/Framework/Search/Request/Query/Filter.php @@ -1,7 +1,5 @@ <?php /** - * Term Query - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Query; use Magento\Framework\Search\Request\QueryInterface; +/** + * Term Query + */ class Filter implements QueryInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Match.php b/lib/internal/Magento/Framework/Search/Request/Query/Match.php index da0d3df48490952074f56613320107531032a437..e32b458a43517bf71b406efbca9016708c9c2105 100644 --- a/lib/internal/Magento/Framework/Search/Request/Query/Match.php +++ b/lib/internal/Magento/Framework/Search/Request/Query/Match.php @@ -1,7 +1,5 @@ <?php /** - * Match Query - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Query; use Magento\Framework\Search\Request\QueryInterface; +/** + * Match Query + */ class Match implements QueryInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/QueryInterface.php b/lib/internal/Magento/Framework/Search/Request/QueryInterface.php index 8b709d0571708039472ac095cd702c627db4136f..45a553639543b30db8b40a13c710124c4d71a105 100644 --- a/lib/internal/Magento/Framework/Search/Request/QueryInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/QueryInterface.php @@ -1,7 +1,5 @@ <?php /** - * Query Interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request; +/** + * Query Interface + */ interface QueryInterface { /** diff --git a/lib/internal/Magento/Framework/Search/RequestFactory.php b/lib/internal/Magento/Framework/Search/RequestFactory.php index a83c16c9c6f822722ea65eb0f82e84b7e1851ba0..0846e0e74887dfe9ec8173881f42629953d22286 100644 --- a/lib/internal/Magento/Framework/Search/RequestFactory.php +++ b/lib/internal/Magento/Framework/Search/RequestFactory.php @@ -1,6 +1,5 @@ <?php /** - * Search Request Pool * Magento * * NOTICE OF LICENSE @@ -24,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Request Pool + */ class RequestFactory { const CACHE_PREFIX = 'search_request::'; @@ -103,7 +105,7 @@ class RequestFactory 'objectManager' => $this->objectManager, 'rootQueryName' => $data['query'], 'queries' => $data['queries'], - 'aggregation' => $data['aggregation'], + 'aggregations' => $data['aggregations'], 'filters' => $data['filters'] ] ); @@ -115,14 +117,14 @@ class RequestFactory 'from' => $data['from'], 'size' => $data['size'], 'query' => $mapper->getRootQuery(), - 'demensions' => array_map( + 'dimensions' => array_map( function ($data) { return $this->objectManager->create( 'Magento\Framework\Search\Request\Dimension', $data ); }, - isset($data['demensions']) ? $data['demensions'] : [] + isset($data['dimensions']) ? $data['dimensions'] : [] ), 'buckets' => $mapper->getBuckets() ] diff --git a/lib/internal/Magento/Framework/Search/RequestInterface.php b/lib/internal/Magento/Framework/Search/RequestInterface.php index 822b29af80d4ae53323e3e534521fc5f44d67816..5de079c302e0d0474b8e3cdbe5559a05b038d7a2 100644 --- a/lib/internal/Magento/Framework/Search/RequestInterface.php +++ b/lib/internal/Magento/Framework/Search/RequestInterface.php @@ -1,7 +1,5 @@ <?php /** - * Search Request - * * Magento * * NOTICE OF LICENSE @@ -29,6 +27,9 @@ use Magento\Framework\Search\Request\BucketInterface; use Magento\Framework\Search\Request\QueryInterface; use Magento\Framework\Search\Request\Dimension; +/** + * Search Request + */ interface RequestInterface { /** diff --git a/lib/internal/Magento/Framework/Search/ResponseInterface.php b/lib/internal/Magento/Framework/Search/ResponseInterface.php index 9b058362b33f04f0e7b5d68c8c0c5bb6803cbf1d..13192b32fe16f936633099e45d15cc600fcbb16f 100644 --- a/lib/internal/Magento/Framework/Search/ResponseInterface.php +++ b/lib/internal/Magento/Framework/Search/ResponseInterface.php @@ -1,7 +1,5 @@ <?php /** - * Search Request - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Request + */ interface ResponseInterface { } diff --git a/lib/internal/Magento/Framework/Search/SearchEngine.php b/lib/internal/Magento/Framework/Search/SearchEngine.php index 8297585cd909b6ae1b8c8c885e588850c66bd07d..6fee0377130125ce2f4ffc5272640e56ac2d80cc 100644 --- a/lib/internal/Magento/Framework/Search/SearchEngine.php +++ b/lib/internal/Magento/Framework/Search/SearchEngine.php @@ -1,7 +1,5 @@ <?php /** - * Search Engine - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Engine + */ class SearchEngine implements SearchEngineInterface { /** diff --git a/lib/internal/Magento/Framework/Search/SearchEngineInterface.php b/lib/internal/Magento/Framework/Search/SearchEngineInterface.php index aab97f199419dd26a35df6cfca5451f1e4ba0cc2..5c01556a462408cc6f00388c528f503cb2429c19 100644 --- a/lib/internal/Magento/Framework/Search/SearchEngineInterface.php +++ b/lib/internal/Magento/Framework/Search/SearchEngineInterface.php @@ -1,7 +1,5 @@ <?php /** - * Search Engine interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Engine interface + */ interface SearchEngineInterface { /** diff --git a/lib/internal/Magento/Framework/Search/etc/requests.xsd b/lib/internal/Magento/Framework/Search/etc/requests.xsd index cfdd133b4588673756545d3c13744e4a51dd5407..f24cbc813f3b190137b32928f33a9520f0339047 100644 --- a/lib/internal/Magento/Framework/Search/etc/requests.xsd +++ b/lib/internal/Magento/Framework/Search/etc/requests.xsd @@ -34,13 +34,13 @@ <xs:field xpath="@name" /> </xs:key> </xs:element> - <xs:element type="filters" name="filters"> + <xs:element type="filters" name="filters" minOccurs="0"> <xs:key name="filterName"> <xs:selector xpath="filter" /> <xs:field xpath="@name" /> </xs:key> </xs:element> - <xs:element type="aggregation" name="aggregation" > + <xs:element type="aggregation" name="aggregation" minOccurs="0"> <xs:key name="aggregationName"> <xs:selector xpath="bucket" /> <xs:field xpath="@name" /> @@ -168,8 +168,8 @@ <xs:complexContent> <xs:extension base="filter"> <xs:attribute type="xs:string" name="field" use="required" /> - <xs:attribute type="xs:string" name="from" use="required" /> - <xs:attribute type="xs:string" name="to" use="required" /> + <xs:attribute type="xs:string" name="from" use="optional" /> + <xs:attribute type="xs:string" name="to" use="optional" /> </xs:extension> </xs:complexContent> </xs:complexType> @@ -289,4 +289,4 @@ <xs:attribute type="xs:string" name="to" use="required" /> <xs:attribute type="xs:string" name="from" use="required" /> </xs:complexType> -</xs:schema> \ No newline at end of file +</xs:schema> diff --git a/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd b/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd index dfedcfe2742715b1bb24c94b006635e09095af84..797fdd6d38de6160073c379995a54d92baaa0fb2 100644 --- a/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd +++ b/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd @@ -44,5 +44,10 @@ </xs:element> </xs:sequence> </xs:complexType> - <xs:element name="requests" type="requests"/> + <xs:element name="requests" type="requests"> + <xs:unique name="uniqueRequest"> + <xs:selector xpath="./*" /> + <xs:field xpath="@query" /> + </xs:unique> + </xs:element> </xs:schema> \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Service/ArrayObjectSearch.php b/lib/internal/Magento/Framework/Service/ArrayObjectSearch.php new file mode 100644 index 0000000000000000000000000000000000000000..3a0d400fbfcabda3e8b9d927c42559373872daf1 --- /dev/null +++ b/lib/internal/Magento/Framework/Service/ArrayObjectSearch.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\Service; + +/** + * Class to provide possibility to search for any object's property value by the name and value of another property + */ +class ArrayObjectSearch +{ + /** + * Search for the value's value by specified key's name-value pair in the object + * <pre> + * Example of usage: + * $data = array( + * ValidationRuleBuilderObject('name' => 'min_text_length', 'value' => 0) + * ValidationRuleBuilderObject('name' => 'max_text_length', 'value' => 255) + * ValidationRuleBuilderObject('anyOtherName' => 'customName', 'anyOtherValue' => 'customValue') + * ); + * + * Call: + * $maxDateValue = ArrayObjectSearch::getArrayElementByName( + * $data, + * 'max_text_length' + * ); + * By default function looks for `value`'s value by the `name`'s value + * Result: 255 + * + * Call: + * $customValue = ArrayObjectSearch::getArrayElementByName( + * $data, + * 'customName', //what key value to look for + * 'anyOtherName', //where to look for + * 'anyOtherValue' //where to return from + * ); + * Result: 'customValue' + * </pre> + * @param object $data Object to search in + * @param string $keyValue Value of the key property to search for + * @param string $keyName Name of the key property to search for + * @param string $valueName Name of the value property name + * @return null|mixed + */ + public static function getArrayElementByName($data, $keyValue, $keyName = 'name', $valueName = 'value') + { + $getter = 'get' . ucfirst($keyName); + if (is_array($data)) { + foreach ($data as $dataObject) { + if (is_object($dataObject) && $dataObject->$getter() == $keyValue) { + $valueGetter = 'get' . ucfirst($valueName); + return $dataObject->$valueGetter(); + } + } + } + return null; + } +} diff --git a/lib/internal/Magento/Framework/Service/Config/MetadataConfig.php b/lib/internal/Magento/Framework/Service/Config/MetadataConfig.php index dbea342f083767f09bb96d42f8aa356576f061d4..972541d4a7e702a85e2b73ccca4070ae90e760ed 100644 --- a/lib/internal/Magento/Framework/Service/Config/MetadataConfig.php +++ b/lib/internal/Magento/Framework/Service/Config/MetadataConfig.php @@ -47,7 +47,7 @@ class MetadataConfig implements MetadataServiceInterface * Initialize dependencies. * * @param ServiceConfigReader $serviceConfigReader - * @param AttributeMetadataBuilderInterface|null $attributeMetadataBuilder + * @param AttributeMetadataBuilderInterface $attributeMetadataBuilder */ public function __construct( ServiceConfigReader $serviceConfigReader, diff --git a/lib/internal/Magento/Framework/Service/Data/AbstractExtensibleObjectBuilder.php b/lib/internal/Magento/Framework/Service/Data/AbstractExtensibleObjectBuilder.php index 47e60fabb2d72f036fc3eb5f53a374f8392d0ecd..2607389e112293552993a988af81775eef7a9295 100644 --- a/lib/internal/Magento/Framework/Service/Data/AbstractExtensibleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Service/Data/AbstractExtensibleObjectBuilder.php @@ -134,7 +134,7 @@ abstract class AbstractExtensibleObjectBuilder extends AbstractSimpleObjectBuild $dataObjectMethods = get_class_methods($this->_getDataObjectType()); foreach ($data as $key => $value) { /* First, verify is there any getter for the key on the Service Data Object */ - $camelCaseKey = \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($key); + $camelCaseKey = \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key); $possibleMethods = array( 'get' . $camelCaseKey, 'is' . $camelCaseKey diff --git a/lib/internal/Magento/Framework/Service/Data/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Service/Data/AbstractSimpleObjectBuilder.php index 11226935bbca261acf8081ee20936c176b6f53a2..44adce498d4a011bc0be8bb4931984a4581d6580 100644 --- a/lib/internal/Magento/Framework/Service/Data/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Service/Data/AbstractSimpleObjectBuilder.php @@ -91,8 +91,8 @@ abstract class AbstractSimpleObjectBuilder foreach ($data as $key => $value) { /* First, verify is there any getter for the key on the Service Data Object */ $possibleMethods = array( - 'get' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($key), - 'is' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($key) + 'get' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key), + 'is' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key) ); if (array_intersect($possibleMethods, $dataObjectMethods)) { $this->_data[$key] = $value; diff --git a/app/code/Magento/Install/Controller/Wizard/DownloadManual.php b/lib/internal/Magento/Framework/Service/Data/AttributeMetadata.php similarity index 71% rename from app/code/Magento/Install/Controller/Wizard/DownloadManual.php rename to lib/internal/Magento/Framework/Service/Data/AttributeMetadata.php index 2e2d7833ac393d4b6fe224a782235a2f003c11d5..e95966363dc86cd76a9bcc801eb34022bb29d0e6 100644 --- a/app/code/Magento/Install/Controller/Wizard/DownloadManual.php +++ b/lib/internal/Magento/Framework/Service/Data/AttributeMetadata.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,18 +21,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class DownloadManual extends \Magento\Install\Controller\Wizard +namespace Magento\Framework\Service\Data; + +/** + * Base data object for custom attribute metadata + */ +class AttributeMetadata extends AbstractSimpleObject implements MetadataObjectInterface { + const ATTRIBUTE_CODE = 'attribute_code'; + /** - * Download manual action + * Retrieve code of the attribute. * - * @return void + * @return string|null */ - public function execute() + public function getAttributeCode() { - $step = $this->_getWizard()->getStepByName('download'); - $this->getResponse()->setRedirect($step->getNextUrl()); + return $this->_get(self::ATTRIBUTE_CODE); } } diff --git a/lib/internal/Magento/Framework/Service/ExtensibleDataObjectConverter.php b/lib/internal/Magento/Framework/Service/ExtensibleDataObjectConverter.php index 9839e08b724da4e0f1323e24e5ce79ad030380d9..f1f0afb02e464bd3d942efb3492a13881d9b5e68 100644 --- a/lib/internal/Magento/Framework/Service/ExtensibleDataObjectConverter.php +++ b/lib/internal/Magento/Framework/Service/ExtensibleDataObjectConverter.php @@ -37,9 +37,10 @@ class ExtensibleDataObjectConverter * Convert AbstractExtensibleObject into flat array. * * @param AbstractExtensibleObject $dataObject + * @param string[] $skipCustomAttributes * @return array */ - public static function toFlatArray(AbstractExtensibleObject $dataObject) + public static function toFlatArray(AbstractExtensibleObject $dataObject, $skipCustomAttributes = array()) { $dataObjectArray = $dataObject->__toArray(); //process custom attributes if present @@ -48,8 +49,10 @@ class ExtensibleDataObjectConverter $customAttributes = $dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY]; unset ($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY]); foreach ($customAttributes as $attributeValue) { - $dataObjectArray[$attributeValue[AttributeValue::ATTRIBUTE_CODE]] - = $attributeValue[AttributeValue::VALUE]; + if (!in_array($attributeValue[AttributeValue::ATTRIBUTE_CODE], $skipCustomAttributes)) { + $dataObjectArray[$attributeValue[AttributeValue::ATTRIBUTE_CODE]] + = $attributeValue[AttributeValue::VALUE]; + } } } return ConvertArray::toFlatArray($dataObjectArray); diff --git a/lib/internal/Magento/Framework/Service/SimpleDataObjectConverter.php b/lib/internal/Magento/Framework/Service/SimpleDataObjectConverter.php index ea4322f50264e65b930c782099071ca59db85834..d1e4ec7853531dd0a0bd3af005209866f0a41fd3 100644 --- a/lib/internal/Magento/Framework/Service/SimpleDataObjectConverter.php +++ b/lib/internal/Magento/Framework/Service/SimpleDataObjectConverter.php @@ -25,6 +25,7 @@ namespace Magento\Framework\Service; use Magento\Framework\Convert\ConvertArray; use Magento\Framework\Service\Data\AbstractExtensibleObject; +use Magento\Framework\Service\Data\AbstractSimpleObject; class SimpleDataObjectConverter { @@ -107,9 +108,31 @@ class SimpleDataObjectConverter $result[$key] = $value; } } - return $result; + return $this->_unpackAssociativeArray($result); } + /** + * Unpack associative array packed by SOAP server into key-value + * + * @param mixed $data + * @return array Unpacked associative array if array was passed as argument or original value otherwise + */ + protected function _unpackAssociativeArray($data) + { + if (!is_array($data)) { + return $data; + } else { + foreach ($data as $key => $value) { + if (is_array($value) && count($value) == 2 && isset($value['key']) && isset($value['value'])) { + $data[$value['key']] = $this->_unpackAssociativeArray($value['value']); + unset($data[$key]); + } else { + $data[$key] = $this->_unpackAssociativeArray($value); + } + } + return $data; + } + } /** * Converts an input string from snake_case to upper CamelCase. @@ -117,13 +140,63 @@ class SimpleDataObjectConverter * @param string $input * @return string */ - public static function snakeCaseToCamelCase($input) + public static function snakeCaseToUpperCamelCase($input) { - $output = ''; - $segments = explode('_', $input); - foreach ($segments as $segment) { - $output .= ucfirst($segment); + return str_replace(' ', '', ucwords(str_replace('_', ' ', $input))); + } + + /** + * Converts the incoming data into scalar or an array of scalars format. + * + * If the data provided is null, then an empty array is returned. Otherwise, if the data is an object, it is + * assumed to be a Data Object and converted to an associative array with keys representing the properties of the + * Data Object. + * Nested Data Objects are also converted. If the data provided is itself an array, then we iterate through the + * contents and convert each piece individually. + * + * @param mixed $data + * @return array|int|string|bool|float Scalar or array of scalars + */ + public function processServiceOutput($data) + { + if (is_array($data)) { + $result = []; + foreach ($data as $datum) { + if ($datum instanceof AbstractSimpleObject) { + $datum = $this->processDataObject($datum->__toArray()); + } + $result[] = $datum; + } + return $result; + } else if ($data instanceof AbstractSimpleObject) { + return $this->processDataObject($data->__toArray()); + } else if (is_null($data)) { + return []; + } else { + /** No processing is required for scalar types */ + return $data; + } + } + + /** + * Convert data object to array and process available custom attributes + * + * @param array $dataObjectArray + * @return array + */ + protected function processDataObject($dataObjectArray) + { + if (isset($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) { + $dataObjectArray = ExtensibleDataObjectConverter::convertCustomAttributesToSequentialArray( + $dataObjectArray + ); + } + //Check for nested custom_attributes + foreach ($dataObjectArray as $key => $value) { + if (is_array($value)) { + $dataObjectArray[$key] = $this->processDataObject($value); + } } - return $output; + return $dataObjectArray; } } diff --git a/lib/internal/Magento/Framework/Session/Config.php b/lib/internal/Magento/Framework/Session/Config.php index 33f8d7047dbe374be81ba732407fc1a8635332a7..289fc2e25be710480d799148997b54f7e5d3d0dd 100644 --- a/lib/internal/Magento/Framework/Session/Config.php +++ b/lib/internal/Magento/Framework/Session/Config.php @@ -108,11 +108,6 @@ class Config implements ConfigInterface 'session.cookie_httponly' ); - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @var \Magento\Framework\App\Filesystem */ @@ -127,7 +122,6 @@ class Config implements ConfigInterface * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Stdlib\String $stringHelper * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\Filesystem $filesystem * @param string $scopeType * @param string $saveMethod @@ -139,7 +133,6 @@ class Config implements ConfigInterface \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\String $stringHelper, \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\App\State $appState, \Magento\Framework\App\Filesystem $filesystem, $scopeType, $saveMethod = \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, @@ -150,13 +143,12 @@ class Config implements ConfigInterface $this->_scopeConfig = $scopeConfig; $this->_stringHelper = $stringHelper; $this->_httpRequest = $request; - $this->_appState = $appState; $this->_filesystem = $filesystem; $this->_scopeType = $scopeType; $this->setSaveHandler($saveMethod === 'db' ? 'user' : $saveMethod); - if (!$this->_appState->isInstalled() || !$savePath) { + if (!$savePath) { $savePath = $this->_filesystem->getPath('session'); } $this->setSavePath($savePath); diff --git a/lib/internal/Magento/Framework/Session/Generic.php b/lib/internal/Magento/Framework/Session/Generic.php index d429ec02720dcc83a49e94256c33912c4dca51bb..db8344c12ee3cbe520a416d928ec4217a1427b95 100644 --- a/lib/internal/Magento/Framework/Session/Generic.php +++ b/lib/internal/Magento/Framework/Session/Generic.php @@ -36,7 +36,6 @@ class Generic extends SessionManager * @param StorageInterface $storage * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory - * @param null $sessionName */ public function __construct( \Magento\Framework\App\Request\Http $request, @@ -46,8 +45,7 @@ class Generic extends SessionManager ValidatorInterface $validator, StorageInterface $storage, \Magento\Framework\Stdlib\CookieManager $cookieManager, - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - $sessionName = null + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory ) { parent::__construct( $request, @@ -59,6 +57,6 @@ class Generic extends SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start($sessionName); + $this->start(); } } diff --git a/lib/internal/Magento/Framework/Session/SessionManager.php b/lib/internal/Magento/Framework/Session/SessionManager.php index a2f3461f0f875ac39bb3721d222a97540a9645d4..810ad1009629f99dfe243d102059c138939b48e7 100644 --- a/lib/internal/Magento/Framework/Session/SessionManager.php +++ b/lib/internal/Magento/Framework/Session/SessionManager.php @@ -170,18 +170,14 @@ class SessionManager implements SessionManagerInterface /** * Configure session handler and start session * - * @param string $sessionName * @return $this */ - public function start($sessionName = null) + public function start() { if (!$this->isSessionExists()) { \Magento\Framework\Profiler::start('session_start'); // Need to apply the config options so they can be ready by session_start $this->initIniOptions(); - if (!empty($sessionName)) { - $this->setName($sessionName); - } $this->registerSaveHandler(); // potential custom logic for session id (ex. switching between hosts) diff --git a/lib/internal/Magento/Framework/Session/SessionManagerInterface.php b/lib/internal/Magento/Framework/Session/SessionManagerInterface.php index 5a54bf8e8a65f0737e45033a6a1ebfbd127b301e..55e5d262e2b5234b0f547d90bf512c31f2620441 100644 --- a/lib/internal/Magento/Framework/Session/SessionManagerInterface.php +++ b/lib/internal/Magento/Framework/Session/SessionManagerInterface.php @@ -38,10 +38,9 @@ interface SessionManagerInterface /** * Start session * - * @param string $sessionName * @return SessionManagerInterface */ - public function start($sessionName = null); + public function start(); /** * Session write close diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php index ad73a649e29dffc5db58fb877f44fd462d8158a8..b78c8f5236b63427b6f23a3737ffb2a6503e2dbd 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php @@ -34,6 +34,9 @@ class CookieMetadata */ const KEY_DOMAIN = 'domain'; const KEY_PATH = 'path'; + const KEY_SECURE = 'secure'; + const KEY_HTTP_ONLY = 'http_only'; + const KEY_DURATION = 'duration'; /**#@-*/ /** @@ -134,4 +137,24 @@ class CookieMetadata $this->metadata[$name] = $value; return $this; } + + /** + * Get HTTP Only flag + * + * @return bool|null + */ + public function getHttpOnly() + { + return $this->get(self::KEY_HTTP_ONLY); + } + + /** + * Get whether the cookie is only available under HTTPS + * + * @return bool|null + */ + public function getSecure() + { + return $this->get(self::KEY_SECURE); + } } diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php index 34640b77f077cf3b6d09290c54677fa621810540..718f3aab1923dc0721c7b0212fd33404c42f600c 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php @@ -27,7 +27,7 @@ namespace Magento\Framework\Stdlib\Cookie; /** * CookieScope is used to store default scope metadata. */ -class CookieScope +class CookieScope implements CookieScopeInterface { /** * @var SensitiveCookieMetadata diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScopeInterface.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScopeInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..0d66a5478457670cb643f1c2ad2cd6342e744d76 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScopeInterface.php @@ -0,0 +1,58 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Stdlib\Cookie; + + +/** + * CookieScope is used to store default scope metadata. + */ +interface CookieScopeInterface +{ + /** + * Merges the input override metadata with any defaults set on this Scope, and then returns a CookieMetadata + * object representing the merged values. + * + * @param SensitiveCookieMetadata|null $override + * @return SensitiveCookieMetadata + */ + public function getSensitiveCookieMetadata(SensitiveCookieMetadata $override = null); + + /** + * Merges the input override metadata with any defaults set on this Scope, and then returns a CookieMetadata + * object representing the merged values. + * + * @param PublicCookieMetadata|null $override + * @return PublicCookieMetadata + */ + public function getPublicCookieMetadata(PublicCookieMetadata $override = null); + + /** + * Merges the input override metadata with any defaults set on this Scope, and then returns a CookieMetadata + * object representing the merged values. + * + * @param CookieMetadata|null $override + * @return CookieMetadata + */ + public function getCookieMetadata(CookieMetadata $override = null); +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php index 90ba0fa4077a1192a2270584049bf354ba3681fc..68d1e07ec4b472445e12820b562aa5eadc52a0f4 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php @@ -56,14 +56,14 @@ class PhpCookieManager implements CookieManager /** - * @var CookieScope + * @var CookieScopeInterface */ private $scope; /** - * @param CookieScope $scope + * @param CookieScopeInterface $scope */ - public function __construct(CookieScope $scope) + public function __construct(CookieScopeInterface $scope) { $this->scope = $scope; } @@ -85,9 +85,6 @@ class PhpCookieManager implements CookieManager public function setSensitiveCookie($name, $value, SensitiveCookieMetadata $metadata = null) { $metadataArray = $this->scope->getSensitiveCookieMetadata($metadata)->__toArray(); - $metadataArray[PublicCookieMetadata::KEY_SECURE] = true; - $metadataArray[PublicCookieMetadata::KEY_HTTP_ONLY] = true; - $this->setCookie($name, $value, $metadataArray); } @@ -134,8 +131,8 @@ class PhpCookieManager implements CookieManager $expire, $this->extractValue(CookieMetadata::KEY_PATH, $metadataArray, ''), $this->extractValue(CookieMetadata::KEY_DOMAIN, $metadataArray, ''), - $this->extractValue(PublicCookieMetadata::KEY_SECURE, $metadataArray, false), - $this->extractValue(PublicCookieMetadata::KEY_HTTP_ONLY, $metadataArray, false) + $this->extractValue(CookieMetadata::KEY_SECURE, $metadataArray, false), + $this->extractValue(CookieMetadata::KEY_HTTP_ONLY, $metadataArray, false) ); if (!$phpSetcookieSuccess) { @@ -219,8 +216,8 @@ class PhpCookieManager implements CookieManager ) { $expireTime = $metadataArray[PhpCookieManager::KEY_EXPIRE_TIME]; } else { - if (isset($metadataArray[PublicCookieMetadata::KEY_DURATION])) { - $expireTime = $metadataArray[PublicCookieMetadata::KEY_DURATION] + time(); + if (isset($metadataArray[CookieMetadata::KEY_DURATION])) { + $expireTime = $metadataArray[CookieMetadata::KEY_DURATION] + time(); } else { $expireTime = PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME; } diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php index f8d146701abe65c09bcd381114bc25dc23cb6a75..d42c1593200af0e77abcfb40a53652d569a1374d 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php @@ -30,14 +30,6 @@ namespace Magento\Framework\Stdlib\Cookie; */ class PublicCookieMetadata extends CookieMetadata { - /**#@+ - * Constant for metadata value key. - */ - const KEY_SECURE = 'secure'; - const KEY_HTTP_ONLY = 'http_only'; - const KEY_DURATION = 'duration'; - /**#@-*/ - /** * Set the number of seconds until the cookie expires * @@ -84,16 +76,6 @@ class PublicCookieMetadata extends CookieMetadata return $this->set(self::KEY_HTTP_ONLY, $httpOnly); } - /** - * Get HTTPOnly flag - * - * @return bool|null - */ - public function getHttpOnly() - { - return $this->get(self::KEY_HTTP_ONLY); - } - /** * Set whether the cookie is only available under HTTPS * @@ -104,14 +86,4 @@ class PublicCookieMetadata extends CookieMetadata { return $this->set(self::KEY_SECURE, $secure); } - - /** - * Get whether the cookie is only available under HTTPS - * - * @return bool|null - */ - public function getSecure() - { - return $this->get(self::KEY_SECURE); - } } diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php index 428c4f22b751ce3c291894711835db26ce0346fa..b053bcd83e1257f8ddd2eafe6e14e9474c407f89 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php @@ -24,6 +24,8 @@ namespace Magento\Framework\Stdlib\Cookie; +use Magento\Framework\StoreManagerInterface; + /** * Class SensitiveCookieMetadata * @@ -32,5 +34,57 @@ namespace Magento\Framework\Stdlib\Cookie; */ class SensitiveCookieMetadata extends CookieMetadata { + /** + * @var StoreManagerInterface + */ + protected $storeManager; + + /** + * @param StoreManagerInterface $storeManager + * @param array $metadata + */ + public function __construct(StoreManagerInterface $storeManager, $metadata = []) + { + if (!isset($metadata[self::KEY_HTTP_ONLY])) { + $metadata[self::KEY_HTTP_ONLY] = true; + } + $this->storeManager = $storeManager; + parent::__construct($metadata); + } + + + /** + * {@inheritdoc} + */ + public function getSecure() + { + $this->updateSecureValue(); + return $this->get(self::KEY_SECURE); + } + + /** + * {@inheritdoc} + */ + public function __toArray() + { + $this->updateSecureValue(); + return parent::__toArray(); + } + /** + * Update secure value, set it to store setting if it has no explicit value assigned. + * + * @return void + */ + private function updateSecureValue() + { + if (null === $this->get(self::KEY_SECURE)) { + $store = $this->storeManager->getStore(); + if (empty($store)) { + $this->set(self::KEY_SECURE, true); + } else { + $this->set(self::KEY_SECURE, $store->isCurrentlySecure()); + } + } + } } diff --git a/app/code/Magento/Store/Model/StoreManagerInterface.php b/lib/internal/Magento/Framework/StoreManagerInterface.php similarity index 95% rename from app/code/Magento/Store/Model/StoreManagerInterface.php rename to lib/internal/Magento/Framework/StoreManagerInterface.php index 42ea5ed3e50932cdb7ed95f536b39cacee91d075..e46867b09aa17c1bb202f8516dfe7edb8eb05f30 100644 --- a/app/code/Magento/Store/Model/StoreManagerInterface.php +++ b/lib/internal/Magento/Framework/StoreManagerInterface.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Store\Model; +namespace Magento\Framework; interface StoreManagerInterface { @@ -52,7 +52,6 @@ interface StoreManagerInterface * * @param null|string|bool|int|\Magento\Store\Model\Store $storeId * @return \Magento\Store\Model\Store - * @throws \Magento\Store\Model\Exception */ public function getStore($storeId = null); @@ -102,8 +101,6 @@ interface StoreManagerInterface * * @param null|\Magento\Store\Model\Group|string $groupId * @return \Magento\Store\Model\Group - * @throws \Magento\Store\Model\Exception - * @throws \Magento\Framework\Model\Exception */ public function getGroup($groupId = null); diff --git a/lib/internal/Magento/Framework/View/Asset/Repository.php b/lib/internal/Magento/Framework/View/Asset/Repository.php index 667a5ce4f06eceafa40573f01756d07c49adc8c2..24b217b509c93f93c4ed2179662dac0c958c7990 100644 --- a/lib/internal/Magento/Framework/View/Asset/Repository.php +++ b/lib/internal/Magento/Framework/View/Asset/Repository.php @@ -50,9 +50,9 @@ class Repository private $design; /** - * @var \Magento\Framework\View\Design\Theme\Provider + * @var \Magento\Framework\View\Design\Theme\ListInterface */ - private $themeProvider; + private $themeList; /** * @var \Magento\Framework\View\Asset\Source @@ -72,18 +72,18 @@ class Repository /** * @param \Magento\Framework\UrlInterface $baseUrl * @param \Magento\Framework\View\DesignInterface $design - * @param \Magento\Framework\View\Design\Theme\Provider $themeProvider + * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList * @param \Magento\Framework\View\Asset\Source $assetSource */ public function __construct( \Magento\Framework\UrlInterface $baseUrl, \Magento\Framework\View\DesignInterface $design, - \Magento\Framework\View\Design\Theme\Provider $themeProvider, + \Magento\Framework\View\Design\Theme\ListInterface $themeList, \Magento\Framework\View\Asset\Source $assetSource ) { $this->baseUrl = $baseUrl; $this->design = $design; - $this->themeProvider = $themeProvider; + $this->themeList = $themeList; $this->assetSource = $assetSource; } @@ -117,7 +117,7 @@ class Repository } if ($theme) { - $params['themeModel'] = $this->themeProvider->getThemeModel($theme, $area); + $params['themeModel'] = $this->themeList->getThemeByFullPath($area . '/' . $theme); if (!$params['themeModel']) { throw new \UnexpectedValueException("Could not find theme '$theme' for area '$area'"); } diff --git a/lib/internal/Magento/Framework/View/Asset/Source.php b/lib/internal/Magento/Framework/View/Asset/Source.php index 5d40493a79b1d1658d9952c6bf4397edc69b50f0..205eb255872884c3ad455d1ca93324c179064086 100644 --- a/lib/internal/Magento/Framework/View/Asset/Source.php +++ b/lib/internal/Magento/Framework/View/Asset/Source.php @@ -69,23 +69,23 @@ class Source protected $fallback; /** - * @var \Magento\Framework\View\Design\Theme\Provider + * @var \Magento\Framework\View\Design\Theme\ListInterface */ - protected $themeProvider; + protected $themeList; /** * @param PreProcessor\Cache $cache * @param \Magento\Framework\App\Filesystem $filesystem * @param PreProcessor\Pool $preProcessorPool * @param \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile $fallback - * @param \Magento\Framework\View\Design\Theme\Provider $themeProvider + * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList */ public function __construct( PreProcessor\Cache $cache, \Magento\Framework\App\Filesystem $filesystem, PreProcessor\Pool $preProcessorPool, \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile $fallback, - \Magento\Framework\View\Design\Theme\Provider $themeProvider + \Magento\Framework\View\Design\Theme\ListInterface $themeList ) { $this->cache = $cache; $this->filesystem = $filesystem; @@ -93,7 +93,7 @@ class Source $this->varDir = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR); $this->preProcessorPool = $preProcessorPool; $this->fallback = $fallback; - $this->themeProvider = $themeProvider; + $this->themeList = $themeList; } /** @@ -217,7 +217,7 @@ class Source LocalInterface $asset, \Magento\Framework\View\Asset\File\FallbackContext $context ) { - $themeModel = $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode()); + $themeModel = $this->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath()); $sourceFile = $this->fallback->getFile( $context->getAreaCode(), $themeModel, diff --git a/lib/internal/Magento/Framework/View/Design/Theme/Provider.php b/lib/internal/Magento/Framework/View/Design/Theme/Provider.php deleted file mode 100644 index 80476a217886c5022e72816213700ad38489038c..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/View/Design/Theme/Provider.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Framework\View\Design\Theme; - -class Provider -{ - /** - * @var \Magento\Framework\App\State - */ - protected $appState; - - /** - * @var FlyweightFactory - */ - private $flyweightFactory; - - /** - * @var ListInterface - */ - private $themeList; - - /** - * @param \Magento\Framework\App\State $appState - * @param FlyweightFactory $flyweightFactory - * @param ListInterface $themeList - */ - public function __construct( - \Magento\Framework\App\State $appState, - FlyweightFactory $flyweightFactory, - ListInterface $themeList - ) { - $this->appState = $appState; - $this->flyweightFactory = $flyweightFactory; - $this->themeList = $themeList; - } - - /** - * Get theme model by theme path and area code - * - * @param string $themePath - * @param string $areaCode - * @return \Magento\Framework\View\Design\ThemeInterface - */ - public function getThemeModel($themePath, $areaCode) - { - if ($this->appState->isInstalled()) { - $themeModel = $this->flyweightFactory->create($themePath, $areaCode); - } else { - $themeModel = $this->themeList->getThemeByFullPath($areaCode . '/' . $themePath); - } - return $themeModel; - } -} diff --git a/lib/internal/Magento/Framework/View/Element/Template.php b/lib/internal/Magento/Framework/View/Element/Template.php index ac2a1d39b2b0b07fbb101d30372d08595fd0c26d..1ea5a982430b0a6bfeed698715d28c05f48cb30e 100644 --- a/lib/internal/Magento/Framework/View/Element/Template.php +++ b/lib/internal/Magento/Framework/View/Element/Template.php @@ -95,7 +95,7 @@ class Template extends AbstractBlock /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; diff --git a/lib/internal/Magento/Framework/View/Element/Template/Context.php b/lib/internal/Magento/Framework/View/Element/Template/Context.php index b19e30b060d233805ed7b1b60cf30b082061c3a0..dd248e7b8d5755da4c40f435e5186d071c6198a0 100644 --- a/lib/internal/Magento/Framework/View/Element/Template/Context.php +++ b/lib/internal/Magento/Framework/View/Element/Template/Context.php @@ -54,7 +54,7 @@ class Context extends \Magento\Framework\View\Element\Context /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -81,7 +81,7 @@ class Context extends \Magento\Framework\View\Element\Context * @param \Magento\Framework\View\FileSystem $viewFileSystem * @param \Magento\Framework\View\TemplateEnginePool $enginePool * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -108,7 +108,7 @@ class Context extends \Magento\Framework\View\Element\Context \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\View\TemplateEnginePool $enginePool, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct( $request, @@ -192,7 +192,7 @@ class Context extends \Magento\Framework\View\Element\Context /** * Get store manager * - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface */ public function getStoreManager() { diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index 57bec853356aa1ff551f81f4829daca5432f8927..fa8a2103ab530df44a4057a5f57a5fef0f251b5d 100644 --- a/lib/internal/Magento/Framework/composer.json +++ b/lib/internal/Magento/Framework/composer.json @@ -2,7 +2,7 @@ "name": "magento/framework", "description": "N/A", "type": "magento2-library", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { "php": "~5.4.11|~5.5.0", "ext-spl": "*", diff --git a/lib/web/tiny_mce/plugins/media/img/flv_player.swf b/lib/web/tiny_mce/plugins/media/img/flv_player.swf deleted file mode 100644 index 042c2ab969e98a6fdbe08848c4a73bd2c41de906..0000000000000000000000000000000000000000 Binary files a/lib/web/tiny_mce/plugins/media/img/flv_player.swf and /dev/null differ diff --git a/pub/cron.php b/pub/cron.php index 17eee445c031a8230d3ec4cefb1bc2622ee2dfd8..1bc57e79eb62b0a91b931240f70ccf718c058b65 100644 --- a/pub/cron.php +++ b/pub/cron.php @@ -23,10 +23,16 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + +use Magento\Framework\App\Bootstrap; +use Magento\Store\Model\Store; use Magento\Store\Model\StoreManager; require dirname(__DIR__) . '/app/bootstrap.php'; -umask(0); -$params = array(StoreManager::PARAM_RUN_CODE => 'admin', \Magento\Store\Model\Store::CUSTOM_ENTRY_POINT_PARAM => true); -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Framework\App\Cron', array('parameters' => array('group::'))); +$params = $_SERVER; +$params[StoreManager::PARAM_RUN_CODE] = 'admin'; +$params[Store::CUSTOM_ENTRY_POINT_PARAM] = true; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Framework\App\Cron $app */ +$app = $bootstrap->createApplication('Magento\Framework\App\Cron', ['parameters' => ['group::']]); +$bootstrap->run($app); diff --git a/pub/errors/default/report.phtml b/pub/errors/default/report.phtml index 2d055b164eaf386e979433f10763ddcb9fdba40b..3c73cbebb71bb9e7e2cdb181196e8c72dcc0c658 100644 --- a/pub/errors/default/report.phtml +++ b/pub/errors/default/report.phtml @@ -100,7 +100,7 @@ </div> </div> <?php endif; ?> - <?php if ($this->reportId && $this->reportUrl): ?> - <p>Error log record number: <a href="<?php echo htmlspecialchars($this->reportUrl) ?>"><?php echo $this->reportId ?></a></p> + <?php if ($this->reportId): ?> + <p>Error log record number: <?php echo $this->reportId ?></p> <?php endif; ?> </div> diff --git a/pub/get.php b/pub/get.php index 83c079d35d0a6f9cc9511c793de7bd4095182e5c..297e40179b4cd010017934e5539cc8bc5ab988d5 100644 --- a/pub/get.php +++ b/pub/get.php @@ -80,19 +80,20 @@ if ($mediaDirectory) { // Materialize file in application $params = $_SERVER; if (empty($mediaDirectory)) { - $params[Filesystem::PARAM_ALLOWED_MODULES] = array('Magento_Core'); - $params[Factory::PARAM_CACHE_FORCED_OPTIONS]['frontend_options']['disable_save'] = true; + $params[Filesystem::PARAM_ALLOWED_MODULES] = ['Magento_Core']; + $params[Factory::PARAM_CACHE_FORCED_OPTIONS] = ['frontend_options' => ['disable_save' => true]]; } - -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(dirname(__DIR__), $params); -$entryPoint->run( +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Core\App\Media $app */ +$app = $bootstrap->createApplication( 'Magento\Core\App\Media', - array( + [ 'request' => $request, 'workingDirectory' => __DIR__, 'mediaDirectory' => $mediaDirectory, 'configCacheFile' => $configCacheFile, 'isAllowed' => $isAllowed, 'relativeFileName' => $relativeFilename, - ) + ] ); +$bootstrap->run($app); diff --git a/pub/index.php b/pub/index.php index c3a588b2f487f6dfaae8fc780a3049b2b7de0d28..a140566bbe18d86c5a6c127fc78b4913fa91d9bb 100644 --- a/pub/index.php +++ b/pub/index.php @@ -23,15 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require __DIR__ . '/../app/bootstrap.php'; use Magento\Framework\App\Filesystem; +require __DIR__ . '/../app/bootstrap.php'; $params = $_SERVER; - -$params[Filesystem::PARAM_APP_DIRS][Filesystem::PUB_DIR] = array('uri' => ''); -$params[Filesystem::PARAM_APP_DIRS][Filesystem::MEDIA_DIR] = array('uri' => 'media'); -$params[Filesystem::PARAM_APP_DIRS][Filesystem::STATIC_VIEW_DIR] = array('uri' => 'static'); -$params[Filesystem::PARAM_APP_DIRS][Filesystem::UPLOAD_DIR] = array('uri' => 'media/upload'); -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Framework\App\Http'); +$params[Filesystem::PARAM_APP_DIRS] = [ + Filesystem::PUB_DIR => ['uri' => ''], + Filesystem::MEDIA_DIR => ['uri' => 'media'], + Filesystem::STATIC_VIEW_DIR => ['uri' => 'static'], + Filesystem::UPLOAD_DIR => ['uri' => 'media/upload'], +]; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Framework\App\Http $app */ +$app = $bootstrap->createApplication('Magento\Framework\App\Http'); +$bootstrap->run($app); diff --git a/pub/static.php b/pub/static.php index 174eee22ac120aedea700f579698d07a3a93cc23..2365fde3fcc6a61151fbafef6697d1f7a9f6bda6 100644 --- a/pub/static.php +++ b/pub/static.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require __DIR__ . '/../app/bootstrap.php'; -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $_SERVER); -$entryPoint->run('Magento\Framework\App\StaticResource'); +require __DIR__ . '/../app/bootstrap.php'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); +/** @var \Magento\Framework\App\StaticResource $app */ +$app = $bootstrap->createApplication('Magento\Framework\App\StaticResource'); +$bootstrap->run($app); diff --git a/setup/composer.json b/setup/composer.json index d69927ba5fa8170d138331f6a91364eff3482758..639c6f37b1b3743beac646aa33cbbec884193190 100644 --- a/setup/composer.json +++ b/setup/composer.json @@ -1,5 +1,6 @@ { - "name": "Magento Setup Tool", + "name": "magento/project-setup", + "version": "0.1.0", "require": { "zendframework/zendframework": "2.3.1", "composer/composer": "1.0.*@dev" diff --git a/setup/module/Magento/Setup/src/Controller/Install/StartController.php b/setup/module/Magento/Setup/src/Controller/Install/StartController.php index f70ca86268f520c9bb93aa9841a9dd1f5b073a73..1a5ce07b640aba700cf02779e9044b5649baa5d4 100644 --- a/setup/module/Magento/Setup/src/Controller/Install/StartController.php +++ b/setup/module/Magento/Setup/src/Controller/Install/StartController.php @@ -29,6 +29,7 @@ use Magento\Module\Setup\Config; use Magento\Module\SetupFactory; use Magento\Setup\Model\AdminAccountFactory; use Magento\Setup\Model\Logger; +use Magento\Config\ConfigFactory; use Zend\Json\Json; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; @@ -55,6 +56,11 @@ class StartController extends AbstractActionController */ protected $config; + /** + * @var ConfigFactory + */ + protected $systemConfig; + /** * @var AdminAccountFactory */ @@ -81,13 +87,15 @@ class StartController extends AbstractActionController AdminAccountFactory $adminAccountFactory, Logger $logger, Random $random, - Config $config + Config $config, + ConfigFactory $systemConfig ) { $this->logger = $logger; $this->json = $view; $this->moduleList = $moduleList->getModules(); $this->setupFactory = $setupFactory; $this->config = $config; + $this->systemConfig = $systemConfig; $this->adminAccountFactory = $adminAccountFactory; $this->random = $random; } @@ -112,7 +120,6 @@ class StartController extends AbstractActionController $setup->applyUpdates(); $this->logger->logSuccess($moduleName); } - $this->logger->logSuccess('Artifact'); // Set data to config @@ -120,6 +127,7 @@ class StartController extends AbstractActionController 'web/seo/use_rewrites', isset($data['config']['rewrites']['allowed']) ? $data['config']['rewrites']['allowed'] : 0 ); + $setup->addConfigData( 'web/unsecure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{unsecure_base_url}}' @@ -163,12 +171,63 @@ class StartController extends AbstractActionController } else { $key = $data['config']['encrypt']['key']; } - $this->config->replaceTmpEncryptKey($key); + $this->config->replaceTmpEncryptKey($key); $this->config->replaceTmpInstallDate(date('r')); - $this->json->setVariable('success', true); + $phpPath = $this->phpExecutablePath(); + exec( + $phpPath . + 'php -f ' . escapeshellarg($this->systemConfig->create()->getMagentoBasePath() . + '/dev/shell/run_data_fixtures.php'), + $output, + $exitCode + ); + if ($exitCode !== 0) { + $outputMsg = implode(PHP_EOL, $output); + $this->logger->logError( + new \Exception('Data Update Failed with Exit Code: ' . $exitCode . PHP_EOL . $outputMsg) + ); + $this->json->setVariable('success', false); + } else { + $this->logger->logSuccess('Data Updates'); + $this->json->setVariable('success', true); + } + $this->json->setVariable('key', $key); return $this->json; } + + /** + * @return string + * @throws \Exception + */ + private function phpExecutablePath() + { + try { + $phpPath = ''; + $iniFile = fopen(php_ini_loaded_file(), 'r'); + while ($line = fgets($iniFile)) { + if ((strpos($line, 'extension_dir') !== false) && (strrpos($line, ";") !==0)) { + $extPath = explode("=", $line); + $pathFull = explode("\"", $extPath[1]); + $pathParts[1] = str_replace('\\', '/', $pathFull[1]); + foreach (explode('/', $pathParts[1]) as $piece) { + $phpPath .= $piece . '/'; + if (strpos($piece, phpversion()) !== false) { + if (file_exists($phpPath.'bin')) { + $phpPath .= 'bin' . '/'; + } + break; + } + } + } + } + fclose($iniFile); + } catch(\Exception $e){ + throw $e; + } + + return $phpPath; + } } diff --git a/setup/module/Magento/Setup/src/Model/AdminAccount.php b/setup/module/Magento/Setup/src/Model/AdminAccount.php index bc882ddb135218aad7678c07906f1bd922b05f7b..6d3b1f60c63013f1602520d1b6c9fd2ddc5003ca 100644 --- a/setup/module/Magento/Setup/src/Model/AdminAccount.php +++ b/setup/module/Magento/Setup/src/Model/AdminAccount.php @@ -102,6 +102,7 @@ class AdminAccount 'sort_order' => 1, 'role_type' => 'G', 'user_id' => 0, + 'user_type' => 2, 'role_name' => 'Administrators', ], 1 => [ @@ -110,6 +111,7 @@ class AdminAccount 'sort_order' => 0, 'role_type' => 'U', 'user_id' => $adminId, + 'user_type' => 2, 'role_name' => $this->config['admin_username'], ] ]; diff --git a/var/.htaccess b/var/.htaccess index 93169e4eb44ffa5e6251f3532bb1902854703f07..896fbc5a341ea313ff3abd503808842757678c1d 100644 --- a/var/.htaccess +++ b/var/.htaccess @@ -1,2 +1,2 @@ Order deny,allow -Deny from all +Deny from all \ No newline at end of file